| | |
| | | package com.matrix.system.common.service.impl;
|
| | |
|
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.matrix.core.constance.MatrixConstance;
|
| | | import com.matrix.core.constance.SystemErrorCode;
|
| | | import com.matrix.core.exception.GlobleException;
|
| | | import com.matrix.core.pojo.PaginationVO;
|
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.ModelUtils;
|
| | | import com.matrix.core.tools.StringUtils;
|
| | | import com.matrix.core.tools.WebUtil;
|
| | | import com.matrix.system.common.bean.*;
|
| | | import com.matrix.system.app.authority.AppAuthorityManager; |
| | | import com.matrix.system.common.authority.DefaultAuthorityManager; |
| | | import com.matrix.system.common.bean.SysCompany; |
| | | import com.matrix.system.common.bean.SysRole; |
| | | import com.matrix.system.common.bean.SysRolePwoerFn; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.SysCompanyDao;
|
| | | import com.matrix.system.common.dao.SysRoleDao;
|
| | | import com.matrix.system.common.dao.SysRolePwoerFnDao;
|
| | | import com.matrix.system.common.init.LocalCache; |
| | | import com.matrix.system.common.service.SysCompanyService;
|
| | | import com.matrix.system.common.service.SysUsersService; |
| | | import com.matrix.system.hive.bean.SysShopInfo;
|
| | | import com.matrix.system.hive.bean.Warehouse;
|
| | | import com.matrix.system.hive.dao.SysShopInfoDao;
|
| | | import com.matrix.system.hive.dao.WarehouseDao;
|
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
|
| | | /**
|
| | | * 公司管理
|
| | |
| | |
|
| | | @Autowired
|
| | | private WarehouseDao warehouseDao;
|
| | | |
| | | /**
|
| | | * 为新公司创建一个总部
|
| | | * |
| | | * @param sysCompany
|
| | | */
|
| | | private SysShopInfo addZbShop(SysCompany sysCompany) {
|
| | |
| | | /**
|
| | | * 更新公司员工权限
|
| | | *
|
| | | * @param newSysCompany |
| | | * @author JIANGYOUYAO
|
| | | * @email 935090232@qq.com
|
| | | * @date 2017年12月5日
|
| | | * @param newSysCompany
|
| | | */
|
| | | private void updatePower(SysCompany newSysCompany) {
|
| | | List<String> oldFunctions = null;
|
| | |
| | | newFunctions = StringUtils.strToCollToString(newSysCompany.getComFunctions(), ",");
|
| | | }
|
| | |
|
| | | for (String old : oldFunctions) {
|
| | | Collections.sort(newFunctions); |
| | | Collections.sort(oldFunctions); |
| | | if (Objects.equals(JSONUtil.toJsonStr(newFunctions), JSONUtil.toJsonStr(oldFunctions))) { |
| | | //没有更新的权限 |
| | | return; |
| | | } |
| | | |
| | | List<String> finalNewFunctions = newFunctions; |
| | | List<String> deletedFn = oldFunctions.stream().map(old -> { |
| | | if (finalNewFunctions.stream().noneMatch(newFn -> Objects.equals(newFn, old))) { |
| | | return old; |
| | | } else { |
| | | return ""; |
| | | } |
| | | }).filter(item->StringUtils.isNotBlank(item)).collect(Collectors.toList()); |
| | | |
| | | if(CollectionUtils.isNotEmpty(deletedFn)){ |
| | | rolePwoerFnDao.deleteByFns(newSysCompany.getComId(),deletedFn); |
| | | //有更新权限清空缓存 |
| | | SysUsers sysUsers = new SysUsers(); |
| | | sysUsers.setCompanyId(newSysCompany.getComId()); |
| | | sysUsers.setSuValid(AppConstance.RECORD_VALID); |
| | | List<SysUsers> users = sysUsersService.findByModel(sysUsers); |
| | | users.forEach(user -> { |
| | | String userKey = SecureUtil.md5(user.getSuId() + ""); |
| | | LocalCache.remove(DefaultAuthorityManager.USER_POWER_REDISKEY_PC + userKey); |
| | | LocalCache.remove(AppAuthorityManager.USER_POWER_REDISKEY_APP + userKey); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | /* for (String old : oldFunctions) { |
| | | // 如果新权限中不包含这个老的功能,则要更新改企业下所有的角色权限
|
| | | if (!newFunctions.contains(old)) {
|
| | | SysRole role = new SysRole();
|
| | |
| | | rolePwoerFnDao.deleteByIds(delRolePwoer);
|
| | | }
|
| | | }
|
| | | }*/ |
| | | |
| | | |
| | | |
| | | }
|
| | | }
|
| | | |
| | | @Autowired |
| | | SysUsersService sysUsersService; |
| | |
|
| | | @Override
|
| | | public int modifyByModel(SysCompany sysCompany) {
|
| | |
| | | return sysCompanyDao.selectById(Long.parseLong(comId));
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | } |