kaiyu
2021-08-26 19b72fbd2e6b30a23a06dd284619784a096bc896
screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
@@ -52,7 +52,6 @@
 * @since 2021-03-09
 */
@Service
@ConfigurationProperties(prefix = "log-aspect")
public class ManageAccountServiceImpl extends ServiceImpl<ManageAccountMapper, ManageAccount> implements ManageAccountService {
@@ -66,12 +65,6 @@
    ManageAccountRoleMapper manageAccountRoleMapper;
    @Autowired
    LogUtils logUtils;
    Map<String, String> manageAccountFormMap;
    public void setManageAccountFormMap(Map<String, String> manageAccountFormMap) {
        this.manageAccountFormMap = manageAccountFormMap;
    }
    /**
     * @Description: 登陆接口
@@ -375,48 +368,6 @@
        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: 更新操作插入日志