| | |
| | | ACCOUNT_INVALID(-11, "用户名无效"), |
| | | PASSWORD_INVALID(-12, "密码无效"), |
| | | ACCOUNT_IS_EXPIRE(-13, "用户已过期"), |
| | | GROUP_EXIST(-14, "组已存在") |
| | | GROUP_EXIST(-14, "组已存在"), |
| | | ROLE_IS_EXPIRE(-15, "用户名无效"), |
| | | ROLE_IS_NULL(-16, "密码无效"), |
| | | MENU_IS_EXPIRE(-17, "用户已过期"), |
| | | MENU_IS_NULL(-18, "组已存在") |
| | | |
| | | ; |
| | | private final Integer code; |
| | |
| | | import com.moral.api.entity.ManageMenu; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.service.ManageMenuService; |
| | | import com.moral.api.service.ManageRoleMenuService; |
| | | import com.moral.api.service.ManageRoleService; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | |
| | | |
| | | @Autowired |
| | | private ManageRoleService manageRoleService; |
| | | |
| | | @Autowired |
| | | private ManageRoleMenuService manageRoleMenuService; |
| | | |
| | | @ApiOperation(value = "获取所有角色", notes = "获取所有角色") |
| | | @ApiImplicitParams({ |
| | |
| | | List<ManageRole> re = manageRoleService.getManageRoleByNameFuzzy(parameters); |
| | | return ResultMessage.ok(re); |
| | | } |
| | | |
| | | @ApiOperation(value = "更新角色菜单", notes = "更新角色菜单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int") |
| | | }) |
| | | @RequestMapping(value = "updateRoleMenu", method = RequestMethod.GET) |
| | | public ResultMessage updateRoleMenu(HttpServletRequest request) { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | int id = Integer.parseInt(parameters.get("id").toString()); |
| | | List list = new ArrayList(); |
| | | list.add(1); |
| | | list.add(2); |
| | | list.add(3); |
| | | list.add(4); |
| | | Map<String,Object> re = manageRoleMenuService.updateRoleMenu(list,id); |
| | | return ResultMessage.ok(re); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.ManageRoleMenu; |
| | | 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 ManageRoleMenuService extends IService<ManageRoleMenu> { |
| | | |
| | | @Transactional |
| | | Map<String,Object> updateRoleMenu(List list,int id); |
| | | |
| | | } |
| | |
| | | import com.moral.api.mapper.ManageRoleMenuMapper; |
| | | import com.moral.api.service.ManageMenuService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | public Map<String,Object> insertManageMenu(ManageMenu manageMenu) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (manageMenu.getName()==null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","名称为空!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该菜单已存在!"); |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_EXPIRE.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_EXPIRE.getMsg()); |
| | | }else { |
| | | manageMenuMapper.insertOne(manageMenu); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","添加成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | public Map<String,Object> updateManageMenu(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","未选择更新目标!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该菜单不存在!"); |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | }else { |
| | | manageMenuMapper.updateManageMenuById(map); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","更新成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | public Map<String, Object> deleteManageMenu(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","未选择删除目标!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该角色不存在或已被删除!"); |
| | | resultMap.put("code",ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | }else { |
| | | Map deleteMap = new HashMap(); |
| | | int id = Integer.parseInt(map.get("id").toString()); |
| | |
| | | Map role_menuDeleteMap = new HashMap(); |
| | | role_menuDeleteMap.put("menu_id",id); |
| | | manageRoleMenuMapper.updateDeleteStateByMenu_id(role_menuDeleteMap); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","删除成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.ManageRoleMenu; |
| | | import com.moral.api.mapper.ManageRoleMenuMapper; |
| | | import com.moral.api.service.ManageRoleMenuService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class ManageRoleMenuServiceImpl extends ServiceImpl<ManageRoleMenuMapper, ManageRoleMenu> implements ManageRoleMenuService { |
| | | |
| | | @Autowired(required = false) |
| | | private ManageRoleMenuMapper manageRoleMenuMapper; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Map<String, Object> updateRoleMenu(List list, int id) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (list.size()==0){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | QueryWrapper<ManageRoleMenu> wrapper = new QueryWrapper(); |
| | | wrapper.eq("role_id",id); |
| | | System.out.println(manageRoleMenuMapper.selectCount(wrapper)); |
| | | if (manageRoleMenuMapper.selectCount(wrapper)==0){ |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | import com.moral.api.service.ManageRoleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | 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","名称为空!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageRoleMapper.getManageRoleByName(manageRole.getName()) != null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该角色已存在!"); |
| | | resultMap.put("code",ResponseCodeEnum.ROLE_IS_EXPIRE.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.ROLE_IS_EXPIRE.getMsg()); |
| | | }else { |
| | | manageRoleMapper.insertOne(manageRole); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","添加成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); |
| | | if (flag){ |
| | | Integer code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code.equals(ResponseCodeEnum.SUCCESS.getCode())){ |
| | | ManageRole manageRoleIns = manageRoleMapper.getManageRoleByName(manageRole.getName()); |
| | | int role_id = manageRoleIns.getId(); |
| | | System.out.println(role_id); |
| | |
| | | public Map<String,Object> updateManageRole(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","未选择更新目标!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageRoleMapper.getManageRoleById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该角色不存在!"); |
| | | resultMap.put("code",ResponseCodeEnum.ROLE_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.ROLE_IS_NULL.getMsg()); |
| | | }else { |
| | | manageRoleMapper.updateManageRoleById(map); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","更新成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |
| | |
| | | public Map<String, Object> deleteManageRole(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (!map.containsKey("id")){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","未选择删除目标!"); |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (manageRoleMapper.getManageRoleById(Integer.parseInt(map.get("id").toString())) == null){ |
| | | resultMap.put("flag",false); |
| | | resultMap.put("msg","该角色不存在或已被删除!"); |
| | | resultMap.put("code",ResponseCodeEnum.ROLE_IS_NULL.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.ROLE_IS_NULL.getMsg()); |
| | | }else { |
| | | ManageRole manageRole = new ManageRole(); |
| | | manageRole.setId(Integer.parseInt(map.get("id").toString())); |
| | |
| | | QueryWrapper<ManageAccountRole> wrapper = new QueryWrapper(); |
| | | wrapper.eq("role_id",Integer.parseInt(map.get("id").toString())); |
| | | manageAccountRoleMapper.update(manageAccountRole,wrapper); |
| | | resultMap.put("flag",true); |
| | | resultMap.put("msg","删除成功!"); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | | return resultMap; |
| | | } |