• Fred's avatar
    重大 · 17e75b03
    Fred authored
    17e75b03
MenuController.java 1.49 KB
package com.govmade.modules.system.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.R;
import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.MenuEntity;
import com.govmade.modules.system.service.MenuService;

/**
 * 系统管理 - 菜单设置
 * 
 * @author Fred
 * @email fangtaosh@qq.com
 * @date 2018年8月3日
 */
@RestController
@RequestMapping("/system/menu")
public class MenuController extends AbstractController {

	@Autowired
	private MenuService menuService;

	/**
	 * 菜单列表
	 */
	@GetMapping("/list")
	public R list(Map<String, Object> params) {

		menuService.queryPage(params);
		return null;
	}
	
	/**
	 * 保存或更新用户
	 */
	@PostMapping("/save")
	public R save(MenuEntity menu) {

		if (null == menu.getId()) {
			if (this.menuService.checkMenu(menu.getName()) > 0) {
				return R.error(menu.getName() + " 已存在!");
			}
		}
		return R.ok();
	}

	/**
	 * 根据ID查询菜单
	 * 
	 * @param id
	 * @return
	 */
	@GetMapping("info/{id}")
	public R info(@PathVariable("id") Long id) {
		return R.ok().put("menu", menuService.queryById(id));
	}
}