| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package com.xintong.visualinspection.controller;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.xintong.system.err.BusinessException;
- import com.xintong.visualinspection.bean.Menu;
- import com.xintong.visualinspection.bean.Permission;
- import com.xintong.visualinspection.bean.User;
- import com.xintong.visualinspection.dao.master.PermissionDao;
- import com.xintong.visualinspection.service.MenuService;
- /**
- * 文件名:TestController
- * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
- */
- /**
- * @author wenhongquan
- *
- */
- @RestController
- @RequestMapping("/menu")
- public class MenuController extends BaseController {
- @Autowired
- private MenuService menuService;
-
-
-
- /**
- * 添加菜单
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- // @PreAuthorize("hasRole('ADMIN')")
- @RequestMapping(value = "/addMenu",method=RequestMethod.POST,produces="application/json;charset=UTF-8")
- public String addMenu(@RequestBody Menu menu) throws Exception{
- menu.setStatus(0);
- menuService.insert(menu);
- return returnResult(0, "添加成功", null);
- }
-
- /**
- * 修改菜单
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/updateMenu/{menuid}",produces="application/json;charset=UTF-8")
- public String updateMenu(@RequestBody Menu menu,@PathVariable int menuid){
- try{
- menu.setId(menuid);
- menuService.update(menu);
- return super.returnResult(0, "修改成功", null);
- }catch(Exception e){
- throw new BusinessException(20003);
- }
- }
-
- /**
- * 删除菜单(软删除)
- * @return
- * String
- * @exception
- * @since 1.0.0
- */
- @RequestMapping(value = "/deleteMenu/{menuid}",produces="application/json;charset=UTF-8")
- public String deleteMenu(@PathVariable Integer menuid){
- try{
- menuService.delete((menuid));
- return returnResult(0, "删除成功", null);
- }catch(Exception e){
- throw new BusinessException(20002);
- }
- }
-
- /**
- * 获取所有菜单
- * @param page
- * @param size
- * @return
- */
- @RequestMapping(value = "/get/all",method=RequestMethod.GET,produces="application/json;charset=UTF-8")
- public String getAllMenu(HttpServletRequest request,@RequestParam(required=false) Integer judge){
- try{
- User u = getCurrentUser(request);
- List<Menu> menus= menuService.getMenus(new Menu(),u,judge);
- return returnResult(0, "获取成功", menus);
- }catch(Exception e){
- throw new BusinessException(20001);
- }
- }
-
- @RequestMapping(value = "/getMenuByParent/{pid}/{page}/{size}",produces="application/json;charset=UTF-8")
- public String getMenuByParent(@PathVariable Integer pid,@PathVariable Integer page,@PathVariable Integer size){
- try{
- PageHelper.startPage(page, size);
- Menu menu =new Menu();
- menu.setParentId(pid);
- List<Menu> menus= menuService.getMenuByParent(menu);
-
- return returnResult(0, "获取成功", new PageInfo(menus));
- }catch(Exception e){
- throw new BusinessException(20001);
- }
- }
-
- @RequestMapping(value = "/getMenuById/{menuid}",method=RequestMethod.GET,produces="application/json;charset=UTF-8")
- public String getMenuById(@PathVariable Integer menuid,HttpServletRequest request){
- try{
- User u = getCurrentUser(request);
- Menu menu = new Menu();
- menu.setId(menuid);
-
- List<Menu> menus = menuService.getMenus(menu,u,0);
- if(menus==null||menus.size()<1 ) throw new BusinessException(20001);
- return returnResult(0, "获取成功", menus.get(0));
- }catch(Exception e){
- throw new BusinessException(20001);
- }
- }
-
-
-
-
-
-
-
-
- }
|