MenuController.java 1.49 KB
Newer Older
Fred's avatar
Fred committed
1 2
package com.govmade.modules.system.controller;

Fred's avatar
Fred committed
3 4 5 6 7 8
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;
Fred's avatar
Fred committed
9 10
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Fred's avatar
Fred committed
11
import com.govmade.common.utils.R;
Fred's avatar
Fred committed
12
import com.govmade.modules.basic.controller.AbstractController;
Fred's avatar
Fred committed
13 14
import com.govmade.modules.system.entity.MenuEntity;
import com.govmade.modules.system.service.MenuService;
Fred's avatar
Fred committed
15 16 17 18 19 20 21 22 23 24 25 26

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

Fred's avatar
Fred committed
27 28 29 30 31 32 33 34 35 36 37 38
	@Autowired
	private MenuService menuService;

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

		menuService.queryPage(params);
		return null;
	}
Fred's avatar
Fred committed
39
	
Fred's avatar
Fred committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
	/**
	 * 保存或更新用户
	 */
	@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));
	}
Fred's avatar
Fred committed
64
}