kaiyu
2021-06-08 6ebaa774117610a8599d369fe9d8258e62a69031
screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
@@ -11,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;
@@ -40,6 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.function.Predicate;
/**
 * <p>
@@ -118,7 +118,7 @@
        List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
        //查询菜单
        List<ManageMenu> menus = null;
        List<ManageMenu> menus = new ArrayList<>();
        if (!ObjectUtils.isEmpty(roles)) {
            menus = manageMenuService.getParentChildrenMenusByRoles(roles);
        }
@@ -267,9 +267,27 @@
        //查询结果
        Page resultPage = manageAccountMapper.selectPage(queryPage, wrapper);
        //查询用户对应的角色
        List<ManageAccount> accounts = resultPage.getRecords();
        //过滤系统最高权限账号admin,除admin角色外无法查看
        AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken();
        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();
@@ -326,6 +344,8 @@
        UpdateWrapper<ManageAccountRole> deleteManageAccountRoleWrapper = new UpdateWrapper<>();
        deleteManageAccountRoleWrapper.set("is_delete", Constants.DELETE).eq("account_id", manageAccount.getId());
        manageAccountRoleMapper.update(null, deleteManageAccountRoleWrapper);
        //销毁token
        TokenUtils.destoryToken(accountId);
        //封装返回结果
        accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
        accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
@@ -395,11 +415,13 @@
                manageAccountRoleMapper.insert(manageAccountRole);
            }
        }
        //操作插入日志
        insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles);
        //销毁token
        TokenUtils.destoryToken(manageAccount.getId());
        //封装返回结果
        accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
        accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
        //操作插入日志
        insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles);
        return accountDTO;
    }