1 files added
	
		
		11 files modified
	
	
 
	
	
	
	
	
	
	
	
| New file | 
 |  |  | 
 |  |  | package com.moral.api.controller; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSON; | 
 |  |  | import com.moral.api.entity.ManageMenu; | 
 |  |  | import com.moral.api.entity.ManageRole; | 
 |  |  | import com.moral.api.service.ManageMenuService; | 
 |  |  | import com.moral.api.service.ManageRoleService; | 
 |  |  | import com.moral.constant.ResultMessage; | 
 |  |  | import com.moral.util.WebUtils; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiImplicitParam; | 
 |  |  | import io.swagger.annotations.ApiImplicitParams; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.PathVariable; | 
 |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
 |  |  | import org.springframework.web.bind.annotation.RequestMethod; | 
 |  |  | import org.springframework.web.bind.annotation.RestController; | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletRequest; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | import static org.springframework.web.util.WebUtils.getParametersStartingWith; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @Api(tags = {"角色"}) | 
 |  |  | @RestController | 
 |  |  | @RequestMapping("/manage") | 
 |  |  | public class WebController { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ManageRoleService manageRoleService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ManageMenuService manageMenuService; | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "获取所有角色", notes = "获取所有角色") | 
 |  |  |     @ApiImplicitParams({}) | 
 |  |  |     @RequestMapping(value = "getAllManageRole", method = RequestMethod.GET) | 
 |  |  |     public ResultMessage getAllManageRole() { | 
 |  |  |         List<ManageRole> re = manageRoleService.getAll(); | 
 |  |  |         return ResultMessage.ok(re); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "新增角色", notes = "新增角色") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "desc", value = "备注", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "insertOneManageRole", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage insertOneManageRole(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         ManageRole manageRole = JSON.parseObject(JSON.toJSONString(parameters), ManageRole.class); | 
 |  |  |         List list = new ArrayList(); | 
 |  |  |         list.add(1); | 
 |  |  |         list.add(2); | 
 |  |  |         list.add(3); | 
 |  |  |         list.add(4); | 
 |  |  |         Map<String,Object> resultMap = manageRoleService.insertOne(manageRole,list); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "更新角色", notes = "更新角色") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "desc", value = "备注", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "updateManageRole", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage updateManageRole(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         Map<String,Object> resultMap = manageRoleService.updateManageRole(parameters); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "删除角色", notes = "删除角色") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "deleteManageRole", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage deleteManageRole(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         Map<String,Object> resultMap = manageRoleService.deleteManageRole(parameters); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "角色模糊查询", notes = "角色模糊查询") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "getManageRoleByNameFuzzy", method = RequestMethod.GET) | 
 |  |  |     public ResultMessage getManageRoleByNameFuzzy(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = getParametersStartingWith(request, null); | 
 |  |  |         ManageRole manageRole = JSON.parseObject(JSON.toJSONString(parameters), ManageRole.class); | 
 |  |  |         List<ManageRole> re = manageRoleService.getManageRoleByNameFuzzy(manageRole); | 
 |  |  |         return ResultMessage.ok(re); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "新增菜单", notes = "新增菜单") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "url", value = "url地址", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "icon", value = "图标地址", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "parent_id", value = "父菜单", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "order", value = "同级菜单顺序", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "insertOneManageMenu", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage insertOneManageMenu(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         ManageMenu manageMenu = JSON.parseObject(JSON.toJSONString(parameters), ManageMenu.class); | 
 |  |  |         Map<String,Object> resultMap = manageMenuService.insertManageMenu(manageMenu); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "更新菜单", notes = "更新菜单") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int"), | 
 |  |  |             @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), | 
 |  |  |             @ApiImplicitParam(name = "url", value = "url地址", required = true, paramType = "query", dataType = "String") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "updateManageMenuById", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage updateManageMenuById(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         Map<String,Object> resultMap = manageMenuService.updateManageMenu(parameters); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "删除角色", notes = "删除角色") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int") | 
 |  |  |     }) | 
 |  |  |     @RequestMapping(value = "deleteManageMenu", method = RequestMethod.POST) | 
 |  |  |     public ResultMessage deleteManageMenu(HttpServletRequest request) { | 
 |  |  |         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
 |  |  |         Map<String,Object> resultMap = manageMenuService.deleteManageMenu(parameters); | 
 |  |  |         String msg = resultMap.get("msg").toString(); | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             return ResultMessage.ok(msg); | 
 |  |  |         } | 
 |  |  |         return ResultMessage.fail(msg); | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |  | 
 |  |  |     List<ManageMenu> getParentChildrenMenusByRoles(List<ManageRole> roles); | 
 |  |  |  | 
 |  |  |     ManageMenu getManageMenuByName(String name); | 
 |  |  |  | 
 |  |  |     ManageMenu getManageMenuById(int id); | 
 |  |  |  | 
 |  |  |     void insertOne(ManageMenu manageMenu); | 
 |  |  |  | 
 |  |  |     void updateManageMenuById(Map map); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import org.apache.ibatis.annotations.Param; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |  */ | 
 |  |  | public interface ManageRoleMapper extends BaseMapper<ManageRole> { | 
 |  |  |     List<ManageRole> getManageRoleByAccountId(Integer accountId); | 
 |  |  |  | 
 |  |  |     List<ManageRole> getAll(); | 
 |  |  |  | 
 |  |  |     ManageRole getManageRoleByName(String name); | 
 |  |  |  | 
 |  |  |     ManageRole getManageRoleById(int id); | 
 |  |  |  | 
 |  |  |     void insertOne(ManageRole manageRole); | 
 |  |  |  | 
 |  |  |     void updateManageRoleById(Map map); | 
 |  |  |  | 
 |  |  |     List<ManageRole> getManageRoleByNameFuzzy(ManageRole manageRole); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageRoleMenu; | 
 |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
 |  |  | import org.apache.ibatis.annotations.Param; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |  */ | 
 |  |  | public interface ManageRoleMenuMapper extends BaseMapper<ManageRoleMenu> { | 
 |  |  |  | 
 |  |  |     void insertBatch(@Param("list")List<Map> list); | 
 |  |  |  | 
 |  |  |     void updateDeleteStateByMenu_id(Map map); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageMenu; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |  * @author moral | 
 |  |  |  * @since 2021-03-09 | 
 |  |  |  */ | 
 |  |  | @Transactional | 
 |  |  | public interface ManageMenuService extends IService<ManageMenu> { | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> insertManageMenu(ManageMenu manageMenu); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> updateManageMenu(Map map); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> deleteManageMenu(Map map); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageRole; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |  * @author moral | 
 |  |  |  * @since 2021-03-09 | 
 |  |  |  */ | 
 |  |  | @Transactional | 
 |  |  | public interface ManageRoleService extends IService<ManageRole> { | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     List<ManageRole> getAll(); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> insertOne(ManageRole manageRole,List list); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> updateManageRole(Map map); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     List<ManageRole> getManageRoleByNameFuzzy(ManageRole manageRole); | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     Map<String,Object> deleteManageRole(Map map); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageMenu; | 
 |  |  | import com.moral.api.mapper.ManageMenuMapper; | 
 |  |  | import com.moral.api.mapper.ManageRoleMenuMapper; | 
 |  |  | import com.moral.api.service.ManageMenuService; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  |  | 
 |  |  | import javax.annotation.Resource; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  | @Service | 
 |  |  | public class ManageMenuServiceImpl extends ServiceImpl<ManageMenuMapper, ManageMenu> implements ManageMenuService { | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private ManageMenuMapper manageMenuMapper; | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private ManageRoleMenuMapper manageRoleMenuMapper; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Map<String,Object> insertManageMenu(ManageMenu manageMenu) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (manageMenu.getName()==null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","名称为空!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该菜单已存在!"); | 
 |  |  |         }else { | 
 |  |  |             manageMenuMapper.insertOne(manageMenu); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","添加成功!"); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Map<String,Object> updateManageMenu(Map map) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (!map.containsKey("id")){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","未选择更新目标!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该菜单不存在!"); | 
 |  |  |         }else { | 
 |  |  |             manageMenuMapper.updateManageMenuById(map); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","更新成功!"); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Map<String, Object> deleteManageMenu(Map map) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (!map.containsKey("id")){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","未选择删除目标!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该角色不存在或已被删除!"); | 
 |  |  |         }else { | 
 |  |  |             Map deleteMap = new HashMap(); | 
 |  |  |             int id = Integer.parseInt(map.get("id").toString()); | 
 |  |  |             deleteMap.put("id",id); | 
 |  |  |             deleteMap.put("is_delete",1); | 
 |  |  |             manageMenuMapper.updateManageMenuById(deleteMap); | 
 |  |  |             Map role_menuDeleteMap = new HashMap(); | 
 |  |  |             role_menuDeleteMap.put("menu_id",id); | 
 |  |  |             manageRoleMenuMapper.updateDeleteStateByMenu_id(role_menuDeleteMap); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","删除成功!"); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | package com.moral.api.service.impl; | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.ManageMenu; | 
 |  |  | import com.moral.api.entity.ManageRole; | 
 |  |  | import com.moral.api.mapper.ManageRoleMapper; | 
 |  |  | import com.moral.api.mapper.ManageRoleMenuMapper; | 
 |  |  | import com.moral.api.service.ManageRoleService; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.util.StringUtils; | 
 |  |  |  | 
 |  |  | import javax.annotation.Resource; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * <p> | 
 |  |  | 
 |  |  |             return null; | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private ManageRoleMapper manageRoleMapper; | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private ManageRoleMenuMapper manageRoleMenuMapper; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public List<ManageRole> getAll() { | 
 |  |  |         return manageRoleMapper.getAll(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public Map<String,Object> insertOne(ManageRole manageRole,List list) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (manageRole.getName()==null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","名称为空!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageRoleMapper.getManageRoleByName(manageRole.getName()) != null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该角色已存在!"); | 
 |  |  |         }else { | 
 |  |  |             manageRoleMapper.insertOne(manageRole); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","添加成功!"); | 
 |  |  |         } | 
 |  |  |         boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); | 
 |  |  |         if (flag){ | 
 |  |  |             ManageRole manageRoleIns = manageRoleMapper.getManageRoleByName(manageRole.getName()); | 
 |  |  |             int role_id = manageRoleIns.getId(); | 
 |  |  |             System.out.println(role_id); | 
 |  |  |             List insertList = new ArrayList(); | 
 |  |  |             for (Object temp: list) { | 
 |  |  |                 Map<String,Integer> insertMap = new HashMap<>(); | 
 |  |  |                 insertMap.put("role_id",role_id); | 
 |  |  |                 insertMap.put("menu_id",Integer.parseInt(temp.toString())); | 
 |  |  |                 insertList.add(insertMap); | 
 |  |  |             } | 
 |  |  |             System.out.println(insertList); | 
 |  |  |             manageRoleMenuMapper.insertBatch(insertList); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public Map<String,Object> updateManageRole(Map map) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (!map.containsKey("id")){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","未选择更新目标!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageRoleMapper.getManageRoleById(Integer.parseInt(map.get("id").toString())) == null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该角色不存在!"); | 
 |  |  |         }else { | 
 |  |  |             manageRoleMapper.updateManageRoleById(map); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","更新成功!"); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public List<ManageRole> getManageRoleByNameFuzzy(ManageRole manageRole) { | 
 |  |  |         return manageRoleMapper.getManageRoleByNameFuzzy(manageRole); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Map<String, Object> deleteManageRole(Map map) { | 
 |  |  |         Map<String,Object> resultMap = new HashMap<>(); | 
 |  |  |         if (!map.containsKey("id")){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","未选择删除目标!"); | 
 |  |  |             return resultMap; | 
 |  |  |         } | 
 |  |  |         if (manageRoleMapper.getManageRoleById(Integer.parseInt(map.get("id").toString())) == null){ | 
 |  |  |             resultMap.put("flag",false); | 
 |  |  |             resultMap.put("msg","该角色不存在或已被删除!"); | 
 |  |  |         }else { | 
 |  |  |             ManageRole manageRole = new ManageRole(); | 
 |  |  |             manageRole.setId(Integer.parseInt(map.get("id").toString())); | 
 |  |  |             manageRole.setIsDelete("1"); | 
 |  |  |             Map deleteMap = new HashMap(); | 
 |  |  |             deleteMap.put("id",Integer.parseInt(map.get("id").toString())); | 
 |  |  |             deleteMap.put("is_delete",1); | 
 |  |  |             manageRoleMapper.updateManageRoleById(deleteMap); | 
 |  |  |             resultMap.put("flag",true); | 
 |  |  |             resultMap.put("msg","删除成功!"); | 
 |  |  |         } | 
 |  |  |         return resultMap; | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |                     <result column="is_delete" property="isDelete" /> | 
 |  |  |         </resultMap> | 
 |  |  |  | 
 |  |  |     <update id="updateDeleteStateByRole_id" parameterType="java.util.Map"> | 
 |  |  |         update manage_account_role | 
 |  |  |         set is_delete = 1 | 
 |  |  |         where role_id = #{role_id} | 
 |  |  |     </update> | 
 |  |  |  | 
 |  |  | </mapper> | 
 
 |  |  | 
 |  |  |         mm.`parent_id`=0; | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getManageMenuByName" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_menu | 
 |  |  |         where name = #{name} | 
 |  |  |         and is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getManageMenuById" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_menu | 
 |  |  |         where id = #{id} | 
 |  |  |         and is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <insert id="insertOne" parameterType="java.util.Map"> | 
 |  |  |         INSERT INTO manage_menu | 
 |  |  |         <trim prefix="(" suffix=")" suffixOverrides=","> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 name, | 
 |  |  |             </if> | 
 |  |  |             <if test="url != null"> | 
 |  |  |                 url, | 
 |  |  |             </if> | 
 |  |  |             <if test="icon != null"> | 
 |  |  |                 icon, | 
 |  |  |             </if> | 
 |  |  |             <if test="parent_id != null"> | 
 |  |  |                 parent_id, | 
 |  |  |             </if> | 
 |  |  |             <if test="order != null"> | 
 |  |  |                 `order`, | 
 |  |  |             </if> | 
 |  |  |         </trim> | 
 |  |  |         <trim prefix="values (" suffix=")" suffixOverrides=","> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 #{name}, | 
 |  |  |             </if> | 
 |  |  |             <if test="url != null"> | 
 |  |  |                 #{url}, | 
 |  |  |             </if> | 
 |  |  |             <if test="icon != null"> | 
 |  |  |                 #{icon}, | 
 |  |  |             </if> | 
 |  |  |             <if test="parent_id != null"> | 
 |  |  |                 #{parent_id}, | 
 |  |  |             </if> | 
 |  |  |             <if test="order != null"> | 
 |  |  |                 #{order}, | 
 |  |  |             </if> | 
 |  |  |         </trim> | 
 |  |  |     </insert> | 
 |  |  |  | 
 |  |  |     <update id="updateManageMenuById" parameterType="java.util.Map"> | 
 |  |  |         update manage_menu | 
 |  |  |         <set> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 name = #{name}, | 
 |  |  |             </if> | 
 |  |  |             <if test="url != null"> | 
 |  |  |                 url = #{url}, | 
 |  |  |             </if> | 
 |  |  |             <if test="icon != null"> | 
 |  |  |                 icon = #{icon}, | 
 |  |  |             </if> | 
 |  |  |             <if test="parent_id != null"> | 
 |  |  |                 parent_id = #{parent_id}, | 
 |  |  |             </if> | 
 |  |  |             <if test="order != null"> | 
 |  |  |                 `order` = #{order}, | 
 |  |  |             </if> | 
 |  |  |             <if test="is_delete != null"> | 
 |  |  |                 is_delete = #{is_delete}, | 
 |  |  |             </if> | 
 |  |  |         </set> | 
 |  |  |         where id = #{id} | 
 |  |  |     </update> | 
 |  |  |  | 
 |  |  | </mapper> | 
 
 |  |  | 
 |  |  |         where | 
 |  |  |         mr.is_delete=0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getAll" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_role | 
 |  |  |         where is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getManageRoleByName" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_role | 
 |  |  |         where name = #{name} | 
 |  |  |         and is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getManageRoleById" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_role | 
 |  |  |         where id = #{id} | 
 |  |  |         and is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="getManageRoleByNameFuzzy" resultMap="BaseResultMap"> | 
 |  |  |         select * from manage_role | 
 |  |  |         where name like concat('%',#{name},'%') | 
 |  |  |         and is_delete = 0 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <insert id="insertOne" parameterType="com.moral.api.entity.ManageRole"> | 
 |  |  |         INSERT INTO manage_role | 
 |  |  |         <trim prefix="(" suffix=")" suffixOverrides=","> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 name, | 
 |  |  |             </if> | 
 |  |  |             <if test="desc != null"> | 
 |  |  |                 `desc`, | 
 |  |  |             </if> | 
 |  |  |         </trim> | 
 |  |  |         <trim prefix="values (" suffix=")" suffixOverrides=","> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 #{name}, | 
 |  |  |             </if> | 
 |  |  |             <if test="desc != null"> | 
 |  |  |                 #{desc}, | 
 |  |  |             </if> | 
 |  |  |         </trim> | 
 |  |  |     </insert> | 
 |  |  |  | 
 |  |  |     <update id="updateManageRoleById" parameterType="com.moral.api.entity.ManageRole"> | 
 |  |  |         update manage_role | 
 |  |  |         <set> | 
 |  |  |             <if test="name != null"> | 
 |  |  |                 name = #{name}, | 
 |  |  |             </if> | 
 |  |  |             <if test="desc != null"> | 
 |  |  |                 `desc` = #{desc}, | 
 |  |  |             </if> | 
 |  |  |             <if test="is_delete != null"> | 
 |  |  |                 is_delete = #{is_delete}, | 
 |  |  |             </if> | 
 |  |  |         </set> | 
 |  |  |         where id = #{id} | 
 |  |  |     </update> | 
 |  |  | </mapper> | 
 
 |  |  | 
 |  |  |                     <result column="is_delete" property="isDelete" /> | 
 |  |  |         </resultMap> | 
 |  |  |  | 
 |  |  |     <insert id="insertBatch" parameterType="java.util.List"> | 
 |  |  |         INSERT INTO manage_role_menu(role_id,menu_id) | 
 |  |  |         values | 
 |  |  |         <foreach collection="list" item="item" index="index" separator=","> | 
 |  |  |             (#{item.role_id},#{item.menu_id}) | 
 |  |  |         </foreach> | 
 |  |  |     </insert> | 
 |  |  |  | 
 |  |  |     <update id="updateDeleteStateByMenu_id" parameterType="java.util.Map"> | 
 |  |  |         update manage_role_menu | 
 |  |  |         set is_delete = 1 | 
 |  |  |         where menu_id = #{menu_id} | 
 |  |  |     </update> | 
 |  |  |  | 
 |  |  | </mapper> |