| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.config.mybatis.wrapper.NullFilterWrapper; |
| | | import com.moral.api.service.ManageMenuService; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import com.moral.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | |
| | | //查询是否存在 |
| | | QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("account", account); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper.select("id", "password"); |
| | | ManageAccount manageAccount = manageAccountMapper.selectOne(wrapper); |
| | | if (ObjectUtils.isEmpty(manageAccount)) { |
| | | loginDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); |
| | |
| | | } |
| | | ); |
| | | } |
| | | //操作插入日志 |
| | | insertLog(manageAccount); |
| | | //封装返回结果 |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | |
| | | return accountDTO; |
| | | } |
| | | |
| | |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(existManageAccount.getUserName() + ";") |
| | | .append("账号:" + existManageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | |
| | | deleteLog(existManageAccount); |
| | | return accountDTO; |
| | | } |
| | | |
| | |
| | | |
| | | //更新ManageAccount表 |
| | | manageAccountMapper.updateById(manageAccount); |
| | | |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount); |
| | | updateLog(oldManageAccount,manageAccount); |
| | | //销毁token |
| | | TokenUtils.destoryToken(manageAccount.getId()); |
| | | //封装返回结果 |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 更新操作插入日志 |
| | | * @Param: [oldAccount, newAccount] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void updateLog(ManageAccount oldAccount,ManageAccount newAccount){ |
| | | List<CompareFieldResult> results = CompareFieldUtils.compare(ManageAccount.class, oldAccount, newAccount); |
| | | StringBuilder content = new StringBuilder("修改了后台用户"+";"); |
| | | content.append("账号:"+oldAccount.getAccount()+";"); |
| | | //密码特殊处理 |
| | | if(!ObjectUtils.isEmpty(newAccount.getPassword())) |
| | | content.append("修改了密码"); |
| | | String resultContent = CompareFieldUtils.resultsConvertContent(results,content.toString()); |
| | | logUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 插入操作插入日志 |
| | | * @Param: [account] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void insertLog(ManageAccount manageAccount){ |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了后台用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 删除操作插入日志 |
| | | * @Param: [manageAccount] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void deleteLog(ManageAccount manageAccount){ |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("账号:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage( content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | } |
| | | |