Merge remote-tracking branch 'origin/dev' into dev
1 files renamed
3 files deleted
2 files added
36 files modified
| | |
| | | MONITOR_POINT_IS_NOT_EXIST(-40,"站点不存在"), |
| | | VERSION_NOT_EXIST(-41,"版本不存在"), |
| | | VERSION_EXIST(-42,"版本已经存在"), |
| | | MAC_IS_EXIST(-42,"mac已存在") |
| | | MAC_IS_EXIST(-42,"mac已存在"), |
| | | URL_IS_EXIST(-43,"路径已存在"), |
| | | ORGANIZATION_EXIST_MONITORPOINT(-44,"组织存在站点,无法删除"), |
| | | CHILDREN_ORGANIZATION_EXIST_MONITORPOINT(-45,"子组织存在站点,无法删除") |
| | | ; |
| | | private final Integer code; |
| | | private final String msg; |
| | |
| | | return userInfo; |
| | | } |
| | | |
| | | public static Object getUserInfo() { |
| | | String token = getCurrentToken(); |
| | | return getUserInfoByToken(token); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 销毁token |
| | | * @Param: [uid, token] |
| | |
| | | |
| | | |
| | | /** |
| | | * @Description: 销毁当前连接的token0 |
| | | * @Description: 销毁当前连接的token |
| | | * @Param: [] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.pojo.dto.account.*; |
| | | import com.moral.api.pojo.form.account.AccountDeleteForm; |
| | | import com.moral.api.pojo.form.account.AccountInsertForm; |
| | | import com.moral.api.pojo.form.account.AccountQueryForm; |
| | | import com.moral.api.pojo.form.account.AccountUpdateForm; |
| | | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; |
| | | import com.moral.api.pojo.form.account.*; |
| | | import com.moral.api.pojo.form.accountRole.AccountRoleUpdateForm; |
| | | import com.moral.api.pojo.vo.account.AccountQueryVO; |
| | | import com.moral.api.service.ManageAccountRoleService; |
| | | import com.moral.api.service.ManageAccountService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | |
| | | public class AccountController { |
| | | @Autowired |
| | | ManageAccountService accountService; |
| | | @Autowired |
| | | ManageAccountRoleService manageAccountRoleService; |
| | | |
| | | @PostMapping("insert") |
| | | public ResultMessage insert(@RequestBody AccountInsertForm form) { |
| | |
| | | return new ResultMessage(accountQueryDTO.getCode(), accountQueryDTO.getMsg(), accountQueryVO); |
| | | } |
| | | |
| | | @PostMapping("updateRole") |
| | | public ResultMessage updateRole(@RequestBody AccountRoleUpdateForm form){ |
| | | |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | |
| | | //处理更新业务 |
| | | AccountRoleDTO dto = manageAccountRoleService.updateAccountRole(form); |
| | | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), null); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.moral.api.pojo.dto.login.LoginDTO; |
| | | import com.moral.api.pojo.form.login.LoginForm; |
| | | import com.moral.api.pojo.form.login.LogoutForm; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.pojo.vo.login.AccountInfoVO; |
| | | import com.moral.api.pojo.vo.login.LoginVO; |
| | | import com.moral.api.service.ManageAccountService; |
| | | import com.moral.api.service.SysConfigService; |
| | |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.pojo.VerificationCode; |
| | | import com.moral.util.KaptchaUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | return new ResultMessage(loginDTO.getCode(), loginDTO.getMsg(), loginVO); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 获取用户信息接口 |
| | | * @Param: [] |
| | | * @return: com.moral.constant.ResultMessage |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/6/9 |
| | | */ |
| | | @GetMapping("getAccountInfo") |
| | | public ResultMessage getAccountInfo(){ |
| | | AccountInfoDTO dto = (AccountInfoDTO) TokenUtils.getUserInfo(); |
| | | AccountInfoVO vo = AccountInfoVO.convert(dto); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 退出接口 |
| | |
| | | String msg = resultMap.get("msg").toString(); |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | return ResultMessage.ok(code,msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | | return ResultMessage.fail(code,msg); |
| | | } |
| | | |
| | | @ApiOperation(value = "更新菜单", notes = "更新菜单") |
| | |
| | | String msg = resultMap.get("msg").toString(); |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | return ResultMessage.ok(code,msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | | return ResultMessage.fail(code,msg); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除菜单", notes = "删除菜单") |
| | |
| | | String msg = resultMap.get("msg").toString(); |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | return ResultMessage.ok(code,msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | | return ResultMessage.fail(code,msg); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有菜单", notes = "查询所有菜单") |
| | |
| | | public ResultMessage getManageMenuByNameFuzzy(HttpServletRequest request) { |
| | | Map<String,Object> parameters = getParametersStartingWith(request,null); |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if (parameters.get("name") == null || parameters.get("current") == null || parameters.get("size") == null){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return ResultMessage.fail(resultMap); |
| | | } |
| | | if (Integer.parseInt(parameters.get("current").toString())<1 || Integer.parseInt(parameters.get("size").toString())<1){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_NOT_REQUIREMENT.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_NOT_REQUIREMENT.getMsg()); |
| | | return ResultMessage.fail(resultMap); |
| | | } |
| | | List<Map<String,Object>> re = manageMenuService.getManageMenuByNameFuzzy(parameters); |
| | | Map<String,Object> re = manageMenuService.getManageMenuByCondition(parameters); |
| | | return ResultMessage.ok(re); |
| | | } |
| | | |
| | |
| | | List<ManageMenu> result = manageMenuService.getManageChildMenuByRoleId(Integer.parseInt(parameters.get("roleId").toString())); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有父菜单", notes = "查询所有父菜单") |
| | | @RequestMapping(value = "getManageParentMenu", method = RequestMethod.GET) |
| | | public ResultMessage getManageParentMenu(HttpServletRequest request) { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | Map<String,Object> result = manageMenuService.getManageParentMenu(parameters); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.service.ManageRoleMenuService; |
| | | import com.moral.api.service.ManageRoleService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | //处理插入业务 |
| | | MenuDTO dto = menuService.insertMenu(form); |
| | | |
| | | //转换前端所需参数 |
| | | MenuInsertVO vo = MenuInsertVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(),null); |
| | | } |
| | | |
| | | @PostMapping("delete") |
| | |
| | | import com.moral.api.pojo.form.sysDictType.SysDictTypeDeleteForm; |
| | | import com.moral.api.pojo.form.sysDictType.SysDictTypeInsertForm; |
| | | import com.moral.api.pojo.form.sysDictType.SysDictTypeUpdateForm; |
| | | import com.moral.api.pojo.vo.sysDictType.SysDictTypeDeleteVO; |
| | | import com.moral.api.pojo.vo.sysDictType.SysDictTypeInsertVO; |
| | | import com.moral.api.pojo.vo.sysDictType.SysDictTypeQueryVO; |
| | | import com.moral.api.pojo.vo.sysDictType.SysDictTypeUpdateVO; |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | |
| | | //处理更新业务 |
| | | SysDictTypeDTO dto = sysDictTypeService.updateType(form); |
| | | |
| | | //转换前端所需参数 |
| | | SysDictTypeUpdateVO vo = SysDictTypeUpdateVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), null); |
| | | } |
| | | |
| | | @PostMapping("type/delete") |
| | |
| | | //处理删除业务 |
| | | SysDictTypeDTO dto = sysDictTypeService.deleteType(form); |
| | | |
| | | //转换前端所需参数 |
| | | SysDictTypeDeleteVO vo = SysDictTypeDeleteVO.convert(dto); |
| | | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(),null); |
| | | } |
| | | |
| | | } |
| | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), null); |
| | | } |
| | | |
| | | @PostMapping("delete") |
| | | public ResultMessage delete(@RequestBody UserDeleteForm form){ |
| | | |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | |
| | | //处理删除业务 |
| | | UserDTO dto = userService.deleteUser(form); |
| | | |
| | | return new ResultMessage(dto.getCode(), dto.getMsg(), null); |
| | | } |
| | | |
| | | @PostMapping("insert") |
| | | public ResultMessage insert(@RequestBody UserInsertForm form){ |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | |
| | | /** |
| | | * 同一级别菜单的顺序 |
| | | */ |
| | | @TableField(value = "`order`") |
| | | private Integer order; |
| | | |
| | | /** |
| | |
| | | |
| | | List<ManageMenu> getManageRoleByNameFuzzy(Map map); |
| | | |
| | | List<ManageMenu> getManageMenuByNameFuzzy(Map map); |
| | | |
| | | List<ManageMenu> getManageMenuByCondition(Map map); |
| | | |
| | | List<ManageMenu> getManageMenuByRoleId(int roleId); |
New file |
| | |
| | | package com.moral.api.pojo.dto.accountRole; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @ClassName AccountRoleDTO |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/6/9 8:56 |
| | | * @Version TODO |
| | | **/ |
| | | @Data |
| | | public class AccountRoleDTO { |
| | | |
| | | private Integer code; |
| | | |
| | | private String msg; |
| | | |
| | | } |
| | |
| | | package com.moral.api.pojo.dto.login; |
| | | |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | |
| | | private String wechat; |
| | | |
| | | private List<Integer> roleIds; |
| | | |
| | | public boolean valid() { |
| | | if (ObjectUtils.isEmpty(accountId)) |
| | |
| | | ObjectUtils.isEmpty(password) && |
| | | ObjectUtils.isEmpty(email) && |
| | | ObjectUtils.isEmpty(mobile) && |
| | | ObjectUtils.isEmpty(wechat) && |
| | | null == roleIds |
| | | ObjectUtils.isEmpty(wechat) |
| | | ) |
| | | return false; |
| | | return true; |
New file |
| | |
| | | package com.moral.api.pojo.form.accountRole; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @ClassName AccountUpdateRoleForm |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/6/9 8:51 |
| | | * @Version TODO |
| | | **/ |
| | | @Data |
| | | public class AccountRoleUpdateForm { |
| | | |
| | | private Integer accountId; |
| | | |
| | | private Integer roleId; |
| | | |
| | | public boolean valid(){ |
| | | if(accountId==null) |
| | | return false; |
| | | return true; |
| | | } |
| | | } |
| | |
| | | |
| | | private String wechat; |
| | | |
| | | private String userName; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date expireTime; |
| | |
| | | public User formConvertEntity(){ |
| | | User user = new User(); |
| | | user.setId(id); |
| | | user.setUserName(userName); |
| | | if (!ObjectUtils.isEmpty(password)) |
| | | user.setPassword(MD5Utils.saltMD5(AESUtils.decrypt(password))); |
| | | user.setEmail(email); |
File was renamed from screen-manage/src/main/java/com/moral/api/pojo/dto/login/AccountInfoDTO.java |
| | |
| | | package com.moral.api.pojo.dto.login; |
| | | package com.moral.api.pojo.redisBean; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.moral.api.entity.ManageAccount; |
| | |
| | | |
| | | /** |
| | | * @ClassName AccountInfoDto |
| | | * @Description TODO |
| | | * @Description 用户信息redis中的实体 |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/3/12 13:51 |
| | | * @Version TODO |
| | |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.ManageMenu; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @ClassName AccountInfoVO |
| | |
| | | removeAttribute(menu); |
| | | } |
| | | } |
| | | //menu进行排序 |
| | | if (!ObjectUtils.isEmpty(menus)) { |
| | | orderRootMenu(menus); |
| | | } |
| | | vo.setAccountId(account.getId()); |
| | | vo.setUserName(account.getUserName()); |
| | | vo.setMenus(menus); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 对根菜单进行排序 |
| | | * @Param: [menus] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/6/8 |
| | | */ |
| | | public static void orderRootMenu(List<ManageMenu> menus){ |
| | | menus.sort(Comparator.comparing(ManageMenu::getOrder)); |
| | | for (ManageMenu menu : menus) { |
| | | orderMenu(menu); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @Description: 对非根菜单进行排序 |
| | | * @Param: [menu] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/6/8 |
| | | */ |
| | | public static void orderMenu(ManageMenu menu){ |
| | | List<ManageMenu> children = menu.getChildren(); |
| | | if(!ObjectUtils.isEmpty(children)){ |
| | | children.sort(Comparator.comparing(ManageMenu::getOrder)); |
| | | for (ManageMenu child : children) { |
| | | orderMenu(child); |
| | | } |
| | | }else{ |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.moral.api.pojo.vo.login; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.pojo.dto.login.LoginDTO; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | /** |
| | | * @ClassName LoginVo |
| | |
| | | * */ |
| | | private String token; |
| | | |
| | | /* |
| | | * 用户基本信息 |
| | | * */ |
| | | private AccountInfoVO accountInfoVO; |
| | | |
| | | /** |
| | | * @Description: DTO转换VO |
| | | * @Param: [dto] |
| | |
| | | return null; |
| | | |
| | | LoginVO vo = new LoginVO(); |
| | | String token = dto.getToken(); |
| | | AccountInfoDTO accountInfoDTO = dto.getAccountInfoDTO(); |
| | | AccountInfoVO accountInfoVO = AccountInfoVO.convert(accountInfoDTO); |
| | | vo.setAccountInfoVO(accountInfoVO); |
| | | vo.setToken(token); |
| | | vo.setToken(dto.getToken()); |
| | | return vo; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.ManageAccountRole; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; |
| | | import com.moral.api.pojo.form.accountRole.AccountRoleUpdateForm; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface ManageAccountRoleService extends IService<ManageAccountRole> { |
| | | |
| | | /** |
| | | * @Description: 更新账号角色 |
| | | * @Param: [form] |
| | | * @return: com.moral.api.pojo.dto.accountRole.AccountRoleDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/6/9 |
| | | */ |
| | | AccountRoleDTO updateAccountRole(AccountRoleUpdateForm form); |
| | | |
| | | } |
| | |
| | | |
| | | List<Map<String,Object>> getManageMenuByNameFuzzy(Map map); |
| | | |
| | | Map<String,Object> getManageMenuByCondition(Map map); |
| | | |
| | | Map<String,Object> getManageParentMenu(Map map); |
| | | |
| | | List<Map<String,Object>> getManageMenuByParentId(Map map); |
| | | |
| | | List<ManageMenu> getParentChildrenMenusByRoles(List<ManageRole> roles); |
| | |
| | | |
| | | @Transactional |
| | | Map<String,Object> deleteManageRole(Map map); |
| | | |
| | | ManageRole getRoleByAccountId(Integer accountId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | Map<String,Object> getMonitorPointByFuzzy(Map map); |
| | | |
| | | List<MonitorPoint> getMonitorPointsByOrganizationId(Integer organizationId); |
| | | |
| | | } |
| | |
| | | UserDTO updateUser(UserUpdateForm form); |
| | | |
| | | /** |
| | | * @Description: 删除组织的admin用户 |
| | | * @Param: [form] |
| | | * @return: com.moral.api.pojo.dto.user.UserDTO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/5/20 |
| | | */ |
| | | UserDTO deleteUser(UserDeleteForm form); |
| | | |
| | | /** |
| | | * @Description: 插入组织的admin用户 |
| | | * @Param: [form] |
| | | * @return: com.moral.api.pojo.dto.user.UserDTO |
| | |
| | | deviceMapper.insert(device); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId()); |
| | | //新增设备信息存入redis |
| | | RedisUtil.del("device_" + device.getMac()); |
| | | RedisUtil.set("device_" + device.getMac(), deviceInfo); |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | |
| | | deviceInfo.put("createTime", DateUtils.dateToDateString(device.getCreateTime())); |
| | | deviceInfo.put("installTime", device.getInstallTime() == null ? null : DateUtils.dateToDateString(device.getInstallTime())); |
| | | |
| | | //扩展字段 |
| | | deviceInfo.put("extend", device.getExtend()); |
| | | |
| | | //行业 |
| | | deviceInfo.put("profession", device.getProfession()); |
| | | deviceInfo.put("professionName", device.getProfessionName()); |
| | |
| | | mpInfo.put("id", monitorPoint.getId()); |
| | | mpInfo.put("name", monitorPoint.getName()); |
| | | deviceInfo.put("monitorPoint", mpInfo); |
| | | |
| | | RedisUtil.set("device_" + mac, deviceInfo); |
| | | return deviceInfo; |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.ManageAccountRole; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.mapper.ManageAccountMapper; |
| | | import com.moral.api.mapper.ManageAccountRoleMapper; |
| | | import com.moral.api.mapper.ManageRoleMapper; |
| | | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; |
| | | import com.moral.api.pojo.form.accountRole.AccountRoleUpdateForm; |
| | | import com.moral.api.service.ManageAccountRoleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.ManageAccountService; |
| | | import com.moral.api.service.ManageRoleService; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.management.relation.Role; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class ManageAccountRoleServiceImpl extends ServiceImpl<ManageAccountRoleMapper, ManageAccountRole> implements ManageAccountRoleService { |
| | | |
| | | @Autowired |
| | | ManageAccountRoleMapper manageAccountRoleMapper; |
| | | @Autowired |
| | | ManageRoleMapper manageRoleMapper; |
| | | @Autowired |
| | | ManageRoleService manageRoleService; |
| | | @Autowired |
| | | ManageAccountMapper manageAccountMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AccountRoleDTO updateAccountRole(AccountRoleUpdateForm form) { |
| | | //创建返回对象 |
| | | AccountRoleDTO dto = new AccountRoleDTO(); |
| | | //取参 |
| | | Integer accountId = form.getAccountId(); |
| | | Integer roleId = form.getRoleId(); |
| | | //查询要更新的账号用于日志插入 |
| | | ManageAccount account = manageAccountMapper.selectById(accountId); |
| | | //查询要更新的角色用于日志插入 |
| | | ManageRole updateRole = null; |
| | | if (!ObjectUtils.isEmpty(roleId)) { |
| | | QueryWrapper<ManageRole> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | queryWrapper.eq("id", roleId); |
| | | updateRole = manageRoleMapper.selectOne(queryWrapper); |
| | | } |
| | | //查询原有角色用于插入日志 |
| | | ManageRole oldRole = manageRoleService.getRoleByAccountId(accountId); |
| | | //先删除原有角色再进行分配 |
| | | UpdateWrapper updateWrapper = new UpdateWrapper(); |
| | | updateWrapper.set("is_delete", Constants.DELETE); |
| | | updateWrapper.eq("account_id", accountId); |
| | | manageAccountRoleMapper.update(null, updateWrapper); |
| | | if (!ObjectUtils.isEmpty(roleId)) { |
| | | ManageAccountRole role = new ManageAccountRole(); |
| | | role.setAccountId(accountId); |
| | | role.setRoleId(roleId); |
| | | manageAccountRoleMapper.insert(role); |
| | | } |
| | | //插入日志 |
| | | insertUpdateLog(oldRole,updateRole,account); |
| | | //封装返回参数 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return dto; |
| | | } |
| | | |
| | | private void insertUpdateLog(ManageRole oldRole, ManageRole updateRole, ManageAccount account) { |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("修改了用户:").append(account.getUserName() + ";") |
| | | .append("账号:" + account.getAccount() + ";") |
| | | .append("角色:"); |
| | | |
| | | if(ObjectUtils.isEmpty(oldRole)) |
| | | content.append("空->"); |
| | | else |
| | | content.append(oldRole.getName()+"->"); |
| | | |
| | | if(ObjectUtils.isEmpty(updateRole)) |
| | | content.append("空;"); |
| | | else |
| | | content.append(updateRole.getName()+";"); |
| | | |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.mapper.ManageAccountMapper; |
| | | import com.moral.api.mapper.ManageAccountRoleMapper; |
| | | import com.moral.api.mapper.ManageMenuMapper; |
| | | import com.moral.api.mapper.ManageRoleMapper; |
| | | import com.moral.api.pojo.dto.account.*; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.pojo.dto.login.LoginDTO; |
| | | import com.moral.api.pojo.form.account.AccountDeleteForm; |
| | | import com.moral.api.pojo.form.account.AccountInsertForm; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | //查询是否存在 |
| | | QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("account", account); |
| | | List<ManageAccount> manageAccounts = manageAccountMapper.selectList(wrapper); |
| | | if (ObjectUtils.isEmpty(manageAccounts)) { |
| | | loginDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); |
| | | loginDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | return loginDTO; |
| | | } |
| | | //查询是否逻辑删除 |
| | | ManageAccount manageAccount = null; |
| | | for (ManageAccount value : manageAccounts) { |
| | | if (Constants.NOT_DELETE.equals(value.getIsDelete())) |
| | | manageAccount = value; |
| | | } |
| | | |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | ManageAccount manageAccount = manageAccountMapper.selectOne(wrapper); |
| | | if (ObjectUtils.isEmpty(manageAccount)) { |
| | | loginDTO.setCode(ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode()); |
| | | loginDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); |
| | | loginDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | return loginDTO; |
| | | } |
| | |
| | | List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId()); |
| | | |
| | | //查询菜单 |
| | | List<ManageMenu> menus = null; |
| | | List<ManageMenu> menus = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | menus = manageMenuService.getParentChildrenMenusByRoles(roles); |
| | | } |
| | |
| | | //封装返回结果 |
| | | loginDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | loginDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | loginDTO.setAccountInfoDTO(accountInfoDTO); |
| | | loginDTO.setToken(token); |
| | | |
| | | //登陆插入日志 |
| | |
| | | |
| | | //查询结果 |
| | | Page resultPage = manageAccountMapper.selectPage(queryPage, wrapper); |
| | | |
| | | //查询用户对应的角色 |
| | | List<ManageAccount> accounts = resultPage.getRecords(); |
| | | //过滤系统最高权限账号admin,除admin角色外无法查看 |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfo(); |
| | | List<ManageRole> ownRoles = accountInfoDTO.getRoles(); |
| | | boolean ownAdminRole = false; |
| | | for (ManageRole ownRole : ownRoles) { |
| | | String roleName = ownRole.getName(); |
| | | if ("admin".equals(roleName)) |
| | | ownAdminRole = true; |
| | | } |
| | | if (!ownAdminRole) { |
| | | accounts.removeIf(new Predicate<ManageAccount>() { |
| | | @Override |
| | | public boolean test(ManageAccount manageAccount) { |
| | | if (manageAccount.getAccount().equals("admin")) |
| | | return true; |
| | | return false; |
| | | } |
| | | }); |
| | | } |
| | | //查询用户对应的角色 |
| | | List<AccountDTO> accountDTOS = new ArrayList<>(); |
| | | for (ManageAccount manageAccount : accounts) { |
| | | AccountDTO accountDTO = new AccountDTO(); |
| | |
| | | AccountDTO accountDTO = new AccountDTO(); |
| | | //取参 |
| | | ManageAccount manageAccount = accountUpdateForm.formConvertEntity(); |
| | | List<Integer> roleIds = accountUpdateForm.getRoleIds(); |
| | | |
| | | //查找要更新的用户用于插入日志 |
| | | QueryWrapper<ManageAccount> oldAccountWrapper = new QueryWrapper<>(); |
| | |
| | | } |
| | | |
| | | //更新ManageAccount表 |
| | | Map manageAccountMap = JSONObject.parseObject(JSON.toJSONString(manageAccount), Map.class);//转换为Map判断属性是否有更新 |
| | | if (manageAccountMap.size() > 1) {//判断如果没有除了id以外的任何属性则不更新 |
| | | manageAccountMapper.updateById(manageAccount); |
| | | } |
| | | manageAccountMapper.updateById(manageAccount); |
| | | |
| | | //获取账号更新前的角色 |
| | | List<ManageRole> oldRoles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId()); |
| | | |
| | | //如果角色有变动,则更新ManageAccountRole表 |
| | | /* |
| | | * 如果roleIds为null,则是该账号角色没有发生改变 |
| | | * 如果roleIds为空,则是该账号所有的角色都被移除 |
| | | * 如果roleIds有元素,则是该账号的角色有更新 |
| | | * */ |
| | | if (roleIds != null) { |
| | | //删除原有角色 |
| | | UpdateWrapper<ManageAccountRole> deleteWrapper = new UpdateWrapper<>(); |
| | | deleteWrapper.eq("account_id", manageAccount.getId()).set("is_delete", Constants.DELETE); |
| | | manageAccountRoleMapper.update(null, deleteWrapper); |
| | | /*重新添加角色*/ |
| | | for (Integer roleId : roleIds) { |
| | | ManageAccountRole manageAccountRole = new ManageAccountRole(); |
| | | manageAccountRole.setAccountId(manageAccount.getId()); |
| | | manageAccountRole.setRoleId(roleId); |
| | | manageAccountRoleMapper.insert(manageAccountRole); |
| | | } |
| | | } |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount); |
| | | //销毁token |
| | | TokenUtils.destoryToken(manageAccount.getId()); |
| | | //封装返回结果 |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles); |
| | | return accountDTO; |
| | | } |
| | | |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/8 |
| | | */ |
| | | private void insertUpdateLog(AccountUpdateForm updateForm, ManageAccount oldAccount, List<ManageRole> oldRoles) { |
| | | private void insertUpdateLog(AccountUpdateForm updateForm, ManageAccount oldAccount) { |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | |
| | | if ("password".equals(key)) {//密码特殊处理,不显示在日志上 |
| | | if (!ObjectUtils.isEmpty(updateForm.getPassword())) {//判断密码是否进行了更新 |
| | | content.append("修改了密码;"); |
| | | } |
| | | } else if ("roleIds".equals(key)) {//角色特殊处理,将Id转化为角色名称 |
| | | List<Integer> newRoleIds = updateForm.getRoleIds(); |
| | | |
| | | if (newRoleIds != null && 0 == newRoleIds.size()) {//如果新的角色集合为空,则是删除了所有的角色 |
| | | content.append("角色:删除了所有角色;"); |
| | | } |
| | | if ((newRoleIds != null) && (newRoleIds.size() != 0)) {//如果新的角色集合不为空,且不为null,则角色进行了更新 |
| | | StringBuilder oldRolesName = new StringBuilder("空"); |
| | | StringBuilder newRolesName = new StringBuilder("空"); |
| | | |
| | | List<ManageRole> newRoles = null; |
| | | if (!ObjectUtils.isEmpty(updateForm.getRoleIds())) { |
| | | newRoles = manageRoleMapper.selectBatchIds(updateForm.getRoleIds()); |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(oldRoles)) { |
| | | oldRolesName.deleteCharAt(oldRolesName.length() - 1);//删除 "空" |
| | | oldRolesName.append("["); |
| | | for (ManageRole role : oldRoles) { |
| | | oldRolesName.append(role.getName() + ","); |
| | | } |
| | | oldRolesName.deleteCharAt(oldRolesName.length() - 1);//移除最后一个逗号 |
| | | oldRolesName.append("]"); |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(newRoles)) { |
| | | newRolesName.deleteCharAt(newRolesName.length() - 1);//删除 "空" |
| | | newRolesName.append("["); |
| | | for (ManageRole role : newRoles) { |
| | | newRolesName.append(role.getName() + ","); |
| | | } |
| | | newRolesName.deleteCharAt(newRolesName.length() - 1);//移除最后一个逗号 |
| | | newRolesName.append("]"); |
| | | } |
| | | //拼接完整content |
| | | content.append(value + ":" + oldRolesName + "->" + newRolesName + ";"); |
| | | } |
| | | } else {//其他属性处理 |
| | | if (newParameters.get(key) != null) { |
| | |
| | | if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_EXIST.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_EXIST.getMsg()); |
| | | } else { |
| | | manageMenuMapper.insertOne(manageMenu); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加菜单:"+manageMenu.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | | } |
| | | QueryWrapper<ManageMenu> wrapper_url = new QueryWrapper(); |
| | | wrapper_url.eq("url",manageMenu.getUrl()); |
| | | wrapper_url.eq("is_delete",Constants.NOT_DELETE); |
| | | if (manageMenuMapper.selectCount(wrapper_url) != 0) { |
| | | resultMap.put("code", ResponseCodeEnum.URL_IS_EXIST.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.URL_IS_EXIST.getMsg()); |
| | | return resultMap; |
| | | } |
| | | manageMenuMapper.insertOne(manageMenu); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加菜单:"+manageMenu.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | | } |
| | | |
| | |
| | | if (manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())) == null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_NULL.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_NULL.getMsg()); |
| | | } else { |
| | | //更新之前获取原来的菜单信息 |
| | | ManageMenu manageMenuOld = manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())); |
| | | manageMenuMapper.updateManageMenuById(map); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "修改了菜单:"+manageMenuOld.getName()+";"; |
| | | for (Object key:map.keySet()) { |
| | | if (key.toString().equals("name")&&map.get(key)!=null){ |
| | | content = content+"菜单名:"+manageMenuOld.getName()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("url")&&map.get(key)!=null){ |
| | | content = content+"url地址:"+manageMenuOld.getUrl()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("icon")&&map.get(key)!=null){ |
| | | content = content+"图标地址:"+manageMenuOld.getIcon()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("parent_id")&&map.get(key)!=null){ |
| | | return resultMap; |
| | | } |
| | | if (map.get("name")!=null && manageMenuMapper.getManageMenuByName(map.get("name").toString()) != null) { |
| | | resultMap.put("code", ResponseCodeEnum.MENU_IS_EXIST.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.MENU_IS_EXIST.getMsg()); |
| | | return resultMap; |
| | | } |
| | | QueryWrapper<ManageMenu> wrapper_url = new QueryWrapper(); |
| | | wrapper_url.eq("url",map.get("url")); |
| | | wrapper_url.eq("is_delete",Constants.NOT_DELETE); |
| | | if (manageMenuMapper.selectCount(wrapper_url) != 0) { |
| | | resultMap.put("code", ResponseCodeEnum.URL_IS_EXIST.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.URL_IS_EXIST.getMsg()); |
| | | return resultMap; |
| | | } |
| | | //更新之前获取原来的菜单信息 |
| | | ManageMenu manageMenuOld = manageMenuMapper.getManageMenuById(Integer.parseInt(map.get("id").toString())); |
| | | manageMenuMapper.updateManageMenuById(map); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "修改了菜单:"+manageMenuOld.getName()+";"; |
| | | for (Object key:map.keySet()) { |
| | | if (key.toString().equals("name")&&map.get(key)!=null){ |
| | | content = content+"菜单名:"+manageMenuOld.getName()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("url")&&map.get(key)!=null){ |
| | | content = content+"url地址:"+manageMenuOld.getUrl()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("icon")&&map.get(key)!=null){ |
| | | content = content+"图标地址:"+manageMenuOld.getIcon()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("parent_id")&&map.get(key)!=null){ |
| | | if (map.get(key).toString().equals("0")){ |
| | | content = content+"父菜单:"+manageMenuMapper.getManageMenuById(manageMenuOld.getId()).getName()+"->0"+";"; |
| | | }else if (manageMenuOld.getId().toString().equals("0")){ |
| | | content = content+"父菜单:"+"0->"+manageMenuMapper.getManageMenuById(Integer.parseInt(map.get(key).toString())).getName()+";"; |
| | | }else { |
| | | content = content+"父菜单:"+manageMenuMapper.getManageMenuById(manageMenuOld.getId()).getName()+"->"+manageMenuMapper.getManageMenuById(Integer.parseInt(map.get(key).toString())).getName()+";"; |
| | | } |
| | | if (key.toString().equals("order")&&map.get(key)!=null){ |
| | | content = content+"同一级别菜单顺序:"+manageMenuOld.getOrder()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("desc")&&map.get(key)!=null){ |
| | | content = content+"描述:"+manageMenuOld.getDesc()+"->"+map.get(key)+";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | if (key.toString().equals("order")&&map.get(key)!=null){ |
| | | content = content+"同一级别菜单顺序:"+manageMenuOld.getOrder()+"->"+map.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("desc")&&map.get(key)!=null){ |
| | | content = content+"描述:"+manageMenuOld.getDesc()+"->"+map.get(key)+";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<Map<String,Object>> getManageMenuByNameFuzzy(Map map) { |
| | | Map limitMap = new HashMap(); |
| | | limitMap.put("name", map.get("name")); |
| | | if(!ObjectUtils.isEmpty(map.get("name"))){ |
| | | limitMap.put("name", map.get("name")); |
| | | } |
| | | if(!ObjectUtils.isEmpty(map.get("parent_id"))){ |
| | | limitMap.put("parent_id", map.get("parent_id")); |
| | | } |
| | | limitMap.put("start", (Integer.parseInt(map.get("current").toString()) - 1) * Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number", Integer.parseInt(map.get("size").toString())); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.getManageRoleByNameFuzzy(limitMap); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.getManageMenuByNameFuzzy(limitMap); |
| | | SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | List<Map<String,Object>> resultList = new ArrayList<>(); |
| | | for (ManageMenu manageMenu:manageMenus) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getManageMenuByCondition(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | int current = Integer.parseInt(map.get("current").toString()); |
| | | int size = Integer.parseInt(map.get("size").toString()); |
| | | Page<ManageMenu> page = new Page<>(current,size); |
| | | QueryWrapper<ManageMenu> wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | if(!ObjectUtils.isEmpty(map.get("name"))){ |
| | | wrapper.like("name", map.get("name")); |
| | | } |
| | | if(!ObjectUtils.isEmpty(map.get("parent_id"))){ |
| | | wrapper.eq("parent_id", map.get("parent_id")); |
| | | } |
| | | Page resultpage = manageMenuMapper.selectPage(page,wrapper); |
| | | List<ManageMenu> manageMenus = resultpage.getRecords(); |
| | | SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | List<Map<String,Object>> manageMenuList = new ArrayList<>(); |
| | | for (ManageMenu manageMenu:manageMenus) { |
| | | Map manegeMenuMap = JSON.parseObject(JSON.toJSONString(manageMenu)); |
| | | if (manageMenu.getParentId().equals(0)){ |
| | | manegeMenuMap.put("parent_name",""); |
| | | }else { |
| | | ManageMenu parentMenu = manageMenuMapper.getManageMenuById(manageMenu.getParentId()); |
| | | if (ObjectUtils.isEmpty(parentMenu)){ |
| | | manegeMenuMap.put("parent_name",""); |
| | | }else { |
| | | String parent_name = parentMenu.getName(); |
| | | manegeMenuMap.put("parent_name",parent_name); |
| | | } |
| | | } |
| | | String createTime = SDF.format(manageMenu.getCreateTime()); |
| | | String updateTime = SDF.format(manageMenu.getUpdateTime()); |
| | | manegeMenuMap.put("createTime",createTime); |
| | | manegeMenuMap.put("updateTime",updateTime); |
| | | manageMenuList.add(manegeMenuMap); |
| | | } |
| | | resultMap.put("manageMenus",manageMenuList); |
| | | int totalNumber = manageMenuMapper.selectCount(wrapper); |
| | | resultMap.put("totalNumber",totalNumber); |
| | | resultMap.put("current",current); |
| | | resultMap.put("size",size); |
| | | int totalPageNumber = totalNumber/size; |
| | | if(totalNumber%size != 0){ |
| | | totalPageNumber += 1; |
| | | } |
| | | resultMap.put("totalPageNumber",totalPageNumber); |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getManageParentMenu(Map map) { |
| | | Map<String,Object> resultMap = new HashMap(); |
| | | QueryWrapper<ManageMenu> wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | wrapper.eq("parent_id",0); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.selectList(wrapper); |
| | | resultMap.put("manageMenus",manageMenus); |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getManageMenuByParentId(Map map) { |
| | | Map limitMap = new HashMap(); |
| | | limitMap.put("parent_id", map.get("parent_id")); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.*; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.service.ManageRoleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.LogUtils; |
| | | 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; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | |
| | | QueryWrapper<ManageRole> wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete",0); |
| | | wrapper.like("name",map.get("name")); |
| | | wrapper.orderByDesc("create_time"); |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page resultpage = manageRoleMapper.selectPage(page,wrapper); |
| | | List<ManageRole> manageRoles = resultpage.getRecords(); |
| | | SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | public ManageRole getRoleByAccountId(Integer accountId) { |
| | | QueryWrapper<ManageAccountRole> queryAccountRoleWrapper = new QueryWrapper<>(); |
| | | queryAccountRoleWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | queryAccountRoleWrapper.eq("account_id",accountId); |
| | | ManageAccountRole accountRole = manageAccountRoleMapper.selectOne(queryAccountRoleWrapper); |
| | | if(ObjectUtils.isEmpty(accountRole)) |
| | | return null; |
| | | Integer roleId = accountRole.getRoleId(); |
| | | QueryWrapper<ManageRole> queryRoleWrapper = new QueryWrapper(); |
| | | queryRoleWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | queryRoleWrapper.eq("id", roleId); |
| | | return manageRoleMapper.selectOne(queryRoleWrapper); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 补充父菜单 |
| | | * @Param: [list, menuId]list:menuId集合 |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.sun.corba.se.spi.presentation.rmi.IDLNameTranslator; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | GroupService groupService; |
| | | @Autowired |
| | | GroupMenuMapper groupMenuMapper; |
| | | |
| | | |
| | | @Override |
| | | public MenuQueryDTO queryAllMenus() { |
| | |
| | | dto.setMsg(ResponseCodeEnum.ORGANIZATION_USER_NOT_EXIST.getMsg()); |
| | | return dto; |
| | | } |
| | | //根据角色查询对应的所有菜单 |
| | | List<Menu> allMenus = menuMapper.getMenusByGroupId(group.getId()); |
| | | //将菜单转换为父子结构 |
| | | combinationParentChildrenMenus(allMenus); |
| | | //删除所有菜单只保留最底层菜单 |
| | | List<Menu> menus = new ArrayList<>(); |
| | | for (Menu menu : allMenus) { |
| | | getNotParentMenu(menu, menus); |
| | | } |
| | | //根据角色查询拥有的所有菜单 |
| | | List<Menu> ownMenus = menuMapper.getMenusByGroupId(group.getId()); |
| | | |
| | | /*判断每个菜单是否有子菜单,如果有则不传递 |
| | | * 前端无法解决父菜单选中,子菜单没有全部选中回显问题。由后端处理的代码。*/ |
| | | removeMenuWithChildren(ownMenus); |
| | | |
| | | //封装返回结果 |
| | | List<MenuDTO> dtos = new ArrayList<>(); |
| | | for (Menu menu : menus) { |
| | | for (Menu menu : ownMenus) { |
| | | MenuDTO menuDTO = new MenuDTO(); |
| | | menuDTO.setMenu(menu); |
| | | dtos.add(menuDTO); |
| | |
| | | UpdateWrapper deleteGroupMenuWrapper = new UpdateWrapper(); |
| | | List<Integer> allMenuIds = new ArrayList<>(); |
| | | allMenuIds.add(id); |
| | | allMenuIds.addAll(childrenIds); |
| | | deleteGroupMenuWrapper.in("menu_id",allMenuIds); |
| | | deleteGroupMenuWrapper.set("is_delete",Constants.DELETE); |
| | | groupMenuMapper.update(null,deleteGroupMenuWrapper); |
| | | if (!ObjectUtils.isEmpty(childrenIds)) { |
| | | allMenuIds.addAll(childrenIds); |
| | | } |
| | | deleteGroupMenuWrapper.in("menu_id", allMenuIds); |
| | | deleteGroupMenuWrapper.set("is_delete", Constants.DELETE); |
| | | groupMenuMapper.update(null, deleteGroupMenuWrapper); |
| | | //封装返回对象 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | |
| | | |
| | | /** |
| | | * @Description: 将传来的菜单集合封装成父子结构的集合 |
| | | * @Param: [menus] |
| | | * @return: java.util.List<com.moral.api.entity.Menu> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/5/13 |
| | | */ |
| | | public void combinationParentChildrenMenus(List<Menu> menus){ |
| | | * @Description: 将传来的菜单集合封装成父子结构的集合 |
| | | * @Param: [menus] |
| | | * @return: java.util.List<com.moral.api.entity.Menu> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/5/13 |
| | | */ |
| | | public void combinationParentChildrenMenus(List<Menu> menus) { |
| | | //组合menu父子结构 |
| | | Map<Integer, Menu> menuMap = new HashMap<>(); |
| | | for (Menu menu : menus) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 获取menu菜单中的最底层菜单添加到menus中 |
| | | * @Param: [menu, menus] |
| | | * @return: void |
| | | * @Description: 移除含有子菜单的菜单 |
| | | * @Param: [menus] |
| | | * @return: java.util.List<com.moral.api.entity.Menu> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/5/13 |
| | | * @Date: 2021/5/28 |
| | | */ |
| | | private void getNotParentMenu(Menu menu, List<Menu> menus) { |
| | | if (ObjectUtils.isEmpty(menu.getChildren())) { |
| | | menus.add(menu); |
| | | } else { |
| | | List<Menu> children = menu.getChildren(); |
| | | for (Menu child : children) { |
| | | getNotParentMenu(child, menus); |
| | | } |
| | | private void removeMenuWithChildren(List<Menu> menus) { |
| | | //查询所有菜单 |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<Menu> allMenus = menuMapper.selectList(wrapper); |
| | | //组合menu父子结构 |
| | | Map<Integer, Menu> menuMap = new HashMap<>(); |
| | | for (Menu menu : allMenus) { |
| | | menuMap.put(menu.getId(), menu); |
| | | menu.setChildren(new ArrayList<>());//初始化集合 |
| | | } |
| | | for (Menu menu : allMenus) { |
| | | putMenuToParentMenu(menuMap, menu); |
| | | } |
| | | //移除含有子菜单的菜单 |
| | | menus.removeIf(new Predicate<Menu>() { |
| | | @Override |
| | | public boolean test(Menu menu) { |
| | | if (ObjectUtils.isEmpty(menuMap.get(menu.getId()).getChildren())) |
| | | return false; |
| | | return true; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SysArea; |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.mapper.SysAreaMapper; |
| | | import com.moral.api.service.MonitorPointService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.ConvertUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private SysAreaMapper sysAreaMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | |
| | | int totalNumber = monitorPointMapper.selectCount(wrapper); |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_ASC)){ |
| | | wrapper.orderByAsc("create_time"); |
| | | wrapper.orderByAsc("update_time"); |
| | | }else { |
| | | wrapper.orderByDesc("create_time"); |
| | | wrapper.orderByDesc("update_time"); |
| | | } |
| | | Page resultPage = monitorPointMapper.selectPage(page,wrapper); |
| | | List<MonitorPoint> monitorPoints = resultPage.getRecords(); |
| | |
| | | monitorPointMap.put("createTime",createTime); |
| | | monitorPointMap.put("updateTime",updateTime); |
| | | monitorPointMap.put("key",monitorPoint.getId()); |
| | | if (monitorPointMap.get("provinceCode")!=null&&monitorPointMap.get("provinceCode")!=""){ |
| | | monitorPointMap.put("provinceCode",getAreaArr(monitorPointMap.get("provinceCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("provinceCode",arr); |
| | | } |
| | | if (monitorPointMap.get("cityCode")!=null&&monitorPointMap.get("cityCode")!=""){ |
| | | monitorPointMap.put("cityCode",getAreaArr(monitorPointMap.get("cityCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("cityCode",arr); |
| | | } |
| | | if (monitorPointMap.get("areaCode")!=null&&monitorPointMap.get("areaCode")!=""){ |
| | | monitorPointMap.put("areaCode",getAreaArr(monitorPointMap.get("areaCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("areaCode",arr); |
| | | } |
| | | if (monitorPointMap.get("organizationId")!=null&&monitorPointMap.get("organizationId")!=""){ |
| | | Organization organization = organizationMapper.selectById(Integer.parseInt(monitorPointMap.get("organizationId").toString())); |
| | | if (!ObjectUtils.isEmpty(organization)) { |
| | | String[] organizationArr = {monitorPointMap.get("organizationId").toString(),organization.getName()}; |
| | | monitorPointMap.put("organizationId",organizationArr); |
| | | } |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("organizationId",arr); |
| | | } |
| | | monitorPointtList.add(monitorPointMap); |
| | | } |
| | | resultMap.put("monitorPoints",monitorPointtList); |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Map<String, Object> updateMonitorPoint(Map<String,Object> updateMap) { |
| | | public Map<String, Object> updateMonitorPoint(Map<String,Object> parameterMap) { |
| | | Map resultMap = new HashMap(); |
| | | Map<String,Object> updateMap = new HashMap<>(); |
| | | for (String key : parameterMap.keySet()) { |
| | | updateMap.put(ConvertUtils.toLine(key),parameterMap.get(key)); |
| | | } |
| | | if(!updateMap.containsKey("id")){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | |
| | | resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getMsg()); |
| | | return resultMap; |
| | | } |
| | | if (updateMap.get("name")==null||updateMap.get("name")==""){ |
| | | if (updateMap.get("name")!=null&&updateMap.get("name").equals("")){ |
| | | resultMap.put("code",ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | return resultMap; |
| | | } |
| | | QueryWrapper<MonitorPoint> wapper_name = new QueryWrapper<>(); |
| | | wapper_name.eq("name",updateMap.get("name")); |
| | | wapper_name.eq("is_delete",Constants.NOT_DELETE); |
| | | MonitorPoint monitorPoint_name = monitorPointMapper.selectOne(wapper_name); |
| | | if(monitorPoint_name!=null&&!monitorPoint_name.getId().toString().equals(updateMap.get("id").toString())){ |
| | | resultMap.put("code",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getMsg()); |
| | | return resultMap; |
| | | if (updateMap.get("name")!=null){ |
| | | QueryWrapper<MonitorPoint> wapper_name = new QueryWrapper<>(); |
| | | wapper_name.eq("name",updateMap.get("name")); |
| | | wapper_name.eq("is_delete",Constants.NOT_DELETE); |
| | | MonitorPoint monitorPoint_name = monitorPointMapper.selectOne(wapper_name); |
| | | if(monitorPoint_name!=null&&!monitorPoint_name.getId().toString().equals(updateMap.get("id").toString())){ |
| | | resultMap.put("code",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getMsg()); |
| | | return resultMap; |
| | | } |
| | | } |
| | | monitorPointMapper.updateMonitorPoint(updateMap); |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "修改了站点:"+oldMonitorPoint.getName()+";"; |
| | | for (Object key:updateMap.keySet()) { |
| | | if (key.toString().equals("name")){ |
| | | if (key.toString().equals("name")&&updateMap.get(key)!=null){ |
| | | content = content+"站点名称:"+oldMonitorPoint.getName()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("longitude")){ |
| | | if (key.toString().equals("longitude")&&updateMap.get(key)!=null){ |
| | | content = content+"经度:"+oldMonitorPoint.getLongitude()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("latitude")){ |
| | | if (key.toString().equals("latitude")&&updateMap.get(key)!=null){ |
| | | content = content+"纬度:"+oldMonitorPoint.getLatitude()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("province_code")){ |
| | | if (key.toString().equals("province_code")&&updateMap.get(key)!=null){ |
| | | content = content+"省份编码:"+oldMonitorPoint.getProvinceCode()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("city_code")){ |
| | | if (key.toString().equals("city_code")&&updateMap.get(key)!=null){ |
| | | content = content+"地级市编码:"+oldMonitorPoint.getCityCode()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("area_code")){ |
| | | if (key.toString().equals("area_code")&&updateMap.get(key)!=null){ |
| | | content = content+"县/区/县级市:"+oldMonitorPoint.getAreaCode()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("address")){ |
| | | if (key.toString().equals("address")&&updateMap.get(key)!=null){ |
| | | content = content+"地址:"+oldMonitorPoint.getAddress()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("organization_id")){ |
| | | if (key.toString().equals("organization_id")&&updateMap.get(key)!=null){ |
| | | content = content+"组织id:"+oldMonitorPoint.getOrganizationId()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | if (key.toString().equals("desc")){ |
| | | if (key.toString().equals("desc")&&updateMap.get(key)!=null){ |
| | | content = content+"描述:"+oldMonitorPoint.getDesc()+"->"+updateMap.get(key)+";"; |
| | | } |
| | | } |
| | |
| | | int totalNumber = monitorPointMapper.selectCount(wrapper); |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_ASC)){ |
| | | wrapper.orderByAsc("create_time"); |
| | | wrapper.orderByAsc("update_time"); |
| | | }else { |
| | | wrapper.orderByDesc("create_time"); |
| | | wrapper.orderByDesc("update_time"); |
| | | } |
| | | Page resultPage = monitorPointMapper.selectPage(page,wrapper); |
| | | List<MonitorPoint> monitorPoints = resultPage.getRecords(); |
| | |
| | | monitorPointMap.put("createTime",createTime); |
| | | monitorPointMap.put("updateTime",updateTime); |
| | | monitorPointMap.put("key",monitorPoint.getId()); |
| | | if (monitorPointMap.get("provinceCode")!=null&&monitorPointMap.get("provinceCode")!=""){ |
| | | monitorPointMap.put("provinceCode",getAreaArr(monitorPointMap.get("provinceCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("provinceCode",arr); |
| | | } |
| | | if (monitorPointMap.get("cityCode")!=null&&monitorPointMap.get("cityCode")!=""){ |
| | | monitorPointMap.put("cityCode",getAreaArr(monitorPointMap.get("cityCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("cityCode",arr); |
| | | } |
| | | if (monitorPointMap.get("areaCode")!=null&&monitorPointMap.get("areaCode")!=""){ |
| | | monitorPointMap.put("areaCode",getAreaArr(monitorPointMap.get("areaCode").toString())); |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("areaCode",arr); |
| | | } |
| | | /*Organization organization = organizationMapper.selectById(Integer.parseInt(monitorPointMap.get("organizationId").toString())); |
| | | if (!ObjectUtils.isEmpty(organization)) { |
| | | String[] organizationArr = {monitorPointMap.get("organizationId").toString(),organization.getName()}; |
| | | monitorPointMap.put("organizationId",organizationArr); |
| | | }*/ |
| | | if (monitorPointMap.get("organizationId")!=null&&monitorPointMap.get("organizationId")!=""){ |
| | | Organization organization = organizationMapper.selectById(Integer.parseInt(monitorPointMap.get("organizationId").toString())); |
| | | if (!ObjectUtils.isEmpty(organization)) { |
| | | String[] organizationArr = {monitorPointMap.get("organizationId").toString(),organization.getName()}; |
| | | monitorPointMap.put("organizationId",organizationArr); |
| | | } |
| | | }else { |
| | | String[] arr = {null,null}; |
| | | monitorPointMap.put("organizationId",arr); |
| | | } |
| | | monitorPointtList.add(monitorPointMap); |
| | | } |
| | | resultMap.put("monitorPoints",monitorPointtList); |
| | |
| | | resultMap.put("totalPageNumber",totalPageNumber); |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<MonitorPoint> getMonitorPointsByOrganizationId(Integer organizationId) { |
| | | QueryWrapper<MonitorPoint> monitorPointQueryWrapper = new QueryWrapper<>(); |
| | | MonitorPoint monitorPoint = new MonitorPoint(); |
| | | monitorPoint.setOrganizationId(organizationId); |
| | | monitorPoint.setIsDelete(Constants.NOT_DELETE); |
| | | monitorPointQueryWrapper.setEntity(monitorPoint); |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(monitorPointQueryWrapper); |
| | | return monitorPoints; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 获取地区名 |
| | | * @Param: [areaArr, menu]menuMap:key为menuid,value为menu |
| | | * @return: Array |
| | | * @Author: lizijie |
| | | * @Date: 2021/4/7 |
| | | */ |
| | | private String[] getAreaArr(String areaCode) { |
| | | QueryWrapper<SysArea> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("area_code",areaCode); |
| | | SysArea sysArea = sysAreaMapper.selectOne(wrapper); |
| | | String[] arr = {areaCode,sysArea.getAreaName()}; |
| | | return arr; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.config.mybatis.wrapper.NullFilterWrapper; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.User; |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.mapper.UserMapper; |
| | | import com.moral.api.pojo.dto.organization.OrganizationDTO; |
| | | import com.moral.api.pojo.dto.organization.OrganizationQueryDTO; |
| | | import com.moral.api.pojo.dto.organization.OrganizationQueryNamesDTO; |
| | | import com.moral.api.pojo.form.organization.*; |
| | | import com.moral.api.service.MonitorPointService; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.UserService; |
| | |
| | | |
| | | @Autowired |
| | | UserMapper userMapper; |
| | | |
| | | @Autowired |
| | | MonitorPointService monitorPointService; |
| | | |
| | | Map<String, String> organizationFormMap; |
| | | |
| | |
| | | //取参 |
| | | Integer id = form.getOrganizationId(); |
| | | |
| | | //判断组织是否含有站点 |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(id); |
| | | if(!ObjectUtils.isEmpty(monitorPoints)){ |
| | | dto.setCode(ResponseCodeEnum.ORGANIZATION_EXIST_MONITORPOINT.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.ORGANIZATION_EXIST_MONITORPOINT.getMsg()); |
| | | return dto; |
| | | } |
| | | |
| | | //查询要删除的组织用于插入日志 |
| | | Organization existOrganization = new Organization(); |
| | | existOrganization.setIsDelete(Constants.NOT_DELETE); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | //逻辑删除组织 |
| | | UpdateWrapper deleteWrapper = new UpdateWrapper(); |
| | | deleteWrapper.eq("id", id); |
| | | deleteWrapper.set("is_delete", Constants.DELETE); |
| | | organizationMapper.update(null, deleteWrapper); |
| | | |
| | | //删除组织账号 |
| | | userService.deleteUsersByOrganizationId(id); |
| | | |
| | | //判断是否含有子组织 |
| | | List<Organization> children = getAllChildrenOrganization(existOrganization.getId()); |
| | | if (!ObjectUtils.isEmpty(children)) {//如果含有子组织 |
| | | if (!ObjectUtils.isEmpty(children)) { |
| | | //判断是否删除所有子组织,如果不删除子组织则所有子组织全部变为无父组织,孙子组织不变 |
| | | UpdateWrapper updateWrapper = new UpdateWrapper(); |
| | | if (form.getDeleteChildren().equals(Constants.DELETE_CHILDREN_ORG)) {//删除所有子组织 |
| | |
| | | children.forEach(value -> { |
| | | childrenId.add(value.getId()); |
| | | }); |
| | | //判断子组织是否含有站点,有一个子组织含有站点则不能删除 |
| | | for (Integer childId : childrenId) { |
| | | List<MonitorPoint> childMonitorPoints = monitorPointService.getMonitorPointsByOrganizationId(childId); |
| | | if(!ObjectUtils.isEmpty(childMonitorPoints)){ |
| | | dto.setCode(ResponseCodeEnum.CHILDREN_ORGANIZATION_EXIST_MONITORPOINT.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.CHILDREN_ORGANIZATION_EXIST_MONITORPOINT.getMsg()); |
| | | return dto; |
| | | } |
| | | } |
| | | //进行删除 |
| | | updateWrapper.in("id", childrenId); |
| | | updateWrapper.set("is_delete", Constants.DELETE); |
| | |
| | | } |
| | | } |
| | | |
| | | //逻辑删除组织 |
| | | UpdateWrapper deleteWrapper = new UpdateWrapper(); |
| | | deleteWrapper.eq("id", id); |
| | | deleteWrapper.set("is_delete", Constants.DELETE); |
| | | organizationMapper.update(null, deleteWrapper); |
| | | |
| | | //删除组织账号 |
| | | userService.deleteUsersByOrganizationId(id); |
| | | |
| | | //封装返回结果 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | if (!ObjectUtils.isEmpty(map.get("orderType"))){ |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_DESC)){ |
| | | wrapper.orderByDesc("create_time"); |
| | | wrapper.orderByDesc("update_time"); |
| | | }else { |
| | | wrapper.orderByAsc("create_time"); |
| | | wrapper.orderByAsc("update_time"); |
| | | } |
| | | } |
| | | Page resultPage = sensorMapper.selectPage(page,wrapper); |
| | |
| | | int totleNum = sensorMapper.selectCount(wrapper); |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_ASC)){ |
| | | wrapper.orderByAsc("create_time"); |
| | | wrapper.orderByAsc("update_time"); |
| | | }else { |
| | | wrapper.orderByDesc("create_time"); |
| | | wrapper.orderByDesc("update_time"); |
| | | } |
| | | Page resultPage = sensorMapper.selectPage(page,wrapper); |
| | | List<Sensor> sensors = resultPage.getRecords(); |
| | |
| | | SysDictTypeDTO dto = new SysDictTypeDTO(); |
| | | //获取Id |
| | | Integer typeId = form.getId(); |
| | | //判断type是否存在 |
| | | //查询要删除的type用于插入日志 |
| | | QueryWrapper<SysDictType> existWrapper = new QueryWrapper<>(); |
| | | existWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | existWrapper.eq("id",typeId); |
| | |
| | | //清除缓存数据 |
| | | CacheUtils.clearDictionariesCache(); |
| | | //封装返回数据 |
| | | dto.setSysDictType(type); |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return dto; |
| | |
| | | SysDictTypeDTO dto = new SysDictTypeDTO(); |
| | | //获取实体 |
| | | SysDictType type = form.formConvertEntity(); |
| | | //判断type是否存在 |
| | | //查询type用于插入日志 |
| | | QueryWrapper<SysDictType> existNameWrapper = new QueryWrapper<>(); |
| | | existNameWrapper.eq("id",type.getId()); |
| | | existNameWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | |
| | | //清除缓存 |
| | | CacheUtils.clearDictionariesCache(); |
| | | //封装返回对象 |
| | | dto.setSysDictType(sysDictType); |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return dto; |
| | |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public UserDTO deleteUser(UserDeleteForm form) { |
| | | //创建返回对象 |
| | | UserDTO dto = new UserDTO(); |
| | | //取参 |
| | | Integer id = form.getId(); |
| | | //创建删除条件 |
| | | User user = new User(); |
| | | user.setIsDelete(Constants.DELETE); |
| | | user.setId(id); |
| | | //删除用户 |
| | | userMapper.updateById(user); |
| | | //删除user_group |
| | | UpdateWrapper deleteUserGroupWrapper = new UpdateWrapper(); |
| | | deleteUserGroupWrapper.eq("user_id", id); |
| | | deleteUserGroupWrapper.set("is_delete", Constants.DELETE); |
| | | userGroupMapper.update(null, deleteUserGroupWrapper); |
| | | //删除组织中admin账号字段 |
| | | UpdateWrapper updateOrgWrapper = new UpdateWrapper(); |
| | | updateOrgWrapper.eq("admin_user_id", user.getId()); |
| | | updateOrgWrapper.set("admin_user_id", 0); |
| | | organizationMapper.update(null, updateOrgWrapper); |
| | | //封装返回对象 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.entity.ManageLog; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpRequest; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | limit #{start},#{number} |
| | | </select> |
| | | |
| | | <select id="getManageMenuByNameFuzzy" parameterType="java.util.Map" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"></include> |
| | | from manage_menu mm |
| | | where mm.is_delete = 0 |
| | | <if test="name != null"> |
| | | and mm.name like concat('%',#{name},'%') |
| | | </if> |
| | | <if test="url != null"> |
| | | and mm.url = #{url} |
| | | </if> |
| | | <if test="icon != null"> |
| | | and mm.icon = #{icon} |
| | | </if> |
| | | <if test="parent_id != null"> |
| | | and mm.parent_id = #{parent_id} |
| | | </if> |
| | | <if test="order != null"> |
| | | and mm.order = #{order} |
| | | </if> |
| | | <if test="desc != null"> |
| | | and mm.desc = #{order} |
| | | </if> |
| | | limit #{start},#{number} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | name = #{name}, |
| | | </if> |
| | | <if test="longitude != null"> |
| | | longitude = #{longitude}, |
| | | <if test="longitude == ''"> |
| | | longitude = null, |
| | | </if> |
| | | <if test="longitude != ''"> |
| | | longitude = #{longitude}, |
| | | </if> |
| | | </if> |
| | | <if test="latitude != null"> |
| | | latitude = #{latitude}, |
| | | <if test="latitude == ''"> |
| | | latitude = null, |
| | | </if> |
| | | <if test="latitude != ''"> |
| | | latitude = #{latitude}, |
| | | </if> |
| | | </if> |
| | | <if test="province_code != null"> |
| | | province_code = #{province_code}, |
| | | <if test="province_code == ''"> |
| | | province_code = null, |
| | | </if> |
| | | <if test="province_code != ''"> |
| | | province_code = #{province_code}, |
| | | </if> |
| | | </if> |
| | | <if test="city_code != null"> |
| | | city_code = #{city_code}, |
| | | <if test="city_code == ''"> |
| | | city_code = null, |
| | | </if> |
| | | <if test="city_code != ''"> |
| | | city_code = #{city_code}, |
| | | </if> |
| | | </if> |
| | | <if test="area_code != null"> |
| | | area_code = #{area_code}, |
| | | <if test="area_code == ''"> |
| | | area_code = null, |
| | | </if> |
| | | <if test="area_code != ''"> |
| | | area_code = #{area_code}, |
| | | </if> |
| | | </if> |
| | | <if test="address != null"> |
| | | address = #{address}, |
| | | </if> |
| | | <if test="organization_id != null"> |
| | | organization_id = #{organization_id}, |
| | | <if test="organization_id == ''"> |
| | | organization_id = null, |
| | | </if> |
| | | <if test="organization_id != ''"> |
| | | organization_id = #{organization_id}, |
| | | </if> |
| | | </if> |
| | | <if test="desc != null"> |
| | | `desc` = #{desc}, |