|  |  | 
 |  |  |  * @since 2021-03-09 | 
 |  |  |  */ | 
 |  |  | @Service | 
 |  |  | @ConfigurationProperties(prefix = "log-aspect") | 
 |  |  | public class ManageAccountServiceImpl extends ServiceImpl<ManageAccountMapper, ManageAccount> implements ManageAccountService { | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |     ManageAccountRoleMapper manageAccountRoleMapper; | 
 |  |  |     @Autowired | 
 |  |  |     LogUtils logUtils; | 
 |  |  |  | 
 |  |  |     Map<String, String> manageAccountFormMap; | 
 |  |  |  | 
 |  |  |     public void setManageAccountFormMap(Map<String, String> manageAccountFormMap) { | 
 |  |  |         this.manageAccountFormMap = manageAccountFormMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @Description: 登陆接口 | 
 |  |  | 
 |  |  |         QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>(); | 
 |  |  |         wrapper.eq("account", account); | 
 |  |  |         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()); | 
 |  |  | 
 |  |  |         accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); | 
 |  |  |         return accountDTO; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @Description: 将更新操作插入日志 | 
 |  |  |      * @Param: [form, newAccount, oldAccount] | 
 |  |  |      * @return: void | 
 |  |  |      * @Author: 陈凯裕 | 
 |  |  |      * @Date: 2021/4/8 | 
 |  |  |      */ | 
 |  |  |     private void insertUpdateLog(AccountUpdateForm updateForm, ManageAccount oldAccount) { | 
 |  |  |         //操作插入日志 | 
 |  |  |         HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | 
 |  |  |         StringBuilder content = new StringBuilder(); | 
 |  |  |         content.append("修改了用户:").append(oldAccount.getUserName() + ";") | 
 |  |  |                 .append("账号:" + oldAccount.getAccount() + ";"); | 
 |  |  |         //对象转为Map,获取对象更新前后的属性 | 
 |  |  |         Map<String, Object> newParameters = JSONObject.parseObject(JSON.toJSONString(updateForm), Map.class); | 
 |  |  |         Map<String, Object> oldParameters = JSONObject.parseObject(JSON.toJSONString(oldAccount), Map.class); | 
 |  |  |         //遍历配置文件中的Map,将属性转化为汉字 | 
 |  |  |         Set<String> keys = manageAccountFormMap.keySet(); | 
 |  |  |         for (String key : keys) { | 
 |  |  |             String value = manageAccountFormMap.get(key);//属性对应的汉字 | 
 |  |  |             if ("password".equals(key)) {//密码特殊处理,不显示在日志上 | 
 |  |  |                 if (!ObjectUtils.isEmpty(updateForm.getPassword())) {//判断密码是否进行了更新 | 
 |  |  |                     content.append("修改了密码;"); | 
 |  |  |                 } | 
 |  |  |             } else {//其他属性处理 | 
 |  |  |                 if (newParameters.get(key) != null) { | 
 |  |  |                     String newValue = "空"; | 
 |  |  |                     String oldValue = "空"; | 
 |  |  |                     if (newParameters.get(key) != null && !newParameters.get(key).equals(" ")) { | 
 |  |  |                         newValue = String.valueOf(newParameters.get(key)); | 
 |  |  |                     } | 
 |  |  |                     if (oldParameters.get(key) != null && !oldParameters.get(key).equals(" ")) { | 
 |  |  |                         oldValue = String.valueOf(oldParameters.get(key)); | 
 |  |  |                     } | 
 |  |  |                     content.append(value + ":" + oldValue + "->" + newValue + ";"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     * @Description: 更新操作插入日志 |