From f342a0d88b2a7168f794d0cf545d16a3138acb6d Mon Sep 17 00:00:00 2001
From: wuqiping <wuqiping@qq.com>
Date: Wed, 09 Jun 2021 15:55:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java |  413 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 215 insertions(+), 198 deletions(-)

diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
index 08da75a..dcc9e60 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
@@ -1,5 +1,7 @@
 package com.moral.api.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -9,10 +11,9 @@
 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;
@@ -22,17 +23,23 @@
 import com.moral.api.pojo.form.login.LogoutForm;
 import com.moral.api.service.ManageAccountService;
 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.LogUtils;
 import com.moral.constant.Constants;
 import com.moral.constant.ResponseCodeEnum;
-import com.moral.util.AESUtils;
-import com.moral.util.MD5Utils;
-import com.moral.util.TokenUtils;
+import com.moral.util.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 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.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.function.Predicate;
 
 /**
  * <p>
@@ -43,6 +50,7 @@
  * @since 2021-03-09
  */
 @Service
+@ConfigurationProperties(prefix = "log-aspect")
 public class ManageAccountServiceImpl extends ServiceImpl<ManageAccountMapper, ManageAccount> implements ManageAccountService {
 
 
@@ -51,17 +59,24 @@
     @Autowired
     ManageRoleMapper manageRoleMapper;
     @Autowired
-    ManageMenuMapper manageMenuMapper;
+    ManageMenuService manageMenuService;
     @Autowired
     ManageAccountRoleMapper manageAccountRoleMapper;
+    @Autowired
+    LogUtils logUtils;
 
+    Map<String, String> manageAccountFormMap;
+
+    public void setManageAccountFormMap(Map<String, String> manageAccountFormMap) {
+        this.manageAccountFormMap = manageAccountFormMap;
+    }
 
     /**
-     * @Description: ������
-     * @Param: [parameters]
-     * @return: java.util.Map<java.lang.String                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               java.lang.Object>
+     * @Description: ������������
+     * @Param: [loginForm]
+     * @return: com.moral.api.pojo.dto.login.LoginDTO
      * @Author: ���������
-     * @Date: 2021/3/11
+     * @Date: 2021/3/30
      */
     @Override
     public LoginDTO login(LoginForm loginForm) {
@@ -74,21 +89,10 @@
         //������������������
         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;
         }
@@ -103,9 +107,9 @@
         List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
 
         //������������
-        List<ManageMenu> menus = null;
+        List<ManageMenu> menus = new ArrayList<>();
         if (!ObjectUtils.isEmpty(roles)) {
-            menus = manageMenuMapper.getParentChildrenMenusByRoles(roles);
+            menus = manageMenuService.getParentChildrenMenusByRoles(roles);
         }
 
         //������������������
@@ -120,8 +124,13 @@
         //������������������
         loginDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
         loginDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
-        loginDTO.setAccountInfoDTO(accountInfoDTO);
         loginDTO.setToken(token);
+
+        //������������������
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        StringBuilder content = new StringBuilder();
+        content.append(manageAccount.getUserName()).append("���������������������;");
+        logUtils.saveLoginForManage(request, content.toString(), manageAccount, manageAccount.getUserName());
 
         return loginDTO;
     }
@@ -129,7 +138,7 @@
     /**
      * @Description: ������
      * @Param: [parameters]
-     * @return: java.util.Map<java.lang.String                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               java.lang.Object>
+     * @return:
      * @Author: ���������
      * @Date: 2021/3/11
      */
@@ -150,65 +159,52 @@
      */
     @Override
     @Transactional
-    public AccountInsertDTO insertAccount(AccountInsertForm accountInsertForm) {
-        AccountInsertDTO accountInsertDTO = new AccountInsertDTO();
+    public AccountDTO insertAccount(AccountInsertForm accountInsertForm) {
+        AccountDTO accountDTO = new AccountDTO();
         //������
-        String account = accountInsertForm.getAccount();
-        String AESPassword = accountInsertForm.getPassword();
-        String password = MD5Utils.saltMD5(AESUtils.decrypt(AESPassword));
-        String userName = accountInsertForm.getUserName();
-        String email = accountInsertForm.getEmail();
-        String mobile = accountInsertForm.getMobile();
-        String wechat = accountInsertForm.getWechat();
-        List<String> roleIdsStr = accountInsertForm.getRoleIds();
+        ManageAccount manageAccount = accountInsertForm.formConvertEntity();
+        List<Integer> roleIds = accountInsertForm.getRoleIds();
 
         /*������������������������*/
         ManageAccount existAccount = new ManageAccount();
-        existAccount.setAccount(account);
+        existAccount.setAccount(manageAccount.getAccount());
         existAccount.setIsDelete(Constants.NOT_DELETE);
         QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>();
         wrapper.setEntity(existAccount);
-        List<ManageAccount> exitAccounts = manageAccountMapper.selectList(wrapper);
-        if (!ObjectUtils.isEmpty(exitAccounts)) {
-            accountInsertDTO.setCode(ResponseCodeEnum.ACCOUNT_EXIST.getCode());
-            accountInsertDTO.setMsg(ResponseCodeEnum.ACCOUNT_EXIST.getMsg());
-            return accountInsertDTO;
+        ManageAccount exitAccountResult = manageAccountMapper.selectOne(wrapper);
+        if (!ObjectUtils.isEmpty(exitAccountResult)) {
+            accountDTO.setCode(ResponseCodeEnum.ACCOUNT_EXIST.getCode());
+            accountDTO.setMsg(ResponseCodeEnum.ACCOUNT_EXIST.getMsg());
+            return accountDTO;
         }
 
-        //������account
-        ManageAccount manageAccount = new ManageAccount();
-        manageAccount.setAccount(account);
-        manageAccount.setPassword(password);
-        manageAccount.setUserName(userName);
-        manageAccount.setEmail(email);
-        manageAccount.setMobile(mobile);
-        manageAccount.setWechat(wechat);
+        //������
         manageAccountMapper.insert(manageAccount);
-        //������account_role
-        /*String to Integer*/
-        List<ManageRole> roles = null;
-        //������������������������������������������������������
-        if (!ObjectUtils.isEmpty(roleIdsStr)) {
-            List<Integer> roleIds = new ArrayList<>();
-            roleIdsStr.forEach(str -> roleIds.add(Integer.parseInt(str)));
 
+        //������������������������������������������������������
+        if (!ObjectUtils.isEmpty(roleIds)) {
             Integer accountId = manageAccount.getId();
-            roleIdsStr.forEach(
+            roleIds.forEach(
                     value -> {
                         ManageAccountRole manageAccountRole = new ManageAccountRole();
                         manageAccountRole.setAccountId(accountId);
-                        manageAccountRole.setRoleId(Integer.parseInt(value));
+                        manageAccountRole.setRoleId(value);
                         manageAccountRoleMapper.insert(manageAccountRole);
                     }
             );
-            roles = manageRoleMapper.selectBatchIds(roleIds);
         }
         //������������������
-        accountInsertDTO.setAccount(manageAccount);
-        accountInsertDTO.setRoles(roles);
-        accountInsertDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
-        accountInsertDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
-        return accountInsertDTO;
+        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;
     }
 
     /**
@@ -221,11 +217,10 @@
     @Override
     public AccountQueryDTO queryAccount(AccountQueryForm accountQueryForm) {
         AccountQueryDTO accountQueryDTO = new AccountQueryDTO();
+
         //������
-        Integer pageCount = accountQueryForm.getPage();
+        Integer page = accountQueryForm.getPage();
         Integer size = accountQueryForm.getSize();
-        Integer accountId = accountQueryForm.getAccountId();
-        String account = accountQueryForm.getAccount();
         String userName = accountQueryForm.getUserName();
         String email = accountQueryForm.getEmail();
         String mobile = accountQueryForm.getMobile();
@@ -233,61 +228,64 @@
         String isDelete = accountQueryForm.getIsDelete();
         String order = accountQueryForm.getOrder();
         String orderType = accountQueryForm.getOrderType();
+        Date createStartTime = accountQueryForm.getCreateStartTime();
+        Date createEndTime = accountQueryForm.getCreateEndTime();
 
-        //������������
-        Page<ManageAccount> page = new Page<>(pageCount, size);
-        QueryWrapper<ManageAccount> wrapper = new QueryWrapper();
-        if (!ObjectUtils.isEmpty(accountId)) {
-            wrapper.eq("id", accountId);
+        //������������������
+        Page<ManageAccount> queryPage = new Page<>(page, size);
+        NullFilterWrapper<ManageAccount> wrapper = new NullFilterWrapper<>();
+
+        wrapper.like("user_name", userName);
+        wrapper.like("email", email);
+        wrapper.like("mobile", mobile);
+        wrapper.like("wechat", wechat);
+        wrapper.between("create_time", createStartTime, createEndTime);
+
+        if (!ObjectUtils.isEmpty(order) && !ObjectUtils.isEmpty(orderType)) { //������������������������
+            if (orderType.equals(Constants.ORDER_ASC))
+                wrapper.orderByAsc(ConvertUtils.toLine(order));
+            else
+                wrapper.orderByDesc(ConvertUtils.toLine(order));
         }
 
-        if (!ObjectUtils.isEmpty(userName)) {
-            wrapper.like("user_name", userName);
-        }
-
-        if (!ObjectUtils.isEmpty(account)) {
-            wrapper.like("account", account);
-        }
-
-        if (!ObjectUtils.isEmpty(email)) {
-            wrapper.like("email", email);
-        }
-
-        if (!ObjectUtils.isEmpty(mobile)) {
-            wrapper.like("mobile", mobile);
-        }
-
-        if (!ObjectUtils.isEmpty(wechat)) {
-            wrapper.like("wechat", wechat);
-        }
-
-        if (!ObjectUtils.isEmpty(order)) {
-            if (!ObjectUtils.isEmpty(orderType)) {
-                if (orderType.equals(Constants.ORDER_ASC))
-                    wrapper.orderByAsc(order);
-                else
-                    wrapper.orderByDesc(order);
-            }
-        }
-
-        if (!ObjectUtils.isEmpty(isDelete))
+        if (!ObjectUtils.isEmpty(isDelete))//������������������������
             wrapper.eq("is_delete", isDelete);
         else
             wrapper.eq("is_delete", Constants.NOT_DELETE);
 
-        Page resultPage = manageAccountMapper.selectPage(page, wrapper);
-        //���������������������������
+        //������������
+        Page resultPage = manageAccountMapper.selectPage(queryPage, wrapper);
         List<ManageAccount> accounts = resultPage.getRecords();
-        List<AccountDTO> accountDTOS = new ArrayList<>();
-        if (!ObjectUtils.isEmpty(accounts)) {
-            for (ManageAccount manageAccount : accounts) {
-                AccountDTO accountDTO = new AccountDTO();
-                List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
-                accountDTO.setRoles(roles);
-                accountDTO.setAccount(manageAccount);
-                accountDTOS.add(accountDTO);
-            }
+        //������������������������������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();
+            List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
+            accountDTO.setRoles(roles);
+            accountDTO.setAccount(manageAccount);
+            accountDTOS.add(accountDTO);
+        }
+
+
         //������������������
         accountQueryDTO.setAccountDTOS(accountDTOS);
         accountQueryDTO.setCurrent(resultPage.getCurrent());
@@ -301,76 +299,6 @@
     }
 
     /**
-     * @Description: ������������������
-     * @Param: [accountUpdateRequest]
-     * @return: com.moral.api.pojo.dto.account.AccountUpdateDTO
-     * @Author: ���������
-     * @Date: 2021/3/16
-     */
-    @Override
-    @Transactional
-    public AccountUpdateDTO updateAccount(AccountUpdateForm accountUpdateForm) {
-        AccountUpdateDTO accountUpdateDTO = new AccountUpdateDTO();
-        //������
-        Integer accountId = accountUpdateForm.getAccountId();
-        String password = accountUpdateForm.getPassword();
-        String email = accountUpdateForm.getEmail();
-        String mobile = accountUpdateForm.getMobile();
-        String wechat = accountUpdateForm.getWechat();
-        String userName = accountUpdateForm.getUserName();
-        List<Integer> roleIds = accountUpdateForm.getRoleIds();
-        //������������������������������������
-        QueryWrapper<ManageAccount> exitWrapper = new QueryWrapper<>();
-        ManageAccount exitManageAccount = new ManageAccount();
-        exitManageAccount.setId(accountId);
-        exitManageAccount.setIsDelete(Constants.NOT_DELETE);
-        exitWrapper.setEntity(exitManageAccount);
-        List<ManageAccount> manageAccounts = manageAccountMapper.selectList(exitWrapper);
-        if (ObjectUtils.isEmpty(manageAccounts)) {
-            accountUpdateDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode());
-            accountUpdateDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg());
-            return accountUpdateDTO;
-        }
-        //������password
-        if(!ObjectUtils.isEmpty(password)){
-            password = MD5Utils.saltMD5(AESUtils.decrypt(password));
-        }
-        //������ManageAccount���
-        ManageAccount manageAccount = new ManageAccount();
-        manageAccount.setPassword(password);
-        manageAccount.setEmail(email);
-        manageAccount.setMobile(mobile);
-        manageAccount.setWechat(wechat);
-        manageAccount.setUserName(userName);
-        QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>();
-        wrapper.eq("id", accountId);
-        manageAccountMapper.update(manageAccount, wrapper);
-        //���������������������������������ManageAccountRole���
-        /*������������������������������*/
-        if (!ObjectUtils.isEmpty(roleIds)) {
-            QueryWrapper<ManageAccountRole> deleteWrapper = new QueryWrapper<>();
-            deleteWrapper.eq("account_id", accountId);
-            manageAccountRoleMapper.delete(deleteWrapper);
-            /*������������������*/
-            for (Integer roleId : roleIds) {
-                ManageAccountRole manageAccountRole = new ManageAccountRole();
-                manageAccountRole.setAccountId(accountId);
-                manageAccountRole.setRoleId(roleId);
-                manageAccountRoleMapper.insert(manageAccountRole);
-            }
-            //������������������������
-            List<ManageRole> manageRoles = manageRoleMapper.selectBatchIds(roleIds);
-            accountUpdateDTO.setRoles(manageRoles);
-        }
-        //������������������
-        accountUpdateDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
-        accountUpdateDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
-        accountUpdateDTO.setAccount(manageAccountMapper.selectById(accountId));
-        return accountUpdateDTO;
-    }
-
-
-    /**
      * @Description: ������������������
      * @Param: [accountDeleteRequest]
      * @return: com.moral.api.pojo.dto.account.AccountDeleteDTO
@@ -379,11 +307,11 @@
      */
     @Override
     @Transactional
-    public AccountDeleteDTO deleteAccount(AccountDeleteForm accountDeleteForm) {
-        AccountDeleteDTO accountDeleteDTO = new AccountDeleteDTO();
+    public AccountDTO deleteAccount(AccountDeleteForm accountDeleteForm) {
+        AccountDTO accountDTO = new AccountDTO();
         //������
         Integer accountId = accountDeleteForm.getAccountId();
-        //������������������
+        //���������������������������������������������
         ManageAccount manageAccount = new ManageAccount();
         manageAccount.setIsDelete(Constants.NOT_DELETE);
         manageAccount.setId(accountId);
@@ -391,24 +319,113 @@
         queryWrapper.setEntity(manageAccount);
         ManageAccount existManageAccount = manageAccountMapper.selectOne(queryWrapper);
         if (ObjectUtils.isEmpty(existManageAccount)) {
-            accountDeleteDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode());
-            accountDeleteDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg());
-            return accountDeleteDTO;
+            accountDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode());
+            accountDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg());
+            return accountDTO;
         }
         //������������������
-        existManageAccount.setIsDelete(Constants.DELETE);
         UpdateWrapper<ManageAccount> deleteAccountWrapper = new UpdateWrapper<>();
-        deleteAccountWrapper.set("is_delete", Constants.DELETE).eq("id", manageAccount.getId());
+        deleteAccountWrapper.eq("id", accountId);
+        deleteAccountWrapper.set("is_delete", Constants.DELETE);
         manageAccountMapper.update(null, deleteAccountWrapper);
         //������������������������������
         UpdateWrapper<ManageAccountRole> deleteManageAccountRoleWrapper = new UpdateWrapper<>();
         deleteManageAccountRoleWrapper.set("is_delete", Constants.DELETE).eq("account_id", manageAccount.getId());
         manageAccountRoleMapper.update(null, deleteManageAccountRoleWrapper);
+        //������token
+        TokenUtils.destoryToken(accountId);
         //������������������
-        accountDeleteDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
-        accountDeleteDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
-        accountDeleteDTO.setAccount(existManageAccount);
-        return accountDeleteDTO;
+        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);
+
+        return accountDTO;
+    }
+
+    /**
+     * @Description: ������������������
+     * @Param: [accountUpdateRequest]
+     * @return: com.moral.api.pojo.dto.account.AccountUpdateDTO
+     * @Author: ���������
+     * @Date: 2021/3/16
+     */
+    @Override
+    @Transactional
+    public AccountDTO updateAccount(AccountUpdateForm accountUpdateForm) {
+        AccountDTO accountDTO = new AccountDTO();
+        //������
+        ManageAccount manageAccount = accountUpdateForm.formConvertEntity();
+
+        //������������������������������������������
+        QueryWrapper<ManageAccount> oldAccountWrapper = new QueryWrapper<>();
+        ManageAccount oldManageAccount = new ManageAccount();
+        oldManageAccount.setId(manageAccount.getId());
+        oldManageAccount.setIsDelete(Constants.NOT_DELETE);
+        oldAccountWrapper.setEntity(oldManageAccount);
+        oldManageAccount = manageAccountMapper.selectOne(oldAccountWrapper);
+        if (ObjectUtils.isEmpty(oldManageAccount)) {
+            accountDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode());
+            accountDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg());
+            return accountDTO;
+        }
+
+        //������ManageAccount���
+        manageAccountMapper.updateById(manageAccount);
+
+        //������������������
+        insertUpdateLog(accountUpdateForm, oldManageAccount);
+        //������token
+        TokenUtils.destoryToken(manageAccount.getId());
+        //������������������
+        accountDTO.setCode(ResponseCodeEnum.SUCCESS.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);
     }
 
 

--
Gitblit v1.8.0