初始代码
This commit is contained in:
21
yunzhupaas-permission/pom.xml
Normal file
21
yunzhupaas-permission/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-java-boot</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-permission</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yunzhupaas-permission-entity</module>
|
||||
<module>yunzhupaas-permission-biz</module>
|
||||
<module>yunzhupaas-permission-controller</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
51
yunzhupaas-permission/yunzhupaas-permission-biz/pom.xml
Normal file
51
yunzhupaas-permission/yunzhupaas-permission-biz/pom.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-permission</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-permission-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- 第三方登录-->
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-connector</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<groupId>javax.validation</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-oauth-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.yunzhupaas.permission.constant;
|
||||
|
||||
/**
|
||||
* 类功能
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/2/14
|
||||
*/
|
||||
public class AuthorizeConst {
|
||||
|
||||
public final static String USER = "User";
|
||||
/**
|
||||
* 岗位 权限标识
|
||||
*/
|
||||
public final static String POSITION = "Position";
|
||||
/**
|
||||
* 角色 权限标识
|
||||
*/
|
||||
public final static String ROLE = "Role";
|
||||
/**
|
||||
* 按钮 权限标识
|
||||
*/
|
||||
public final static String BUTTON = "button";
|
||||
/**
|
||||
* 菜单 权限标识
|
||||
*/
|
||||
public final static String MODULE = "module";
|
||||
/**
|
||||
* 列表 权限标识
|
||||
*/
|
||||
public final static String COLUMN = "column";
|
||||
/**
|
||||
* 数据 权限标识
|
||||
*/
|
||||
public final static String RESOURCE = "resource";
|
||||
/**
|
||||
* 表单 权限标识
|
||||
*/
|
||||
public final static String FROM = "form";
|
||||
/**
|
||||
* 系统、子系统
|
||||
*/
|
||||
public final static String SYSTEM = "system";
|
||||
/**
|
||||
* 数据 权限标识
|
||||
*/
|
||||
public final static String AUTHORIZE_PORTAL_MANAGE = "portalManage";
|
||||
/**
|
||||
* 流程 权限标识
|
||||
*/
|
||||
public final static String FLOW = "flow";
|
||||
/**
|
||||
* 打印 权限标识
|
||||
*/
|
||||
public final static String PRINT = "print";
|
||||
/**
|
||||
*
|
||||
* 权限标识集合
|
||||
*/
|
||||
public final static String[] TYPES = {USER, POSITION, ROLE, BUTTON, MODULE, COLUMN, RESOURCE, FROM};
|
||||
|
||||
public final static String DATE_PICKER = "datePicker";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.base.model.base.SystemBaeModel;
|
||||
import com.yunzhupaas.base.model.form.ModuleFormModel;
|
||||
import com.yunzhupaas.permission.entity.AuthorizeEntity;
|
||||
import com.yunzhupaas.base.model.button.ButtonModel;
|
||||
import com.yunzhupaas.base.model.column.ColumnModel;
|
||||
import com.yunzhupaas.base.model.module.ModuleModel;
|
||||
import com.yunzhupaas.base.model.resource.ResourceModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
public interface AuthorizeMapper extends SuperMapper<AuthorizeEntity> {
|
||||
|
||||
|
||||
List<ModuleModel> findModule(@Param("objectId") List<String> objectId, @Param("systemId") List<String> systemId, @Param("moduleAuthorize") List<String> moduleAuthorize, @Param("moduleUrlAddressAuthorize") List<String> moduleUrlAddressAuthorize, @Param("mark") Integer mark,@Param("moduleCode") List<String> moduleCode);
|
||||
|
||||
List<ButtonModel> findButton(@Param("objectId") List<String> objectId);
|
||||
|
||||
List<ColumnModel> findColumn(@Param("objectId") List<String> objectId);
|
||||
|
||||
List<ResourceModel> findResource(@Param("objectId") List<String> objectId);
|
||||
|
||||
List<ModuleFormModel> findForms(@Param("objectId") List<String> objectId);
|
||||
|
||||
List<SystemBaeModel> findSystem(@Param("objectId") List<String> objectId, @Param("enCode") String enCode, @Param("moduleAuthorize") List<String> moduleAuthorize, @Param("mark") Integer mark);
|
||||
|
||||
List<ButtonModel> findButtonAdmin(@Param("mark") Integer mark);
|
||||
|
||||
List<ColumnModel> findColumnAdmin(@Param("mark") Integer mark);
|
||||
|
||||
List<ResourceModel> findResourceAdmin(@Param("mark") Integer mark);
|
||||
|
||||
List<ModuleFormModel> findFormsAdmin(@Param("mark") Integer mark);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.ColumnsPurviewEntity;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/15 9:41
|
||||
*/
|
||||
public interface ColumnsPurviewMapper extends SuperMapper<ColumnsPurviewEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.GroupEntity;
|
||||
|
||||
/**
|
||||
* 分组管理Mapper
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/10 17:56
|
||||
*/
|
||||
public interface GroupMapper extends SuperMapper<GroupEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.OrganizeAdministratorEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 机构分级管理员
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface OrganizeAdminIsTratorMapper extends SuperMapper<OrganizeAdministratorEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.OrganizeEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 组织机构
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface OrganizeMapper extends SuperMapper<OrganizeEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.OrganizeRelationEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织关系 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @since 2022-01-19
|
||||
*/
|
||||
public interface OrganizeRelationMapper extends SuperMapper<OrganizeRelationEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.PermissionGroupEntity;
|
||||
|
||||
public interface PermissionGroupMapper extends SuperMapper<PermissionGroupEntity> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.PositionEntity;
|
||||
|
||||
/**
|
||||
* 岗位信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface PositionMapper extends SuperMapper<PositionEntity> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.RoleEntity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface RoleMapper extends SuperMapper<RoleEntity> {
|
||||
|
||||
/**
|
||||
* 通过组织id获取用户信息
|
||||
*
|
||||
* @param orgIdList
|
||||
* @return
|
||||
*/
|
||||
List<String> query(@Param("orgIdList") List<String> orgIdList, @Param("keyword") String keyword, @Param("globalMark") Integer globalMark, @Param("enabledMark") Integer enabledMark);
|
||||
|
||||
/**
|
||||
* 通过组织id获取用户信息
|
||||
*
|
||||
* @param
|
||||
* @param orgIdList
|
||||
* @return
|
||||
*/
|
||||
Long count(@Param("orgIdList") List<String> orgIdList, @Param("keyword") String keyword, @Param("globalMark") Integer globalMark, @Param("enabledMark") Integer enabledMark);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.SocialsUserEntity;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 9:49:19
|
||||
*/
|
||||
public interface SocialsUserMapper extends SuperMapper<SocialsUserEntity> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface UserMapper extends SuperMapper<UserEntity> {
|
||||
/**
|
||||
* 获取用户id
|
||||
* @return
|
||||
*/
|
||||
List<String> getListId();
|
||||
|
||||
/**
|
||||
* 通过组织id获取用户信息
|
||||
*
|
||||
* @param orgIdList
|
||||
* @param gender
|
||||
* @return
|
||||
*/
|
||||
List<String> query(@Param("orgIdList") List<String> orgIdList, @Param("account") String account, @Param("dbSchema") String dbSchema, @Param("enabledMark") Integer enabledMark, @Param("gender") String gender);
|
||||
|
||||
/**
|
||||
* 通过组织id获取用户信息
|
||||
*
|
||||
* @param orgIdList
|
||||
* @param gender
|
||||
* @return
|
||||
*/
|
||||
Long count(@Param("orgIdList") List<String> orgIdList, @Param("account") String account, @Param("dbSchema") String dbSchema, @Param("enabledMark") Integer enabledMark, @Param("gender") String gender);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.permission.entity.UserOldPasswordEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 组织机构
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface UserOldPasswordMapper extends SuperMapper<UserOldPasswordEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.permission.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 用户关系
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface UserRelationMapper extends SuperMapper<UserRelationEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunzhupaas.permission.rest;
|
||||
|
||||
import com.yunzhupaas.permission.connector.HttpRequestUserInfoService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 推送工具类
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/7/28 20:56
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PullUserUtil {
|
||||
|
||||
|
||||
private static HttpRequestUserInfoService httpRequestUserInfoService;
|
||||
|
||||
public PullUserUtil(@Autowired(required = false) HttpRequestUserInfoService httpRequestUserInfoService){
|
||||
PullUserUtil.httpRequestUserInfoService = httpRequestUserInfoService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送到
|
||||
*
|
||||
* @param userEntity
|
||||
* @param method
|
||||
* @param tenantId
|
||||
*/
|
||||
public static void syncUser(UserEntity userEntity, String method, String tenantId) {
|
||||
if (httpRequestUserInfoService != null) {
|
||||
Map<String, Object> map = JsonUtil.entityToMap(userEntity);
|
||||
httpRequestUserInfoService.syncUserInfo(map, method, tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.permission.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yunzhupaas.permission.entity.ColumnsPurviewEntity;
|
||||
|
||||
/**
|
||||
* 模块列表权限业务类
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/15 9:39
|
||||
*/
|
||||
public interface ColumnsPurviewService extends SuperService<ColumnsPurviewEntity> {
|
||||
|
||||
/**
|
||||
* 通过moduleId获取列表权限
|
||||
*
|
||||
* @param moduleId
|
||||
* @return
|
||||
*/
|
||||
ColumnsPurviewEntity getInfo(String moduleId);
|
||||
|
||||
/**
|
||||
* 判断是保存还是编辑
|
||||
*
|
||||
* @param moduleId
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
boolean update(String moduleId, ColumnsPurviewEntity entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.yunzhupaas.permission.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yunzhupaas.permission.entity.SocialsUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 9:33:16
|
||||
*/
|
||||
public interface SocialsUserService extends SuperService<SocialsUserEntity> {
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14
|
||||
*/
|
||||
List<SocialsUserEntity> getListByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14
|
||||
*/
|
||||
List<SocialsUserEntity> getUserIfnoBySocialIdAndType(String socialId,String socialType);
|
||||
|
||||
/**
|
||||
* 查询用户授权列表
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14
|
||||
*/
|
||||
List<SocialsUserEntity> getListByUserIdAndSource(String userId,String socialType);
|
||||
|
||||
/**
|
||||
* 根据第三方账号账号类型和id获取用户第三方绑定信息
|
||||
* @param socialId 第三方账号id
|
||||
* @return
|
||||
*/
|
||||
SocialsUserEntity getInfoBySocialId(String socialId,String socialType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.permission.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.permission.entity.UserOldPasswordEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
public interface UserOldPasswordService extends SuperService<UserOldPasswordEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<UserOldPasswordEntity> getList(String userId);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
Boolean create(UserOldPasswordEntity entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,840 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.*;
|
||||
import com.yunzhupaas.base.model.base.SystemBaeModel;
|
||||
import com.yunzhupaas.base.model.button.ButtonModel;
|
||||
import com.yunzhupaas.base.model.column.ColumnModel;
|
||||
import com.yunzhupaas.base.model.form.ModuleFormModel;
|
||||
import com.yunzhupaas.base.model.module.ModuleModel;
|
||||
import com.yunzhupaas.base.model.portalManage.PortalManagePageDO;
|
||||
import com.yunzhupaas.base.model.portalManage.PortalModel;
|
||||
import com.yunzhupaas.base.model.portalManage.SavePortalAuthModel;
|
||||
import com.yunzhupaas.base.model.resource.ResourceModel;
|
||||
import com.yunzhupaas.base.service.*;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.YunzhupaasConst;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.consts.DeviceType;
|
||||
import com.yunzhupaas.database.model.dto.PrepSqlDTO;
|
||||
import com.yunzhupaas.database.model.superQuery.SuperJsonModel;
|
||||
import com.yunzhupaas.database.model.superQuery.SuperQueryJsonModel;
|
||||
import com.yunzhupaas.database.sql.util.SqlFrameFastUtil;
|
||||
import com.yunzhupaas.database.util.DataSourceUtil;
|
||||
import com.yunzhupaas.database.util.DbTypeUtil;
|
||||
import com.yunzhupaas.database.util.JdbcUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.emnus.SearchMethodEnum;
|
||||
import com.yunzhupaas.model.login.UserSystemVO;
|
||||
import com.yunzhupaas.model.tenant.TenantAuthorizeModel;
|
||||
import com.yunzhupaas.model.visualJson.FieLdsModel;
|
||||
import com.yunzhupaas.model.visualJson.config.ConfigModel;
|
||||
import com.yunzhupaas.permission.constant.AuthorizeConst;
|
||||
import com.yunzhupaas.permission.entity.AuthorizeEntity;
|
||||
import com.yunzhupaas.permission.entity.OrganizeAdministratorEntity;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.mapper.AuthorizeMapper;
|
||||
import com.yunzhupaas.permission.model.authorize.*;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 操作权限
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AuthorizeServiceImpl extends SuperServiceImpl<AuthorizeMapper, AuthorizeEntity>
|
||||
implements AuthorizeService {
|
||||
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private DataSourceUtil dataSourceUtils;
|
||||
@Autowired
|
||||
private CacheKeyUtil cacheKeyUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private OrganizeAdministratorService organizeAdminIsTratorService;
|
||||
@Autowired
|
||||
private SystemService systemApi;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private PermissionGroupService permissionGroupService;
|
||||
@Autowired
|
||||
private ModuleService moduleApi;
|
||||
@Autowired
|
||||
private ModuleButtonService buttonApi;
|
||||
@Autowired
|
||||
private ModuleColumnService columnApi;
|
||||
@Autowired
|
||||
private ModuleFormService formApi;
|
||||
@Autowired
|
||||
private ModuleDataAuthorizeSchemeService dataAuthorizeSchemeApi;
|
||||
@Autowired
|
||||
private PortalManageService portalManageApi;
|
||||
|
||||
@Override
|
||||
public AuthorizeVO getAuthorize(boolean isCache, boolean singletonOrg) {
|
||||
return getAuthorize(isCache, singletonOrg, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorizeVO getAuthorize(boolean isCache, boolean singletonOrg, boolean isMainSystem) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<UserSystemVO> standingAll = getUserStanding(false, userInfo.getUserId());
|
||||
boolean isAdmin = standingAll.stream().filter(t -> "1".equals(t.getId()) || "2".equals(t.getId())).count() > 0;
|
||||
List<UserSystemVO> userStanding = standingAll.stream().filter(t -> "2".equals(t.getId()))
|
||||
.collect(Collectors.toList());
|
||||
int stand = isAdmin ? 1 : userStanding.size() > 0 ? 2 : 3;
|
||||
return getAuthorize(userInfo, singletonOrg, stand, isMainSystem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPortal(List<SystemEntity> systemList, List<PortalModel> portalList, Long dateTime,
|
||||
List<String> collect) {
|
||||
Map<String, SystemEntity> systemBaeModelMap = systemList.stream()
|
||||
.collect(Collectors.toMap(SystemEntity::getId, Function.identity()));
|
||||
List<String> systemIds = systemList.stream().map(SystemEntity::getId).collect(Collectors.toList());
|
||||
List<PortalManagePageDO> portalManagePageDOS = portalManageApi.selectPortalBySystemIds(systemIds, collect);
|
||||
if (portalManagePageDOS.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Map<String, List<PortalManagePageDO>> systemIdAndPortalMap = portalManagePageDOS.stream()
|
||||
.collect(Collectors.groupingBy(PortalManagePageDO::getSystemId));
|
||||
if (systemIdAndPortalMap != null) {
|
||||
systemIdAndPortalMap.keySet().forEach(t -> {
|
||||
if (Optional.ofNullable(systemBaeModelMap.get(t)).isPresent()) {
|
||||
PortalModel systemModel = JsonUtil.getJsonToBean(systemBaeModelMap.get(t), PortalModel.class);
|
||||
systemModel.setParentId("-1");
|
||||
portalList.add(systemModel);
|
||||
Map<String, String> platFormId = new HashMap<>();
|
||||
List<PortalManagePageDO> portalManagePageDOList = systemIdAndPortalMap.get(t);
|
||||
Map<String, List<PortalManagePageDO>> platFormMap = portalManagePageDOList.stream()
|
||||
.collect(Collectors.groupingBy(PortalManagePageDO::getPlatform));
|
||||
List<PortalManagePageDO> web = platFormMap.get("Web");
|
||||
List<PortalManagePageDO> app = platFormMap.get("App");
|
||||
if (web != null && web.size() > 0) {
|
||||
PortalModel platForm = new PortalModel();
|
||||
platForm.setId(systemModel.getId() + "1");
|
||||
platForm.setParentId(systemModel.getId());
|
||||
platForm.setFullName("WEB门户");
|
||||
platForm.setIcon("icon-ym icon-ym-pc");
|
||||
platForm.setSortCode(0L);
|
||||
platForm.setCreatorTime(dateTime);
|
||||
platFormId.put("Web", platForm.getId());
|
||||
portalList.add(platForm);
|
||||
}
|
||||
if (app != null && app.size() > 0) {
|
||||
PortalModel platForm = new PortalModel();
|
||||
platForm.setId(systemModel.getId() + "2");
|
||||
platForm.setParentId(systemModel.getId());
|
||||
platForm.setFullName("APP门户");
|
||||
platForm.setIcon("icon-ym icon-ym-mobile");
|
||||
platForm.setSortCode(0L);
|
||||
platForm.setCreatorTime(dateTime);
|
||||
platFormId.put("App", platForm.getId());
|
||||
portalList.add(platForm);
|
||||
}
|
||||
portalManagePageDOList.forEach(pageDO -> {
|
||||
// if (!categoryList.contains(pageDO.getCategoryId())) {
|
||||
// categoryList.add(pageDO.getCategoryId());
|
||||
// PortalModel categoryModel = new PortalModel();
|
||||
// categoryModel.setId(pageDO.getCategoryId());
|
||||
// categoryModel.setParentId(platFormId.get(pageDO.getPlatform()));
|
||||
// categoryModel.setFullName(pageDO.getCategoryName());
|
||||
// categoryModel.setOnlyId(RandomUtil.uuId());
|
||||
// list.add(categoryModel);
|
||||
// }
|
||||
PortalModel model = JsonUtil.getJsonToBean(pageDO, PortalModel.class);
|
||||
// model.setParentId(pageDO.getCategoryId());
|
||||
model.setParentId(platFormId.get(pageDO.getPlatform()));
|
||||
model.setFullName(pageDO.getPortalName());
|
||||
portalList.add(model);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void saveItemAuth(SavePortalAuthModel portalAuthModel) {
|
||||
List<String> ids = portalAuthModel.getIds();
|
||||
String id = portalAuthModel.getId();
|
||||
String type = portalAuthModel.getType();
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
// 原始授权角色
|
||||
List<AuthorizeEntity> list = new ArrayList<>();
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
AuthorizeEntity authorizeEntity = new AuthorizeEntity();
|
||||
authorizeEntity.setId(RandomUtil.uuId());
|
||||
authorizeEntity.setItemType(type);
|
||||
authorizeEntity.setItemId(ids.get(i));
|
||||
authorizeEntity.setObjectType(AuthorizeConst.ROLE);
|
||||
authorizeEntity.setObjectId(id);
|
||||
authorizeEntity.setSortCode((long) i);
|
||||
authorizeEntity.setCreatorTime(new Date());
|
||||
authorizeEntity.setCreatorUserId(userId);
|
||||
list.add(authorizeEntity);
|
||||
}
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, type);
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectId, id);
|
||||
this.remove(queryWrapper);
|
||||
list.forEach(this::save);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void saveObjectAuth(SavePortalAuthModel portalAuthModel) {
|
||||
List<String> ids = portalAuthModel.getIds();
|
||||
String id = portalAuthModel.getId();
|
||||
String type = portalAuthModel.getType();
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, type);
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemId, id);
|
||||
this.remove(queryWrapper);
|
||||
|
||||
List<AuthorizeEntity> portalSystem = new ArrayList<>();
|
||||
boolean isPortal = AuthorizeConst.AUTHORIZE_PORTAL_MANAGE.equals(type);
|
||||
if (isPortal && !ids.isEmpty() && StringUtil.isNotEmpty(portalAuthModel.getSystemId())) {
|
||||
QueryWrapper<AuthorizeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(AuthorizeEntity::getItemType, AuthorizeConst.SYSTEM);
|
||||
wrapper.lambda().eq(AuthorizeEntity::getItemId, portalAuthModel.getSystemId());
|
||||
wrapper.lambda().in(AuthorizeEntity::getObjectId, ids);
|
||||
portalSystem.addAll(this.list(wrapper));
|
||||
}
|
||||
// 原始授权角色
|
||||
List<AuthorizeEntity> list = new ArrayList<>();
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
String objectId = ids.get(i);
|
||||
AuthorizeEntity authorizeEntity = new AuthorizeEntity();
|
||||
authorizeEntity.setId(RandomUtil.uuId());
|
||||
authorizeEntity.setItemType(type);
|
||||
authorizeEntity.setObjectId(objectId);
|
||||
authorizeEntity.setObjectType(AuthorizeConst.ROLE);
|
||||
authorizeEntity.setItemId(id);
|
||||
authorizeEntity.setSortCode((long) i);
|
||||
authorizeEntity.setCreatorTime(new Date());
|
||||
authorizeEntity.setCreatorUserId(userId);
|
||||
list.add(authorizeEntity);
|
||||
if (isPortal && StringUtil.isNotEmpty(portalAuthModel.getSystemId())) {
|
||||
boolean portalCount = portalSystem.stream().filter(t -> Objects.equals(t.getObjectId(), objectId))
|
||||
.count() == 0;
|
||||
if (portalCount) {
|
||||
AuthorizeEntity systemAuthorize = new AuthorizeEntity();
|
||||
systemAuthorize.setId(RandomUtil.uuId());
|
||||
systemAuthorize.setItemType(AuthorizeConst.SYSTEM);
|
||||
systemAuthorize.setObjectId(ids.get(i));
|
||||
systemAuthorize.setObjectType(AuthorizeConst.ROLE);
|
||||
systemAuthorize.setItemId(portalAuthModel.getSystemId());
|
||||
systemAuthorize.setSortCode(0l);
|
||||
systemAuthorize.setCreatorTime(new Date());
|
||||
systemAuthorize.setCreatorUserId(userId);
|
||||
list.add(systemAuthorize);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.forEach(this::save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getAuthorizeByItem(String itemType, String itemId) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, itemType);
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemId, itemId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorizeVO getAuthorizeByUser(boolean singletonOrg) {
|
||||
AuthorizeVO authorizeModel = this.getAuthorize(false, singletonOrg);
|
||||
return authorizeModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorizeVO getMainSystemAuthorize(List<String> moduleIds, List<String> moduleAuthorize,
|
||||
List<String> moduleUrlAddressAuthorize, boolean singletonOrg) {
|
||||
SystemEntity systemEntity = systemApi.getInfoByEnCode(YunzhupaasConst.MAIN_SYSTEM_CODE);
|
||||
if (systemEntity == null || moduleAuthorize.contains(systemEntity.getId())) {
|
||||
return new AuthorizeVO();
|
||||
}
|
||||
SystemBaeModel systemBaeModel = JsonUtil.getJsonToBean(systemEntity, SystemBaeModel.class);
|
||||
List<ModuleEntity> moduleList = new ArrayList<>();
|
||||
if (moduleIds.size() > 0) {
|
||||
moduleList = moduleApi.getModuleByIds(moduleIds, moduleAuthorize, moduleUrlAddressAuthorize, singletonOrg);
|
||||
} else {
|
||||
moduleList = moduleApi.getMainModule(moduleAuthorize, moduleUrlAddressAuthorize, singletonOrg);
|
||||
}
|
||||
List<ModuleModel> moduleModelList = JsonUtil.getJsonToList(moduleList, ModuleModel.class);
|
||||
List<ModuleButtonEntity> buttonByModuleId = buttonApi
|
||||
.getListByModuleIds(moduleModelList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ButtonModel> buttonJsonToList = JsonUtil.getJsonToList(buttonByModuleId, ButtonModel.class);
|
||||
|
||||
List<ModuleColumnEntity> columnByModuleId = columnApi
|
||||
.getListByModuleId(moduleModelList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ColumnModel> columnJsonToList = JsonUtil.getJsonToList(columnByModuleId, ColumnModel.class);
|
||||
|
||||
List<ModuleDataAuthorizeSchemeEntity> resourceByModuleId = dataAuthorizeSchemeApi
|
||||
.getListByModuleId(moduleModelList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ResourceModel> resourceJsonToList = JsonUtil.getJsonToList(resourceByModuleId, ResourceModel.class);
|
||||
|
||||
List<ModuleFormEntity> formByModuleId = formApi
|
||||
.getListByModuleId(moduleModelList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ModuleFormModel> formJsonToList = JsonUtil.getJsonToList(formByModuleId, ModuleFormModel.class);
|
||||
|
||||
return new AuthorizeVO(moduleModelList, buttonJsonToList, columnJsonToList, resourceJsonToList, formJsonToList,
|
||||
Collections.singletonList(systemBaeModel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByRoleIdsAndItemType(List<String> roleIds, String itemType) {
|
||||
if (roleIds.size() == 0) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, itemType);
|
||||
queryWrapper.lambda().in(AuthorizeEntity::getObjectId, roleIds);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String objectId, AuthorizeDataUpForm authorizeList) {
|
||||
SaveBatchForm form = JsonUtil.getJsonToBean(authorizeList, SaveBatchForm.class);
|
||||
form.setRoleIds(new String[] { objectId });
|
||||
this.saveBatch(form, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBatch(SaveBatchForm saveBatchForm, boolean isBatch) {
|
||||
try {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
|
||||
List<AuthorizeEntity> objectList = new ArrayList<>();
|
||||
List<AuthorizeEntity> authorizeList = new ArrayList<>();
|
||||
// 设置权限归属对象
|
||||
setEntity(saveBatchForm.getUserIds(), AuthorizeConst.USER, objectList, true);
|
||||
setEntity(saveBatchForm.getPositionIds(), AuthorizeConst.POSITION, objectList, true);
|
||||
setEntity(saveBatchForm.getRoleIds(), AuthorizeConst.ROLE, objectList, true);
|
||||
// setEntity(saveBatchForm.getSystemIds(), AuthorizeConst.SYSTEM, objectList,
|
||||
// true);
|
||||
// 设置权限模块
|
||||
setEntity(saveBatchForm.getButton(), AuthorizeConst.BUTTON, authorizeList, false);
|
||||
setEntity(saveBatchForm.getModule(), AuthorizeConst.MODULE, authorizeList, false);
|
||||
setEntity(saveBatchForm.getColumn(), AuthorizeConst.COLUMN, authorizeList, false);
|
||||
setEntity(saveBatchForm.getResource(), AuthorizeConst.RESOURCE, authorizeList, false);
|
||||
setEntity(saveBatchForm.getForm(), AuthorizeConst.FROM, authorizeList, false);
|
||||
setEntity(saveBatchForm.getSystemIds(), AuthorizeConst.SYSTEM, authorizeList, false);
|
||||
|
||||
// 移除权限缓存
|
||||
this.removeAuthByUserOrMenu(null, Arrays.asList(saveBatchForm.getModule()));
|
||||
|
||||
// 删除角色相关信息
|
||||
List<String> objectIdAll = objectList.stream().map(AuthorizeEntity::getObjectId)
|
||||
.collect(Collectors.toList());
|
||||
userService.delCurRoleUser(MsgCode.PS010.get(), objectIdAll);
|
||||
if (!isBatch) {
|
||||
String ids = String.join(",", objectIdAll);
|
||||
JdbcUtil.creUpDe(new PrepSqlDTO(
|
||||
XSSEscape.escapeEmpty(SqlFrameFastUtil.AUTHOR_DEL.replace("{authorizeIds}", ids)))
|
||||
.withConn(dataSourceUtils, null));
|
||||
}
|
||||
|
||||
// 插入数据
|
||||
String sql = DbTypeUtil.checkOracle(dataSourceUtils) || DbTypeUtil.checkPostgre(dataSourceUtils)
|
||||
? SqlFrameFastUtil.INSERT_AUTHORIZE2
|
||||
: SqlFrameFastUtil.INSERT_AUTHORIZE;
|
||||
|
||||
String column_key = StringUtil.EMPTY, column_plceholder = StringUtil.EMPTY,
|
||||
column_value = TenantDataSourceUtil.getTenantColumn();
|
||||
if (StringUtil.isNotEmpty(column_value)) {
|
||||
column_key = StrPool.COMMA + configValueUtil.getMultiTenantColumn();
|
||||
column_plceholder = ",?";
|
||||
}
|
||||
sql = sql.replace("%COLUMN_KEY%", column_key).replace("%COLUMN_PLACEHOLDER%", column_plceholder);
|
||||
PrepSqlDTO dto = new PrepSqlDTO(sql).withConn(dataSourceUtils, null);
|
||||
for (int i = 0; i < objectList.size(); i++) {
|
||||
for (AuthorizeEntity entityItem : authorizeList) {
|
||||
List<Object> data = new LinkedList<>();
|
||||
data.add(RandomUtil.uuId());
|
||||
data.add(entityItem.getItemType());
|
||||
data.add(entityItem.getItemId());
|
||||
data.add(objectList.get(i).getObjectType());
|
||||
data.add(objectList.get(i).getObjectId());
|
||||
data.add(i);
|
||||
data.add(DateUtil.getNow());
|
||||
data.add(userInfo.getUserId());
|
||||
if (StringUtil.isNotEmpty(column_value)) {
|
||||
data.add(column_value);
|
||||
}
|
||||
dto.addMultiData(data);
|
||||
}
|
||||
}
|
||||
JdbcUtil.creUpDeBatchOneSql(dto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("权限报错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
private void setEntity(String[] ids, String type, List<AuthorizeEntity> entityList, Boolean objectFlag) {
|
||||
if (ids != null) {
|
||||
for (String id : ids) {
|
||||
AuthorizeEntity entity = new AuthorizeEntity();
|
||||
if (objectFlag) {
|
||||
entity.setObjectType(type);
|
||||
entity.setObjectId(id);
|
||||
} else {
|
||||
entity.setItemType(type);
|
||||
entity.setItemId(id);
|
||||
}
|
||||
entityList.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByUserId(boolean isAdmin, String userId) {
|
||||
if (!isAdmin) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(UserRelationEntity::getUserId, userId);
|
||||
List<UserRelationEntity> list = userRelationService.list(queryWrapper);
|
||||
List<String> userRelationList = list.stream().map(u -> u.getObjectId()).collect(Collectors.toList());
|
||||
userRelationList.add(userId);
|
||||
QueryWrapper<AuthorizeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(AuthorizeEntity::getObjectId, userRelationList);
|
||||
return this.list(wrapper);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByObjectId(List<String> objectId) {
|
||||
if (objectId.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(AuthorizeEntity::getObjectId, objectId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existAuthorize(String roleId, String systemId) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectId, roleId);
|
||||
if (StringUtil.isNotEmpty(systemId)) {
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemId, systemId);
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, AuthorizeConst.SYSTEM);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByRoleId(String roleId) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectId, roleId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByObjectId(String objectId, String itemType) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectId, objectId);
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, itemType);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByObjectAndItem(String itemId, String objectType) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectType, objectType).eq(AuthorizeEntity::getItemId, itemId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorizeEntity> getListByObjectAndItemIdAndType(String itemId, String itemType) {
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getItemType, itemType).eq(AuthorizeEntity::getItemId, itemId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserSystemVO> getUserStanding(boolean isLogin, String userId) {
|
||||
return getUserStanding(isLogin, userId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserSystemVO> getUserStanding(boolean isLogin, String userId, String loginDevice) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<UserSystemVO> systemVOS = new ArrayList<>();
|
||||
UserEntity info = userService.getInfo(userId);
|
||||
String device = StringUtil.isNotEmpty(loginDevice) ? loginDevice : userInfo.getLoginDevice();
|
||||
if (DeviceType.PC.getDevice().equals(device)) {
|
||||
if (ObjectUtil.isNotEmpty(info.getStanding())) {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId(info.getStanding() + "");
|
||||
vo.setCurrentStanding(true);
|
||||
systemVOS.add(vo);
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(info.getAppStanding())) {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId(info.getAppStanding() + "");
|
||||
vo.setCurrentStanding(true);
|
||||
systemVOS.add(vo);
|
||||
}
|
||||
}
|
||||
List<OrganizeAdministratorEntity> infoByUserId = organizeAdminIsTratorService.getInfoByUserId(userId);
|
||||
if (isLogin) {
|
||||
if (infoByUserId.size() > 0) {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId("2");
|
||||
systemVOS.add(vo);
|
||||
}
|
||||
} else {
|
||||
if (systemVOS.size() == 0) {
|
||||
if (Objects.equals(info.getIsAdministrator(), 1)) {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId("1");
|
||||
systemVOS.add(vo);
|
||||
} else if (infoByUserId.size() > 0) {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId("2");
|
||||
systemVOS.add(vo);
|
||||
} else {
|
||||
UserSystemVO vo = new UserSystemVO();
|
||||
vo.setId("3");
|
||||
systemVOS.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return systemVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorizeVO getAuthorize(UserInfo userInfo, boolean singletonOrg, Integer stand, boolean isMainSystem) {
|
||||
List<ModuleModel> moduleList = new ArrayList<>();
|
||||
List<ButtonModel> buttonList = new ArrayList<>();
|
||||
List<ColumnModel> columnList = new ArrayList<>();
|
||||
List<ResourceModel> resourceList = new ArrayList<>();
|
||||
List<ModuleFormModel> formsList = new ArrayList<>();
|
||||
List<SystemBaeModel> systemList = new ArrayList<>();
|
||||
List<OrganizeAdministratorEntity> organizeAdministratorEntity = new ArrayList<>();
|
||||
boolean isAdmin = userInfo.getIsAdministrator();
|
||||
if (ObjectUtil.isNotEmpty(stand)) {
|
||||
isAdmin = Objects.equals(stand, 1);
|
||||
if (Objects.equals(stand, 2)) {
|
||||
organizeAdministratorEntity.addAll(organizeAdminIsTratorService.getInfoByUserId(userInfo.getUserId()));
|
||||
}
|
||||
}
|
||||
SystemEntity entity = systemApi.getInfoByEnCode(YunzhupaasConst.MAIN_SYSTEM_CODE);
|
||||
List<String> moduleAuthorize = new ArrayList<>();
|
||||
List<String> moduleUrlAddressAuthorize = new ArrayList<>();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantAuthorizeModel tenantAuthorizeModel = TenantDataSourceUtil
|
||||
.getCacheModuleAuthorize(userInfo.getTenantId());
|
||||
moduleAuthorize = tenantAuthorizeModel.getModuleIdList();
|
||||
moduleUrlAddressAuthorize = tenantAuthorizeModel.getUrlAddressList();
|
||||
}
|
||||
// 开发平台权限获取
|
||||
AuthorizeVO mainSystemAuthorize = new AuthorizeVO();
|
||||
if (isMainSystem) {
|
||||
if (isAdmin || organizeAdministratorEntity.size() > 0) {
|
||||
List<String> mainModuleId = new ArrayList<>();
|
||||
List<String> moduleId = organizeAdministratorEntity.stream()
|
||||
.filter(t -> PermissionConst.MODULE.equals(t.getOrganizeType()))
|
||||
.map(OrganizeAdministratorEntity::getOrganizeId).collect(Collectors.toList());
|
||||
mainModuleId.addAll(moduleId);
|
||||
if (organizeAdministratorEntity.size() > 0) {
|
||||
mainModuleId.add(YunzhupaasConst.MAIN_SYSTEM_CODE);
|
||||
}
|
||||
AuthorizeVO mainAuthorize = this.getMainSystemAuthorize(mainModuleId, moduleAuthorize,
|
||||
moduleUrlAddressAuthorize, singletonOrg);
|
||||
mainSystemAuthorize.setModuleList(mainAuthorize.getModuleList());
|
||||
mainSystemAuthorize.setButtonList(mainAuthorize.getButtonList());
|
||||
mainSystemAuthorize.setColumnList(mainAuthorize.getColumnList());
|
||||
mainSystemAuthorize.setResourceList(mainAuthorize.getResourceList());
|
||||
mainSystemAuthorize.setFormsList(mainAuthorize.getFormsList());
|
||||
if ((organizeAdministratorEntity.size() > 0 && moduleId.size() > 0) || isAdmin) {
|
||||
mainSystemAuthorize.setSystemList(mainAuthorize.getSystemList());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isAdmin) {
|
||||
if (organizeAdministratorEntity.size() > 0) {
|
||||
List<String> systemId = organizeAdministratorEntity.stream()
|
||||
.filter(t -> PermissionConst.SYSTEM.equals(t.getOrganizeType()))
|
||||
.map(OrganizeAdministratorEntity::getOrganizeId).collect(Collectors.toList());
|
||||
List<SystemEntity> systemEntities = systemApi.getListByIds(systemId, moduleAuthorize);
|
||||
List<SystemBaeModel> systemJsonToList = JsonUtil.getJsonToList(systemEntities, SystemBaeModel.class);
|
||||
systemList.addAll(systemJsonToList);
|
||||
List<String> systemIds = systemJsonToList.stream().map(SystemBaeModel::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<ModuleEntity> moduleBySystemIds = moduleApi.getModuleBySystemIds(systemIds, moduleAuthorize,
|
||||
moduleUrlAddressAuthorize);
|
||||
List<ModuleModel> moduleJsonToList = JsonUtil.getJsonToList(moduleBySystemIds, ModuleModel.class);
|
||||
moduleList.addAll(moduleJsonToList);
|
||||
List<ModuleButtonEntity> buttonByModuleId = buttonApi.getListByModuleIds(
|
||||
moduleJsonToList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ButtonModel> buttonJsonToList = JsonUtil.getJsonToList(buttonByModuleId, ButtonModel.class);
|
||||
buttonList.addAll(buttonJsonToList);
|
||||
List<ModuleColumnEntity> columnByModuleId = columnApi.getListByModuleId(
|
||||
moduleJsonToList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ColumnModel> columnJsonToList = JsonUtil.getJsonToList(columnByModuleId, ColumnModel.class);
|
||||
columnList.addAll(columnJsonToList);
|
||||
List<ModuleDataAuthorizeSchemeEntity> resourceByModuleId = dataAuthorizeSchemeApi.getListByModuleId(
|
||||
moduleJsonToList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ResourceModel> resourceJsonToList = JsonUtil.getJsonToList(resourceByModuleId,
|
||||
ResourceModel.class);
|
||||
resourceList.addAll(resourceJsonToList);
|
||||
List<ModuleFormEntity> formByModuleId = formApi.getListByModuleId(
|
||||
moduleJsonToList.stream().map(ModuleModel::getId).collect(Collectors.toList()));
|
||||
List<ModuleFormModel> formJsonToList = JsonUtil.getJsonToList(formByModuleId, ModuleFormModel.class);
|
||||
formsList.addAll(formJsonToList);
|
||||
} else {
|
||||
List<String> roleIdList = new ArrayList<>();
|
||||
permissionGroupService
|
||||
.getPermissionGroupByUserId(userInfo.getUserId(), userInfo.getOrganizeId(), true, null)
|
||||
.forEach(t -> {
|
||||
roleIdList.add(t.getId());
|
||||
});
|
||||
List<AuthorizeEntity> authorizeList = new ArrayList<>();
|
||||
if (roleIdList.size() > 0) {
|
||||
QueryWrapper<AuthorizeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(AuthorizeEntity::getObjectId, roleIdList);
|
||||
authorizeList = this.list(wrapper);
|
||||
}
|
||||
// 应用
|
||||
List<String> systemId = authorizeList.stream()
|
||||
.filter(t -> AuthorizeConst.SYSTEM.equals(t.getItemType())).map(AuthorizeEntity::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
systemId.remove(entity.getId());
|
||||
if (systemId.size() > 0) {
|
||||
List<SystemEntity> systemAdmin = systemApi.getListByIds(systemId, moduleAuthorize);
|
||||
systemList = JsonUtil.getJsonToList(systemAdmin, SystemBaeModel.class);
|
||||
systemId = systemAdmin.stream().map(SystemEntity::getId).collect(Collectors.toList());
|
||||
}
|
||||
// 菜单 无开发平台
|
||||
List<String> moduleId = authorizeList.stream()
|
||||
.filter(t -> AuthorizeConst.MODULE.equals(t.getItemType())).map(AuthorizeEntity::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
if (moduleId.size() > 0 && systemId.size() > 0) {
|
||||
moduleList = this.baseMapper.findModule(moduleId, systemId, moduleAuthorize,
|
||||
moduleUrlAddressAuthorize, singletonOrg ? 0 : 1, YunzhupaasConst.MODULE_CODE);
|
||||
}
|
||||
// 按钮
|
||||
List<String> buttonId = authorizeList.stream()
|
||||
.filter(t -> AuthorizeConst.BUTTON.equals(t.getItemType())).map(AuthorizeEntity::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
if (buttonId.size() > 0) {
|
||||
buttonList = this.baseMapper.findButton(buttonId);
|
||||
}
|
||||
// 列表
|
||||
List<String> columnId = authorizeList.stream()
|
||||
.filter(t -> AuthorizeConst.COLUMN.equals(t.getItemType())).map(AuthorizeEntity::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
if (columnId.size() > 0) {
|
||||
columnList = this.baseMapper.findColumn(columnId);
|
||||
}
|
||||
// 数据
|
||||
List<String> resourceId = authorizeList.stream()
|
||||
.filter(t -> AuthorizeConst.RESOURCE.equals(t.getItemType())).map(AuthorizeEntity::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
if (resourceId.size() > 0) {
|
||||
resourceList = this.baseMapper.findResource(resourceId);
|
||||
}
|
||||
// 表单
|
||||
List<String> formId = authorizeList.stream().filter(t -> AuthorizeConst.FROM.equals(t.getItemType()))
|
||||
.map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
if (formId.size() > 0) {
|
||||
formsList = this.baseMapper.findForms(formId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buttonList = this.baseMapper.findButtonAdmin(1);
|
||||
columnList = this.baseMapper.findColumnAdmin(1);
|
||||
resourceList = this.baseMapper.findResourceAdmin(1);
|
||||
formsList = this.baseMapper.findFormsAdmin(1);
|
||||
List<SystemEntity> systemAdmin = systemApi.findSystemAdmin(singletonOrg ? 0 : 1,
|
||||
YunzhupaasConst.MAIN_SYSTEM_CODE, moduleAuthorize);
|
||||
systemList = JsonUtil.getJsonToList(systemAdmin, SystemBaeModel.class);
|
||||
List<String> systemId = systemList.stream().map(SystemBaeModel::getId).collect(Collectors.toList());
|
||||
List<ModuleEntity> moduleAdmin = moduleApi.findModuleAdmin(singletonOrg ? 0 : 1, entity.getId(),
|
||||
moduleAuthorize, moduleUrlAddressAuthorize);
|
||||
moduleList = JsonUtil.getJsonToList(moduleAdmin, ModuleModel.class).stream()
|
||||
.filter(t -> systemId.contains(t.getSystemId())).collect(Collectors.toList());
|
||||
}
|
||||
systemList.addAll(mainSystemAuthorize.getSystemList());
|
||||
moduleList.addAll(mainSystemAuthorize.getModuleList());
|
||||
buttonList.addAll(mainSystemAuthorize.getButtonList());
|
||||
columnList.addAll(mainSystemAuthorize.getColumnList());
|
||||
resourceList.addAll(mainSystemAuthorize.getResourceList());
|
||||
formsList.addAll(mainSystemAuthorize.getFormsList());
|
||||
return new AuthorizeVO(moduleList, buttonList, columnList, resourceList, formsList, systemList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("")
|
||||
public List<SuperJsonModel> getConditionSql(String moduleId) {
|
||||
List<SuperJsonModel> list = new ArrayList<>();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
String reidsKey = cacheKeyUtil.getUserAuthorize() + moduleId + "_" + userInfo.getUserId();
|
||||
long time = 60 * 5;
|
||||
if (redisUtil.exists(reidsKey)) {
|
||||
return JsonUtil.getJsonToList(redisUtil.getString(reidsKey).toString(), SuperJsonModel.class);
|
||||
}
|
||||
|
||||
AuthorizeVO model = this.getAuthorizeByUser(false);
|
||||
if (model == null) {
|
||||
redisUtil.insert(reidsKey, JsonUtil.getObjectToString(new ArrayList<>()), time);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<ResourceModel> resourceListAll = model.getResourceList().stream()
|
||||
.filter(m -> m.getModuleId().equals(moduleId)).collect(Collectors.toList());
|
||||
// 先遍历一次 查找其中有没有全部方案
|
||||
boolean isAll = resourceListAll.stream().filter(item -> "yunzhupaas_alldata".equals(item.getEnCode())
|
||||
|| item.getEnCode().startsWith("yunzhupaas_alldata")).count() > 0;
|
||||
// 未分配权限方案
|
||||
if (isAll || userInfo.getIsAdministrator()) {
|
||||
SuperJsonModel superJsonModel = new SuperJsonModel();
|
||||
list.add(superJsonModel);
|
||||
redisUtil.insert(reidsKey, JsonUtil.getObjectToString(list), time);
|
||||
return list;
|
||||
}
|
||||
Map<String, List<ResourceModel>> authorizeMap = resourceListAll.stream()
|
||||
.filter(t -> StringUtil.isNotEmpty(t.getObjectId()))
|
||||
.collect(Collectors.groupingBy(ma -> ma.getObjectId()));
|
||||
int num = 0;
|
||||
// 方案
|
||||
for (String key : authorizeMap.keySet()) {
|
||||
List<ResourceModel> resourceList = authorizeMap.get(key);
|
||||
boolean authorizeLogic = num == 0;
|
||||
for (ResourceModel item : resourceList) {
|
||||
String matchLogic = StringUtil.isNotEmpty(item.getMatchLogic()) ? item.getMatchLogic()
|
||||
: SearchMethodEnum.And.getSymbol();
|
||||
List<SuperQueryJsonModel> conditionList = new ArrayList<>();
|
||||
List<ConditionModel> conditionModelList = JsonUtil.getJsonToList(item.getConditionJson(),
|
||||
ConditionModel.class);
|
||||
// 分组
|
||||
for (ConditionModel conditionModel : conditionModelList) {
|
||||
String logic = conditionModel.getLogic();
|
||||
List<FieLdsModel> groupList = new ArrayList<>();
|
||||
// 条件
|
||||
for (ConditionModel.ConditionItemModel fieldItem : conditionModel.getGroups()) {
|
||||
SearchMethodEnum itemMethod = SearchMethodEnum.getSearchMethod(fieldItem.getOp());
|
||||
String itemField = fieldItem.getField();
|
||||
String table = fieldItem.getBindTable();
|
||||
if (itemField.contains(".") && itemField.split("\\.").length == 2) {
|
||||
table = itemField.split("\\.")[0];
|
||||
itemField = itemField.split("\\.")[1];
|
||||
}
|
||||
String bindTable = table;
|
||||
String vModel = itemField;
|
||||
String fileId = "";
|
||||
FieLdsModel fieLdsModel = new FieLdsModel();
|
||||
ConfigModel config = new ConfigModel();
|
||||
String yunzhupaasKey = fieldItem.getConditionText();
|
||||
if (AuthorizeConditionEnum.CURRENTTIME.getCondition().equals(yunzhupaasKey)) {
|
||||
yunzhupaasKey = AuthorizeConst.DATE_PICKER;
|
||||
}
|
||||
switch (fieldItem.getFieldRule()) {
|
||||
case "1":
|
||||
fileId = "yunzhupaas_" + bindTable + "_yunzhupaas_" + vModel;
|
||||
break;
|
||||
case "2":
|
||||
fileId = fieldItem.getChildTableKey() + "-" + vModel;
|
||||
break;
|
||||
default:
|
||||
fileId = vModel;
|
||||
break;
|
||||
}
|
||||
|
||||
config.setYunzhupaasKey(yunzhupaasKey);
|
||||
config.setTableName(bindTable);
|
||||
fieLdsModel.setConfig(config);
|
||||
fieLdsModel.setSymbol(itemMethod.getSymbol());
|
||||
fieLdsModel.setVModel(vModel);
|
||||
fieLdsModel.setId(fileId);
|
||||
fieLdsModel.setFieldValue(fieldItem.getValue());
|
||||
groupList.add(fieLdsModel);
|
||||
}
|
||||
// 搜索条件
|
||||
SuperQueryJsonModel queryJsonModel = new SuperQueryJsonModel();
|
||||
queryJsonModel.setGroups(groupList);
|
||||
queryJsonModel.setLogic(logic);
|
||||
conditionList.add(queryJsonModel);
|
||||
}
|
||||
if (conditionList.size() > 0) {
|
||||
SuperJsonModel superJsonModel = new SuperJsonModel();
|
||||
superJsonModel.setMatchLogic(matchLogic);
|
||||
superJsonModel.setConditionList(conditionList);
|
||||
superJsonModel.setAuthorizeLogic(authorizeLogic);
|
||||
list.add(superJsonModel);
|
||||
}
|
||||
}
|
||||
num += list.size() > 0 ? 1 : 0;
|
||||
}
|
||||
redisUtil.insert(reidsKey, JsonUtil.getObjectToString(list), time);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAuthByUserOrMenu(List<String> userIds, List<String> menuIds) {
|
||||
userIds = userIds == null ? new ArrayList<>() : userIds;
|
||||
menuIds = menuIds == null ? new ArrayList<>() : menuIds;
|
||||
Set<String> allKeys = redisUtil.getAllKeys();
|
||||
for (String cacheKey : allKeys) {
|
||||
for (String user : userIds) {
|
||||
if (cacheKey.startsWith(cacheKeyUtil.getUserAuthorize()) && cacheKey.contains(user)) {
|
||||
redisUtil.remove(cacheKey);
|
||||
}
|
||||
}
|
||||
for (String menuId : menuIds) {
|
||||
if (cacheKey.startsWith(cacheKeyUtil.getUserAuthorize()) && cacheKey.contains(menuId)) {
|
||||
redisUtil.remove(cacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUserCurrentStanding(String userId, Integer standType) {
|
||||
if (UserProvider.getUser() == null || UserProvider.getUser().getUserId() == null)
|
||||
return false;
|
||||
List<UserSystemVO> userStanding = this.getUserStanding(false, UserProvider.getUser().getUserId());
|
||||
if (standType != null && userStanding.stream().anyMatch(t -> standType.toString().equals(t.getId()))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.permission.entity.ColumnsPurviewEntity;
|
||||
import com.yunzhupaas.permission.mapper.ColumnsPurviewMapper;
|
||||
import com.yunzhupaas.permission.service.ColumnsPurviewService;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 模块列表权限业务实现类
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/15 9:40
|
||||
*/
|
||||
@Service
|
||||
public class ColumnsPurviewServiceImpl extends SuperServiceImpl<ColumnsPurviewMapper, ColumnsPurviewEntity> implements ColumnsPurviewService {
|
||||
|
||||
@Override
|
||||
public ColumnsPurviewEntity getInfo(String moduleId) {
|
||||
QueryWrapper<ColumnsPurviewEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ColumnsPurviewEntity::getModuleId, moduleId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String moduleId, ColumnsPurviewEntity entity) {
|
||||
ColumnsPurviewEntity entitys = getInfo(moduleId);
|
||||
// id不存在则是保存
|
||||
if (entitys == null) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
return this.save(entity);
|
||||
} else {
|
||||
// 修改
|
||||
entity.setId(entitys.getId());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
entity.setLastModifyTime(DateUtil.getNowDate());
|
||||
}
|
||||
return this.saveOrUpdate(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.permission.entity.GroupEntity;
|
||||
import com.yunzhupaas.permission.entity.PositionEntity;
|
||||
import com.yunzhupaas.permission.mapper.GroupMapper;
|
||||
import com.yunzhupaas.permission.model.usergroup.PaginationGroup;
|
||||
import com.yunzhupaas.permission.service.GroupService;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 分组管理业务类实现类
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/10 18:00
|
||||
*/
|
||||
@Service
|
||||
public class GroupServiceImpl extends SuperServiceImpl<GroupMapper, GroupEntity> implements GroupService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<GroupEntity> getList(PaginationGroup pagination) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
// 定义变量判断是否需要使用修改时间倒序
|
||||
boolean flag = false;
|
||||
// 判断关键字
|
||||
String keyword = pagination.getKeyword();
|
||||
if (StringUtil.isNotEmpty(keyword)) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(GroupEntity::getFullName, keyword)
|
||||
.or().like(GroupEntity::getEnCode, keyword)
|
||||
.or().like(GroupEntity::getDescription, keyword)
|
||||
);
|
||||
}
|
||||
if (pagination.getEnabledMark() != null) {
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnabledMark, pagination.getEnabledMark());
|
||||
}
|
||||
if (StringUtil.isNotEmpty(pagination.getType())) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().eq(GroupEntity::getType, pagination.getType());
|
||||
}
|
||||
// 获取列表
|
||||
queryWrapper.lambda().orderByAsc(GroupEntity::getSortCode).orderByDesc(GroupEntity::getCreatorTime);
|
||||
if (flag) {
|
||||
queryWrapper.lambda().orderByDesc(GroupEntity::getLastModifyTime);
|
||||
}
|
||||
Page<GroupEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<GroupEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GroupEntity> list() {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnabledMark, 1);
|
||||
queryWrapper.lambda().orderByAsc(GroupEntity::getSortCode).orderByDesc(GroupEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getGroupMap() {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(GroupEntity::getId,GroupEntity::getFullName);
|
||||
return this.list(queryWrapper).stream().collect(Collectors.toMap(GroupEntity::getId,GroupEntity::getFullName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getGroupEncodeMap() {
|
||||
return getGroupEncodeMap(false);
|
||||
}
|
||||
@Override
|
||||
public Map<String, Object> getGroupEncodeMap(boolean enabledMark) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
if(enabledMark){
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnabledMark,1);
|
||||
}
|
||||
queryWrapper.lambda().select(GroupEntity::getId,GroupEntity::getFullName,GroupEntity::getEnCode);
|
||||
return this.list(queryWrapper).stream().collect(Collectors.toMap(group->group.getFullName() + "/" + group.getEnCode(),GroupEntity::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupEntity getInfo(String id) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(GroupEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupEntity getInfo(String fullName,String enCode) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(GroupEntity::getFullName, fullName);
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnCode, enCode);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void crete(GroupEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, GroupEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
entity.setLastModifyTime(DateUtil.getNowDate());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(GroupEntity entity) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(GroupEntity::getFullName, fullName);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(GroupEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByEnCode(String enCode, String id) {
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnCode, enCode);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(GroupEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GroupEntity> getListByIds(List<String> list, Boolean filterEnabledMark) {
|
||||
if (list.isEmpty()) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
QueryWrapper<GroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(GroupEntity::getId, list);
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(GroupEntity::getEnabledMark, 1);
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yunzhupaas.base.entity.ModuleEntity;
|
||||
import com.yunzhupaas.base.entity.SystemEntity;
|
||||
import com.yunzhupaas.base.service.DbLinkService;
|
||||
import com.yunzhupaas.base.service.ModuleService;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.service.SystemService;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.YunzhupaasConst;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.database.model.dto.PrepSqlDTO;
|
||||
import com.yunzhupaas.database.sql.util.SqlFrameFastUtil;
|
||||
import com.yunzhupaas.database.util.DataSourceUtil;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.database.util.DbTypeUtil;
|
||||
import com.yunzhupaas.database.util.JdbcUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.model.login.UserSystemVO;
|
||||
import com.yunzhupaas.model.tenant.TenantAuthorizeModel;
|
||||
import com.yunzhupaas.permission.entity.OrganizeAdministratorEntity;
|
||||
import com.yunzhupaas.permission.entity.OrganizeEntity;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.mapper.OrganizeAdminIsTratorMapper;
|
||||
import com.yunzhupaas.permission.model.organizeadministrator.OrganizeAdministratorListVo;
|
||||
import com.yunzhupaas.permission.model.organizeadministrator.OrganizeAdministratorModel;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 机构分级管理员
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Service
|
||||
public class OrganizeAdministratorServiceImpl
|
||||
extends SuperServiceImpl<OrganizeAdminIsTratorMapper, OrganizeAdministratorEntity>
|
||||
implements OrganizeAdministratorService {
|
||||
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private DbLinkService dbLinkService;
|
||||
@Autowired
|
||||
private SystemService systemApi;
|
||||
@Autowired
|
||||
private ModuleService moduleApi;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
private DataSourceUtil dataSourceUtils;
|
||||
|
||||
@Override
|
||||
public OrganizeAdministratorEntity getOne(String userId, String organizeId) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getOrganizeId, organizeId);
|
||||
// 排序
|
||||
queryWrapper.lambda().orderByAsc(OrganizeAdministratorEntity::getSortCode)
|
||||
.orderByDesc(OrganizeAdministratorEntity::getCreatorTime);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorEntity> getOrganizeAdministratorEntity(String userId) {
|
||||
return getOrganizeAdministratorEntity(userId, PermissionConst.ORGANIZE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorEntity> getOrganizeAdministratorEntity(String userId, String type,
|
||||
boolean filterMain) {
|
||||
List<OrganizeAdministratorEntity> list = new ArrayList<>();
|
||||
UserEntity entity1 = userService.getInfo(userId);
|
||||
List<UserSystemVO> userStanding = authorizeService.getUserStanding(false, entity1.getId());
|
||||
boolean isAdmin = userStanding.stream().filter(t -> "1".equals(t.getId())).count() > 0;
|
||||
// 查询非组织权限
|
||||
if ((entity1 != null && isAdmin) && !PermissionConst.ORGANIZE.equals(type)) {
|
||||
List<String> collect = new ArrayList<>();
|
||||
List<String> moduleAuthorize = new ArrayList<>();
|
||||
List<String> moduleUrlAddressAuthorize = new ArrayList<>();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantAuthorizeModel tenantAuthorizeModel = TenantDataSourceUtil
|
||||
.getCacheModuleAuthorize(UserProvider.getUser().getTenantId());
|
||||
moduleAuthorize = tenantAuthorizeModel.getModuleIdList();
|
||||
moduleUrlAddressAuthorize = tenantAuthorizeModel.getUrlAddressList();
|
||||
}
|
||||
if (PermissionConst.SYSTEM.equals(type)) {
|
||||
collect = systemApi.getList(null, false, false, filterMain, false, moduleAuthorize).stream()
|
||||
.map(SystemEntity::getId).collect(Collectors.toList());
|
||||
} else if (PermissionConst.MODULE.equals(type)) {
|
||||
collect = moduleApi.getList(false, moduleAuthorize, moduleUrlAddressAuthorize).stream()
|
||||
.map(ModuleEntity::getId).collect(Collectors.toList());
|
||||
}
|
||||
for (String t : collect) {
|
||||
OrganizeAdministratorEntity entity = new OrganizeAdministratorEntity();
|
||||
entity.setOrganizeId(t);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setOrganizeType(type);
|
||||
entity.setUserId(userId);
|
||||
list.add(entity);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
// 组织权限
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (PermissionConst.ORGANIZE.equals(type)) {
|
||||
queryWrapper.lambda().isNull(OrganizeAdministratorEntity::getOrganizeType);
|
||||
} else if (StringUtil.isNotEmpty(type)) {
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getOrganizeType, type);
|
||||
}
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
// 排序
|
||||
queryWrapper.lambda().orderByAsc(OrganizeAdministratorEntity::getSortCode)
|
||||
.orderByDesc(OrganizeAdministratorEntity::getCreatorTime);
|
||||
list = this.list(queryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorEntity> getOrganizeAdministratorEntity(String userId, String type) {
|
||||
// 组织权限
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (PermissionConst.ORGANIZE.equals(type)) {
|
||||
queryWrapper.lambda().isNull(OrganizeAdministratorEntity::getOrganizeType);
|
||||
} else if (StringUtil.isNotEmpty(type)) {
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getOrganizeType, type);
|
||||
}
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
// 排序
|
||||
queryWrapper.lambda().orderByAsc(OrganizeAdministratorEntity::getSortCode)
|
||||
.orderByDesc(OrganizeAdministratorEntity::getCreatorTime);
|
||||
List<OrganizeAdministratorEntity> list = this.list(queryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void create(OrganizeAdministratorEntity entity) {
|
||||
// 判断是新建还是删除
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getOrganizeId, entity.getOrganizeId());
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, entity.getUserId());
|
||||
// 查出数据是否重复
|
||||
OrganizeAdministratorEntity administratorEntity = this.getOne(queryWrapper);
|
||||
if (administratorEntity == null) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setCreatorUserId(UserProvider.getLoginUserId());
|
||||
entity.setCreatorTime(new Date());
|
||||
} else {
|
||||
entity.setId(administratorEntity.getId());
|
||||
entity.setCreatorUserId(UserProvider.getLoginUserId());
|
||||
entity.setLastModifyTime(new Date());
|
||||
}
|
||||
this.saveOrUpdate(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createList(List<OrganizeAdministratorEntity> list, String userId) {
|
||||
// QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new
|
||||
// QueryWrapper<>();
|
||||
// queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId,userId);
|
||||
// queryWrapper.lambda().select(OrganizeAdministratorEntity::getCreatorTime);
|
||||
// IPage<OrganizeAdministratorEntity> list1 = this.page(new Page<>(1, 1),
|
||||
// queryWrapper);
|
||||
// boolean isData = !list1.getRecords().isEmpty() &&
|
||||
// ObjectUtil.isNotEmpty(list1.getRecords().get(0).getCreatorTime());
|
||||
// Date creatorTime = isData?list1.getRecords().get(0).getCreatorTime():new
|
||||
// Date();
|
||||
// this.remove(queryWrapper);
|
||||
// for (OrganizeAdministratorEntity entity : list) {
|
||||
// entity.setCreatorTime(creatorTime);
|
||||
// this.save(entity);
|
||||
// }
|
||||
// userService.delCurUser(MsgCode.PS010.get(), ImmutableList.of(userId),2);
|
||||
try {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
Page<OrganizeAdministratorEntity> page = new Page<>(1, 1);
|
||||
IPage<OrganizeAdministratorEntity> list1 = this.page(page, queryWrapper);
|
||||
boolean isData = !list1.getRecords().isEmpty()
|
||||
&& ObjectUtil.isNotEmpty(list1.getRecords().get(0).getCreatorTime());
|
||||
String now = isData ? DateUtil.dateFormat(list1.getRecords().get(0).getCreatorTime()) : DateUtil.getNow();
|
||||
JdbcUtil.creUpDe(new PrepSqlDTO(
|
||||
XSSEscape.escapeEmpty(SqlFrameFastUtil.ADMINISTRATOR_DEL.replace("{userId}", userId)))
|
||||
.withConn(dataSourceUtils, null));
|
||||
String sql = DbTypeUtil.checkOracle(dataSourceUtils) || DbTypeUtil.checkPostgre(dataSourceUtils)
|
||||
? SqlFrameFastUtil.INSERT_ADMINISTRATOR2
|
||||
: SqlFrameFastUtil.INSERT_ADMINISTRATOR;
|
||||
String column_key = StringUtil.EMPTY, column_plceholder = StringUtil.EMPTY,
|
||||
column_value = TenantDataSourceUtil.getTenantColumn();
|
||||
if (StringUtil.isNotEmpty(column_value)) {
|
||||
column_key = StrPool.COMMA + configValueUtil.getMultiTenantColumn();
|
||||
column_plceholder = ",?";
|
||||
}
|
||||
sql = sql.replace("%COLUMN_KEY%", column_key).replace("%COLUMN_PLACEHOLDER%", column_plceholder);
|
||||
PrepSqlDTO dto = new PrepSqlDTO(sql).withConn(dataSourceUtils, null);
|
||||
|
||||
for (OrganizeAdministratorEntity entity : list) {
|
||||
List<Object> data = new LinkedList<>();
|
||||
data.add(RandomUtil.uuId());
|
||||
data.add(userId);
|
||||
data.add(entity.getOrganizeId());
|
||||
data.add(entity.getOrganizeType());
|
||||
data.add(entity.getThisLayerAdd());
|
||||
data.add(entity.getThisLayerEdit());
|
||||
data.add(entity.getThisLayerDelete());
|
||||
data.add(entity.getSubLayerAdd());
|
||||
data.add(entity.getSubLayerEdit());
|
||||
data.add(entity.getSubLayerDelete());
|
||||
data.add(entity.getThisLayerSelect());
|
||||
data.add(entity.getSubLayerSelect());
|
||||
data.add(entity.getManagerGroup());
|
||||
data.add(now);
|
||||
data.add(UserProvider.getLoginUserId());
|
||||
data.add(1);
|
||||
if (StringUtil.isNotEmpty(column_value)) {
|
||||
data.add(column_value);
|
||||
}
|
||||
dto.addMultiData(data);
|
||||
}
|
||||
JdbcUtil.creUpDeBatchOneSql(dto);
|
||||
userService.delCurUser(MsgCode.PS010.get(), ImmutableList.of(userId), 2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("分级报错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String organizeId, OrganizeAdministratorEntity entity) {
|
||||
entity.setId(entity.getId());
|
||||
entity.setLastModifyTime(DateUtil.getNowDate());
|
||||
entity.setLastModifyUserId(UserProvider.getLoginUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteByUserId(String userId) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
boolean remove = this.remove(queryWrapper);
|
||||
userService.delCurUser(MsgCode.PS010.get(), ImmutableList.of(userId), 2);
|
||||
userService.updateStand(ImmutableList.of(userId), 2);
|
||||
return remove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorEntity> getInfoByUserId(String userId) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getEnabledMark, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizeAdministratorEntity getInfo(String id) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(OrganizeAdministratorEntity entity) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagerGroupByUserId(String userId) {
|
||||
if (StringUtil.isEmpty(userId)) {
|
||||
return null;
|
||||
}
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getUserId, userId);
|
||||
List<OrganizeAdministratorEntity> list = this.list(queryWrapper);
|
||||
return list.size() > 0 ? list.get(0).getManagerGroup() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizeAdministratorEntity getInfoByOrganizeId(String organizeId) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OrganizeAdministratorEntity::getOrganizeId, organizeId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorEntity> getListByOrganizeId(List<String> organizeIdList) {
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(OrganizeAdministratorEntity::getOrganizeId, organizeIdList);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeAdministratorListVo> getList(Pagination pagination) {
|
||||
List<OrganizeAdministratorEntity> list = getOrganizeAdministratorEntity(UserProvider.getLoginUserId(),
|
||||
PermissionConst.ORGANIZE, false);
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
List<String> organizeIdList;
|
||||
Map<String, OrganizeEntity> orgMaps = organizeService.getOrgMaps(null, true, null);
|
||||
// 存放所有的有资格管理的组织id
|
||||
if (UserProvider.getUser().getIsAdministrator()) {
|
||||
organizeIdList = new ArrayList<>(orgMaps.keySet());
|
||||
} else {
|
||||
Set<String> orgId = new HashSet<>(16);
|
||||
// 判断自己是哪些组织的管理员
|
||||
list.stream().forEach(t -> {
|
||||
if (t != null) {
|
||||
// t.getThisLayerAdd() == 1 || t.getThisLayerEdit() == 1 ||
|
||||
// t.getThisLayerDelete() == 1 ||
|
||||
// (StringUtil.isNotEmpty(String.valueOf(t.getSubLayerSelect())) &&
|
||||
// t.getThisLayerSelect() == 1)
|
||||
if (t.getSubLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
orgId.add(t.getOrganizeId());
|
||||
}
|
||||
// t.getSubLayerAdd() == 1 || t.getSubLayerEdit() == 1 || t.getSubLayerDelete()
|
||||
// == 1 || (StringUtil.isNotEmpty(String.valueOf(t.getSubLayerSelect())) &&
|
||||
// t.getSubLayerSelect() == 1)
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(),
|
||||
true);
|
||||
orgId.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
});
|
||||
organizeIdList = new ArrayList<>(orgId);
|
||||
}
|
||||
if (organizeIdList.size() < 1) {
|
||||
organizeIdList.add("");
|
||||
}
|
||||
List<OrganizeAdministratorListVo> jsonToList = new ArrayList<>();
|
||||
List<List<String>> organizeList = Lists.partition(organizeIdList, 1000);
|
||||
List<String> userId = new ArrayList<>();
|
||||
for (List<String> objectId : organizeList) {
|
||||
userId.addAll(userRelationService.getListByOrgId(objectId).stream().map(UserRelationEntity::getUserId)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
userId.remove(UserProvider.getUser().getUserId());
|
||||
if (userId.isEmpty()) {
|
||||
return jsonToList;
|
||||
}
|
||||
|
||||
QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
|
||||
userWrapper.lambda().select(UserEntity::getId, UserEntity::getAccount, UserEntity::getRealName,
|
||||
UserEntity::getGender, UserEntity::getMobilePhone);
|
||||
userWrapper.lambda().in(UserEntity::getId, userId);
|
||||
userWrapper.lambda().eq(UserEntity::getEnabledMark, 1);
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
userWrapper.lambda().and(
|
||||
t -> t.like(UserEntity::getRealName, pagination.getKeyword())
|
||||
.or().like(UserEntity::getAccount, pagination.getKeyword())
|
||||
.or().like(UserEntity::getMobilePhone, pagination.getKeyword()));
|
||||
}
|
||||
List<UserEntity> userList = userService.list(userWrapper);
|
||||
if (userList.isEmpty()) {
|
||||
return jsonToList;
|
||||
}
|
||||
|
||||
QueryWrapper<OrganizeAdministratorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().isNotNull(OrganizeAdministratorEntity::getManagerGroup);
|
||||
queryWrapper.lambda().select(OrganizeAdministratorEntity::getUserId,
|
||||
OrganizeAdministratorEntity::getCreatorTime, OrganizeAdministratorEntity::getManagerGroup);
|
||||
queryWrapper.lambda().in(OrganizeAdministratorEntity::getUserId,
|
||||
userList.stream().map(UserEntity::getId).collect(Collectors.toList()));
|
||||
queryWrapper.lambda().orderByDesc(OrganizeAdministratorEntity::getCreatorTime);
|
||||
List<OrganizeAdministratorEntity> entityList = this.list(queryWrapper);
|
||||
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (OrganizeAdministratorEntity entity : entityList) {
|
||||
if (!ids.contains(entity.getUserId())) {
|
||||
ids.add(entity.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
List listPage = PageUtil.getListPage((int) pagination.getCurrentPage(), (int) pagination.getPageSize(), ids);
|
||||
if (!listPage.isEmpty()) {
|
||||
List<OrganizeAdministratorEntity> organizeAdminList = entityList.stream()
|
||||
.filter(t -> listPage.contains(t.getUserId())).distinct()
|
||||
.sorted(Comparator.comparing(OrganizeAdministratorEntity::getCreatorTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
for (OrganizeAdministratorEntity entity : organizeAdminList) {
|
||||
UserEntity info = userList.stream().filter(t -> t.getId().equals(entity.getUserId())).findFirst()
|
||||
.orElse(null);
|
||||
if (info != null) {
|
||||
OrganizeAdministratorListVo vo = JsonUtil.getJsonToBean(info, OrganizeAdministratorListVo.class);
|
||||
// 所属组织
|
||||
List<UserRelationEntity> orgRelationByUserId = userRelationService
|
||||
.getAllOrgRelationByUserId(entity.getUserId());
|
||||
StringBuilder orgName = new StringBuilder();
|
||||
orgRelationByUserId.stream().forEach(or -> {
|
||||
OrganizeEntity organizeEntity = orgMaps.get(or.getObjectId());
|
||||
if (organizeEntity != null && StringUtil.isNotEmpty(organizeEntity.getOrganizeIdTree())) {
|
||||
String fullNameByOrgIdTree = organizeService.getFullNameByOrgIdTree(orgIdNameMaps,
|
||||
organizeEntity.getOrganizeIdTree(), "/");
|
||||
orgName.append("," + fullNameByOrgIdTree);
|
||||
}
|
||||
});
|
||||
// 组织名称
|
||||
String org = orgName.length() > 0 ? orgName.toString().replaceFirst(",", "") : "";
|
||||
vo.setOrganizeId(org);
|
||||
vo.setManagerGroup(entity.getManagerGroup());
|
||||
vo.setCreatorTime(entity.getCreatorTime().getTime());
|
||||
jsonToList.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pagination.setData(jsonToList, ids.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrganizeUserList(String type) {
|
||||
if (UserProvider.getUser().getIsAdministrator()) {
|
||||
return organizeService.getList(true).stream().map(OrganizeEntity::getId).collect(Collectors.toList());
|
||||
}
|
||||
List<OrganizeAdministratorEntity> list = getOrganizeAdministratorEntity(UserProvider.getLoginUserId());
|
||||
Set<String> orgId = new HashSet<>(16);
|
||||
// 判断自己是哪些组织的管理员
|
||||
list.stream().forEach(t -> {
|
||||
if (t != null) {
|
||||
if (t.getSubLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
orgId.add(t.getOrganizeId());
|
||||
}
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), true);
|
||||
orgId.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
});
|
||||
List<String> orgIds = new ArrayList<>(orgId);
|
||||
if (YunzhupaasConst.CURRENT_ORG_SUB.equals(type)) {
|
||||
return orgIds;
|
||||
}
|
||||
List<String> userList = userRelationService.getListByObjectIdAll(orgIds).stream()
|
||||
.map(UserRelationEntity::getUserId).collect(Collectors.toList());
|
||||
return userList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeEntity> getListByAuthorize() {
|
||||
// 通过权限转树
|
||||
List<OrganizeAdministratorEntity> listss = getOrganizeAdministratorEntity(UserProvider.getLoginUserId());
|
||||
Set<String> orgIds = new HashSet<>(16);
|
||||
// 判断自己是哪些组织的管理员
|
||||
listss.stream().forEach(t -> {
|
||||
if (t != null) {
|
||||
if (t.getThisLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
orgIds.add(t.getOrganizeId());
|
||||
}
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), true);
|
||||
orgIds.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
});
|
||||
List<String> list1 = new ArrayList<>(orgIds);
|
||||
// 得到所有有权限的组织
|
||||
List<OrganizeEntity> organizeName = organizeService.getOrganizeName(list1);
|
||||
return organizeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizeAdministratorModel getOrganizeAdministratorList() {
|
||||
// 通过权限转树
|
||||
List<OrganizeAdministratorEntity> list = getOrganizeAdministratorEntity(UserProvider.getUser().getUserId());
|
||||
List<String> addList = new ArrayList<>();
|
||||
List<String> editList = new ArrayList<>();
|
||||
List<String> deleteList = new ArrayList<>();
|
||||
List<String> selectList = new ArrayList<>();
|
||||
// 判断自己是哪些组织的管理员
|
||||
list.forEach(t -> {
|
||||
if (t != null) {
|
||||
// 查询
|
||||
if (t.getThisLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
selectList.add(t.getOrganizeId());
|
||||
// 修改
|
||||
if (t.getThisLayerEdit() != null && t.getThisLayerEdit() == 1) {
|
||||
editList.add(t.getOrganizeId());
|
||||
}
|
||||
// 删除
|
||||
if (t.getThisLayerDelete() != null && t.getThisLayerDelete() == 1) {
|
||||
deleteList.add(t.getOrganizeId());
|
||||
}
|
||||
// 新增
|
||||
if (t.getThisLayerAdd() != null && t.getThisLayerAdd() == 1) {
|
||||
addList.add(t.getOrganizeId());
|
||||
}
|
||||
}
|
||||
// 查询
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), false);
|
||||
selectList.addAll(underOrganizations);
|
||||
// 修改
|
||||
if (t.getSubLayerEdit() != null && t.getSubLayerEdit() == 1) {
|
||||
editList.addAll(underOrganizations);
|
||||
}
|
||||
// 删除
|
||||
if (t.getSubLayerDelete() != null && t.getSubLayerDelete() == 1) {
|
||||
deleteList.addAll(underOrganizations);
|
||||
}
|
||||
// 新增
|
||||
if (t.getSubLayerAdd() != null && t.getSubLayerAdd() == 1) {
|
||||
addList.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
OrganizeAdministratorModel model = new OrganizeAdministratorModel(addList, editList, deleteList, selectList);
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.constant.YunzhupaasConst;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.mapper.OrganizeRelationMapper;
|
||||
import com.yunzhupaas.permission.model.organize.OrganizeConditionModel;
|
||||
import com.yunzhupaas.permission.model.organize.OrganizeModel;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织关系 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @since 2022-01-19
|
||||
*/
|
||||
@Service
|
||||
public class OrganizeRelationServiceImpl extends SuperServiceImpl<OrganizeRelationMapper, OrganizeRelationEntity>
|
||||
implements OrganizeRelationService {
|
||||
|
||||
@Autowired
|
||||
RoleService roleService;
|
||||
@Autowired
|
||||
PositionService positionService;
|
||||
@Autowired
|
||||
UserRelationService userRelationService;
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
OrganizeService organizeService;
|
||||
@Autowired
|
||||
OrganizeAdministratorService organizeAdministratorService;
|
||||
@Autowired
|
||||
PermissionGroupService permissionGroupService;
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByOrganizeId(List<String> organizeIds) {
|
||||
if (organizeIds.isEmpty()) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeIds);
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByOrganizeId(List<String> organizeIds, String objectType) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
if (StringUtil.isNotEmpty(objectType)) {
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, objectType);
|
||||
}
|
||||
if (organizeIds.size() > 0) {
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeIds);
|
||||
} else {
|
||||
organizeIds.add("");
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeIds);
|
||||
}
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPositionListByOrganizeId(List<String> organizeIds) {
|
||||
if (organizeIds.size() > 0) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.POSITION);
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeIds);
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query).stream().map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByRoleId(String roleId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.ROLE);
|
||||
query.lambda().in(OrganizeRelationEntity::getObjectId, roleId);
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByRoleIdList(List<String> roleId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.ROLE);
|
||||
query.lambda().in(OrganizeRelationEntity::getObjectId, roleId);
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByObjectIdAndType(String objectType, String objectId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectId, objectId);
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, objectType);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existByRoleIdAndOrgId(String roleId, String organizeId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.ROLE);
|
||||
query.lambda().in(OrganizeRelationEntity::getObjectId, roleId);
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeId);
|
||||
return count(query) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existByObjTypeAndOrgId(String objectType, String organizeId) {
|
||||
return existByObjAndOrgId(objectType, null, organizeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existByObjAndOrgId(String objectType, String objId, String organizeId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, objectType);
|
||||
if (StringUtil.isNotEmpty(objId)) {
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectId, objId);
|
||||
}
|
||||
query.lambda().in(OrganizeRelationEntity::getOrganizeId, organizeId);
|
||||
return count(query) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getRelationListByType(String objectType) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, objectType);
|
||||
query.lambda().orderByDesc(OrganizeRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeRelationEntity> getListByTypeAndOrgId(String objectType, String orgId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
// 查询组织关系表集合
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, objectType)
|
||||
.eq(OrganizeRelationEntity::getOrganizeId, orgId);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteAllByRoleId(String roleId) {
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.ROLE);
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectId, roleId);
|
||||
return this.remove(query);
|
||||
}
|
||||
|
||||
/* ========================== 自动切换岗位,组织相关 ============================== */
|
||||
|
||||
@Override
|
||||
public String autoGetMajorPositionId(String userId, String currentMajorOrgId, String currentMajorPosId) {
|
||||
// 属于该该组织底下的岗位
|
||||
List<PositionEntity> positionList = positionService.getListByOrgIdAndUserId(currentMajorOrgId, userId);
|
||||
if (positionList.size() > 0) {
|
||||
// 默认岗位是否在此组织内,若存在不做切换
|
||||
if (positionList.stream().anyMatch(p -> p.getId().equals(currentMajorPosId))) {
|
||||
return currentMajorPosId;
|
||||
} else {
|
||||
// 默认第一个岗位
|
||||
return positionList.get(0).getId();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String autoGetMajorOrganizeId(String userId, List<String> userAllOrgIds, String currentMajorOrgId,
|
||||
String systemId) {
|
||||
if (userAllOrgIds.size() > 0) {
|
||||
if (userAllOrgIds.contains(currentMajorOrgId)
|
||||
&& checkBasePermission(userId, currentMajorOrgId, systemId).size() > 0) {
|
||||
// 保持原默认组织不切换
|
||||
return currentMajorOrgId;
|
||||
} else {
|
||||
// 去除原本默认组织ID
|
||||
List<String> selectOrgIds = userAllOrgIds.stream().filter(usi -> !usi.equals(currentMajorOrgId))
|
||||
.collect(Collectors.toList());
|
||||
// 若不存在,强制切换有基本登录权限的角色
|
||||
for (String orgId : selectOrgIds) {
|
||||
if (this.checkBasePermission(userId, orgId, systemId).size() > 0) {
|
||||
// 这个组织ID底下角色存在基础登录权限
|
||||
return orgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 随机赋值一个
|
||||
return userAllOrgIds.get(0);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/* == 自动key.equals == */
|
||||
|
||||
@Override
|
||||
public void autoSetOrganize(List<String> allUpdateUserIds) {
|
||||
if (allUpdateUserIds.size() > 0) {
|
||||
for (UserEntity userEntity : userService.listByIds(allUpdateUserIds)) {
|
||||
String useId = userEntity.getId();
|
||||
String majorOrgId = userEntity.getOrganizeId();
|
||||
List<String> orgList = userRelationService.getListByObjectType(useId, PermissionConst.ORGANIZE)
|
||||
.stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
String changeOrgId = this.autoGetMajorOrganizeId(useId, orgList, majorOrgId, null);
|
||||
if (!changeOrgId.equals(majorOrgId)) {
|
||||
// 切换默认组织
|
||||
UserEntity updateUserEntity = new UserEntity();
|
||||
updateUserEntity.setId(useId);
|
||||
updateUserEntity.setOrganizeId(changeOrgId);
|
||||
userService.updateById(updateUserEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoSetPosition(List<String> allUpdateUserIds) {
|
||||
if (allUpdateUserIds.size() > 0) {
|
||||
for (UserEntity user : userService.listByIds(allUpdateUserIds)) {
|
||||
String majorPosId = user.getPositionId();
|
||||
String changePositionId = this.autoGetMajorPositionId(user.getId(), user.getOrganizeId(), majorPosId);
|
||||
if (!changePositionId.equals(majorPosId)) {
|
||||
UserEntity updateUser = new UserEntity();
|
||||
updateUser.setId(user.getId());
|
||||
updateUser.setPositionId(changePositionId);
|
||||
userService.updateById(updateUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ===================== 权限判断 ======================= */
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> checkBasePermission(String userId, String orgId, String systemId) {
|
||||
List<PermissionGroupEntity> permissionGroupByUserId = permissionGroupService.getPermissionGroupByUserId(userId,
|
||||
orgId, false, systemId);
|
||||
return permissionGroupByUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrgIds(List<String> departIds, String type) {
|
||||
List<String> idList = new ArrayList<>(16);
|
||||
// 获取所有组织
|
||||
if (departIds.size() > 0) {
|
||||
List<String> collect = departIds.stream().filter(YunzhupaasConst.SYSTEM_PARAM.keySet()::contains)
|
||||
.collect(Collectors.toList());
|
||||
String organizeId = UserProvider.getUser().getOrganizeId();
|
||||
collect.forEach(t -> {
|
||||
if (YunzhupaasConst.CURRENT_ORG.equals(t) || YunzhupaasConst.CURRENT_ORG_TYPE.equals(t)) {
|
||||
idList.add(organizeId + "--" + com.yunzhupaas.constant.PermissionConst.COMPANY);
|
||||
idList.add(organizeId);
|
||||
} else if (YunzhupaasConst.CURRENT_ORG_SUB.equals(t)
|
||||
|| YunzhupaasConst.CURRENT_ORG_SUB_TYPE.equals(t)) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(organizeId, true);
|
||||
underOrganizations.add(organizeId);
|
||||
underOrganizations.forEach(orgId -> {
|
||||
idList.add(orgId + "--" + com.yunzhupaas.constant.PermissionConst.COMPANY);
|
||||
idList.add(orgId);
|
||||
});
|
||||
} else if (YunzhupaasConst.CURRENT_GRADE.equals(t) || YunzhupaasConst.CURRENT_GRADE_TYPE.equals(t)) {
|
||||
List<String> organizeUserList = organizeAdministratorService
|
||||
.getOrganizeUserList(YunzhupaasConst.CURRENT_ORG_SUB);
|
||||
organizeUserList.forEach(orgId -> {
|
||||
idList.add(orgId + "--" + com.yunzhupaas.constant.PermissionConst.COMPANY);
|
||||
idList.add(orgId);
|
||||
});
|
||||
}
|
||||
});
|
||||
departIds.removeAll(collect);
|
||||
idList.addAll(departIds);
|
||||
for (String departId : departIds) {
|
||||
String[] split = departId.split("--");
|
||||
if (split.length == 1 || split.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (split.length > 1) {
|
||||
if (com.yunzhupaas.constant.PermissionConst.ORGANIZE.equals(split[1])) {
|
||||
departId = split[0];
|
||||
}
|
||||
if (com.yunzhupaas.constant.PermissionConst.DEPARTMENT.equals(split[1])) {
|
||||
departId = split[0];
|
||||
}
|
||||
}
|
||||
if (!com.yunzhupaas.constant.PermissionConst.ROLE.equals(type)) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(departId, true);
|
||||
if (underOrganizations.size() > 0) {
|
||||
idList.addAll(underOrganizations);
|
||||
idList.add(organizeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return idList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrganizeModel> getOrgIdsList(OrganizeConditionModel organizeConditionModel) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
List<String> orgIds = getOrgIds(organizeConditionModel.getDepartIds(), null);
|
||||
Map<String, String> orgIdNameMaps = Optional.ofNullable(organizeConditionModel.getOrgIdNameMaps())
|
||||
.orElse(organizeService.getInfoList());
|
||||
orgIds.forEach(t -> ids.add(t.split("--")[0]));
|
||||
List<OrganizeEntity> listAll = organizeService.getListAll(ids, organizeConditionModel.getKeyword());
|
||||
List<OrganizeModel> organizeList = JsonUtil.getJsonToList(listAll, OrganizeModel.class);
|
||||
organizeList.forEach(t -> {
|
||||
t.setIcon("department".equals(t.getType()) ? "icon-ym icon-ym-tree-department1"
|
||||
: "icon-ym icon-ym-tree-organization3");
|
||||
t.setLastFullName(t.getFullName());
|
||||
if (StringUtil.isNotEmpty(t.getOrganizeIdTree())) {
|
||||
t.setOrganizeIds(Arrays.asList(t.getOrganizeIdTree().split(",")));
|
||||
t.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, t.getOrganizeIdTree(), "/"));
|
||||
String[] split = t.getOrganizeIdTree().split(",");
|
||||
List<String> list = Arrays.asList(split);
|
||||
Collections.reverse(list);
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
String orgId = list.get(i);
|
||||
List<OrganizeModel> collect1 = organizeList.stream().filter(tt -> orgId.equals(tt.getId()))
|
||||
.collect(Collectors.toList());
|
||||
if (collect1.size() > 0) {
|
||||
String[] split1 = StringUtil.isNotEmpty(t.getOrganizeIdTree())
|
||||
? t.getOrganizeIdTree().split(orgId)
|
||||
: new String[0];
|
||||
if (split1.length > 0) {
|
||||
t.setFullName(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, split1[1], "/"));
|
||||
}
|
||||
t.setOrganize(
|
||||
organizeService.getFullNameByOrgIdTree(orgIdNameMaps, t.getOrganizeIdTree(), "/"));
|
||||
t.setParentId(orgId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return organizeList;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,590 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.message.util.SynThirdConsts;
|
||||
import com.yunzhupaas.permission.constant.AuthorizeConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.mapper.PermissionGroupMapper;
|
||||
import com.yunzhupaas.permission.model.permissiongroup.PaginationPermissionGroup;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.type.AuthorizeType;
|
||||
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.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PermissionGroupServiceImpl extends SuperServiceImpl<PermissionGroupMapper, PermissionGroupEntity> implements PermissionGroupService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private OrganizeRelationService organizeRelationService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private PositionService positionService;
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> list(PaginationPermissionGroup pagination) {
|
||||
boolean flag = false;
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
String keyword = pagination.getKeyword();
|
||||
if (StringUtil.isNotEmpty(keyword)) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(PermissionGroupEntity::getFullName, keyword)
|
||||
.or().like(PermissionGroupEntity::getEnCode, keyword)
|
||||
.or().like(PermissionGroupEntity::getDescription, keyword)
|
||||
);
|
||||
}
|
||||
if (pagination.getEnabledMark() != null) {
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getEnabledMark, pagination.getEnabledMark());
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(PermissionGroupEntity::getSortCode).orderByDesc(PermissionGroupEntity::getCreatorTime);
|
||||
if (flag) {
|
||||
queryWrapper.lambda().orderByDesc(PermissionGroupEntity::getLastModifyTime);
|
||||
}
|
||||
Page<PermissionGroupEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<PermissionGroupEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> list(boolean filterEnabledMark, List<String> ids) {
|
||||
if (ids != null && ids.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getEnabledMark, 1);
|
||||
}
|
||||
if (ids != null && ids.size() > 0) {
|
||||
queryWrapper.lambda().in(PermissionGroupEntity::getId, ids);
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionGroupEntity info(String id) {
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(PermissionGroupEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, PermissionGroupEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(PermissionGroupEntity entity) {
|
||||
return this.removeById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(String id, PermissionGroupEntity entity) {
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getFullName, entity.getFullName());
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
queryWrapper.lambda().ne(PermissionGroupEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(String id, PermissionGroupEntity entity) {
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getEnCode, entity.getEnCode());
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
queryWrapper.lambda().ne(PermissionGroupEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionGroupEntity permissionMember(String id) {
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getId, id);
|
||||
queryWrapper.lambda().select(PermissionGroupEntity::getId, PermissionGroupEntity::getPermissionMember);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> getPermissionGroupByUserId(String userId, String organizeId, boolean singletonOrg, String systemId) {
|
||||
List<PermissionGroupEntity> list = new ArrayList<>();
|
||||
// 用户本身有没有权限
|
||||
UserEntity userEntity = userService.getInfo(userId);
|
||||
if (userEntity == null) {
|
||||
return list;
|
||||
}
|
||||
List<PermissionGroupEntity> allGroupList = this.list(true, null).stream().filter(t -> Objects.equals(0,t.getType())).collect(Collectors.toList());
|
||||
allGroupList.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
list.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
List<PermissionGroupEntity> permissionGroupEntities = this.list(true, null).stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).collect(Collectors.toList());
|
||||
String finalUserId = userId + "--" + PermissionConst.USER;
|
||||
List<PermissionGroupEntity> collect = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(finalUserId)).collect(Collectors.toList());
|
||||
collect.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
list.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
// 用户关系表
|
||||
List<UserRelationEntity> listByUserId = userRelationService.getListByUserId(userEntity.getId()).stream().filter(r -> StringUtil.isNotEmpty(r.getObjectId())).collect(Collectors.toList());
|
||||
// 分组有没有权限
|
||||
List<String> groupIds = new ArrayList<>();
|
||||
List<String> groupId = listByUserId.stream().filter(t -> PermissionConst.GROUP.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> groupName = groupService.getListByIds(groupId, true)
|
||||
.stream().map(GroupEntity::getId).collect(Collectors.toList());
|
||||
groupName.forEach(t -> groupIds.add(t + "--group"));
|
||||
for (String id : groupIds) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id)).collect(Collectors.toList());
|
||||
collect1.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
list.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 全局角色如果有权限
|
||||
List<String> roleAllList = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> globalList = roleService.getGlobalList(roleAllList)
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());
|
||||
for (String id : globalList) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream()
|
||||
.filter(entity -> entity.getPermissionMember().contains(id + "--role")).collect(Collectors.toList());
|
||||
collect1.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
list.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 组织有权限
|
||||
List<String> organizeIds = new ArrayList<>();
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
if(list.size() > 0) {
|
||||
// 当前组织及组织下岗位、角色权限组
|
||||
organizeIds.add(userEntity.getOrganizeId());
|
||||
} else {
|
||||
// 此情况下不找
|
||||
if (StringUtil.isNotEmpty(organizeId)) {
|
||||
organizeIds.add(organizeId);
|
||||
} else {
|
||||
// 找到一个有权限的组织、岗位、角色
|
||||
List<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(userId, PermissionConst.ORGANIZE);
|
||||
List<String> collect2 = listByObjectType.stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
organizeIds.addAll(collect2);
|
||||
organizeIds.add(userEntity.getOrganizeId());
|
||||
}
|
||||
}
|
||||
// 拼上后缀
|
||||
if (organizeIds.size() > 0) {
|
||||
List<String> collect1 = new ArrayList<>();
|
||||
collect1.addAll(organizeService.getOrgEntityList(organizeIds, true)
|
||||
.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
|
||||
orgIds.addAll(collect1);
|
||||
collect1.forEach(t -> {
|
||||
orgIds.add(t + "--" + PermissionConst.COMPANY);
|
||||
orgIds.add(t + "--" + PermissionConst.DEPARTMENT);
|
||||
});
|
||||
}
|
||||
List<OrganizeRelationEntity> relationListByOrganizeId = organizeRelationService.getRelationListByOrganizeId(organizeIds);
|
||||
List<PermissionGroupEntity> orgList = new ArrayList<>();
|
||||
List<PositionEntity> listByOrganizeId = positionService.getListByOrganizeId(orgIds, false);
|
||||
for (String oId : orgIds) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(oId)).collect(Collectors.toList());
|
||||
collect1.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
orgList.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
|
||||
// 判断该组织下的岗位是否有权限
|
||||
List<String> positionListByTypeAndOrgId = listByOrganizeId.stream().filter(t -> t.getOrganizeId().equals(oId))
|
||||
.map(PositionEntity::getId).collect(Collectors.toList());
|
||||
List<String> positionId = listByUserId.stream().filter(t -> PermissionConst.POSITION.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> containsPosition = positionListByTypeAndOrgId.stream().filter(positionId::contains).collect(Collectors.toList());
|
||||
List<String> positionName = positionService.getPositionName(containsPosition, true)
|
||||
.stream().map(PositionEntity::getId).collect(Collectors.toList());
|
||||
for (String id : positionName) {
|
||||
List<PermissionGroupEntity> collect2 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id + "--position")).collect(Collectors.toList());
|
||||
collect2.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
orgList.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 判断该组织下的角色是否有权限
|
||||
List<String> roleListByTypeAndOrgId = relationListByOrganizeId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> roleId = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<RoleEntity> roleName = roleService.getListByIds(roleId, null, true)
|
||||
.stream().filter(t -> t.getGlobalMark() != 1).collect(Collectors.toList());
|
||||
List<String> containsRole = roleName.stream().filter(t -> roleListByTypeAndOrgId.contains(t.getId())).collect(Collectors.toList())
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());;
|
||||
for (String id : containsRole) {
|
||||
List<PermissionGroupEntity> collect2 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id + "--role")).collect(Collectors.toList());
|
||||
collect2.forEach(permissionGroupEntity -> {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), systemId)) {
|
||||
orgList.add(permissionGroupEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (orgList.size() > 0) {
|
||||
if (!singletonOrg) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(orgList);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionGroupByUserId(String userId) {
|
||||
// 用户本身有没有权限
|
||||
UserEntity userEntity = userService.getInfo(userId);
|
||||
if (userEntity == null) {
|
||||
return "";
|
||||
}
|
||||
List<PermissionGroupEntity> allGroupList = this.list(true, null).stream().filter(t -> Objects.equals(0,t.getType())).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : allGroupList) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
List<PermissionGroupEntity> permissionGroupEntities = this.list(true, null).stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).collect(Collectors.toList());
|
||||
String finalUserId = userId + "--" + PermissionConst.USER;
|
||||
List<PermissionGroupEntity> collect = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(finalUserId)).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// 用户关系表
|
||||
List<UserRelationEntity> listByUserId = userRelationService.getListByUserId(userEntity.getId());
|
||||
// 分组有没有权限
|
||||
List<String> groupIds = new ArrayList<>();
|
||||
List<String> groupId = listByUserId.stream().filter(t -> PermissionConst.GROUP.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> groupName = groupService.getListByIds(groupId, true)
|
||||
.stream().map(GroupEntity::getId).collect(Collectors.toList());
|
||||
groupName.forEach(t -> groupIds.add(t + "--group"));
|
||||
for (String id : groupIds) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id)).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect1) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
// 全局角色如果有权限
|
||||
List<String> roleAllList = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> globalList = roleService.getGlobalList(roleAllList)
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());
|
||||
for (String id : globalList) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream()
|
||||
.filter(entity -> entity.getPermissionMember().contains(id + "--role")).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect1) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 组织有权限
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
List<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(userId, PermissionConst.ORGANIZE);
|
||||
List<String> collect2 = new ArrayList<>();
|
||||
collect2.add(userEntity.getOrganizeId());
|
||||
collect2.addAll(listByObjectType.stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList()));
|
||||
orgIds.addAll(collect2);
|
||||
collect2.forEach(t -> {
|
||||
orgIds.add(t + "--" + PermissionConst.COMPANY);
|
||||
orgIds.add(t + "--" + PermissionConst.DEPARTMENT);
|
||||
});
|
||||
List<OrganizeRelationEntity> relationListByOrganizeId = organizeRelationService.getRelationListByOrganizeId(collect2);
|
||||
List<PositionEntity> listByOrganizeId = positionService.getListByOrganizeId(orgIds, false);
|
||||
for (String orgId : orgIds) {
|
||||
List<PermissionGroupEntity> collect1 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(orgId)).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect1) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return orgId.split("--")[0];
|
||||
}
|
||||
}
|
||||
// 判断该组织下的岗位是否有权限
|
||||
List<String> positionListByTypeAndOrgId = listByOrganizeId.stream().filter(t -> t.getOrganizeId().equals(orgId))
|
||||
.map(PositionEntity::getId).collect(Collectors.toList());
|
||||
List<String> positionId = listByUserId.stream().filter(t -> PermissionConst.POSITION.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> containsPosition = positionListByTypeAndOrgId.stream().filter(positionId::contains).collect(Collectors.toList());
|
||||
List<String> positionName = positionService.getPositionName(containsPosition, true)
|
||||
.stream().map(PositionEntity::getId).collect(Collectors.toList());
|
||||
for (String id : positionName) {
|
||||
List<PermissionGroupEntity> collect3 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id + "--position")).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect3) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return orgId.split("--")[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断该组织下的角色是否有权限
|
||||
List<String> roleListByTypeAndOrgId = relationListByOrganizeId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> roleId = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<RoleEntity> roleName = roleService.getListByIds(roleId, null, true)
|
||||
.stream().filter(t -> t.getGlobalMark() != 1).collect(Collectors.toList());
|
||||
List<String> containsRole = roleName.stream().filter(t -> roleListByTypeAndOrgId.contains(t.getId())).collect(Collectors.toList())
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());;
|
||||
for (String id : containsRole) {
|
||||
List<PermissionGroupEntity> collect3 = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(id + "--role")).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity permissionGroupEntity : collect3) {
|
||||
if (authorizeService.existAuthorize(permissionGroupEntity.getId(), null)) {
|
||||
return orgId.split("--")[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgIdByUserIdAndSystemId(String userId, String systemId) {
|
||||
// 用户本身有没有权限
|
||||
UserEntity userEntity = userService.getInfo(userId);
|
||||
if (userEntity == null) {
|
||||
return "";
|
||||
}
|
||||
// 判断有这个应用的权限组有哪些
|
||||
List<String> collect = authorizeService.getListByObjectAndItemIdAndType(systemId, PermissionConst.SYSTEM).stream().map(AuthorizeEntity::getObjectId).collect(Collectors.toList());
|
||||
List<PermissionGroupEntity> list = this.list(true, collect).stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).collect(Collectors.toList());
|
||||
List<PermissionGroupEntity> allGroupList = this.list(true, collect).stream().filter(t -> Objects.equals(0,t.getType())).collect(Collectors.toList());
|
||||
if(allGroupList.size()>0){
|
||||
return "";
|
||||
}
|
||||
|
||||
List<String> objectIds = new ArrayList<>();
|
||||
objectIds.add(userId + "--" + PermissionConst.USER);
|
||||
// 用户关系
|
||||
List<UserRelationEntity> listByUserId = userRelationService.getListByUserId(userEntity.getId())
|
||||
.stream().filter(t -> userId.equals(t.getUserId())).collect(Collectors.toList());
|
||||
// 分组
|
||||
List<String> groupId = listByUserId.stream().filter(t -> PermissionConst.GROUP.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> groupName = groupService.getListByIds(groupId, true)
|
||||
.stream().map(GroupEntity::getId).collect(Collectors.toList());
|
||||
groupName.forEach(t -> {
|
||||
objectIds.add(t + "--group");
|
||||
});
|
||||
// 角色
|
||||
List<String> roleAllList = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> globalList = roleService.getGlobalList(roleAllList)
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());
|
||||
globalList.forEach(t -> {
|
||||
objectIds.add(t + "--role");
|
||||
});
|
||||
for (String objectId : objectIds) {
|
||||
List<PermissionGroupEntity> collect1 = list.stream().filter(t -> t.getPermissionMember().contains(objectId)).collect(Collectors.toList());
|
||||
if (collect1.size() > 0) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// 组织
|
||||
List<String> orgIds = listByUserId.stream().filter(t -> PermissionConst.ORGANIZE.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<OrganizeEntity> orgEntityList = organizeService.getOrgEntityList(orgIds, true);
|
||||
List<PositionEntity> listByOrganizeId = positionService.getListByOrganizeId(orgIds, false);
|
||||
List<OrganizeRelationEntity> relationListByOrganizeId = organizeRelationService.getRelationListByOrganizeId(orgEntityList.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
|
||||
for (OrganizeEntity organizeEntity : orgEntityList) {
|
||||
List<PermissionGroupEntity> collect1 = list.stream().filter(entity -> entity.getPermissionMember().contains(organizeEntity.getId())).collect(Collectors.toList());
|
||||
if (collect1.size() > 0) {
|
||||
return organizeEntity.getId();
|
||||
}
|
||||
// 角色
|
||||
List<String> roleListByTypeAndOrgId = relationListByOrganizeId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> roleId = listByUserId.stream().filter(t -> PermissionConst.ROLE.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<RoleEntity> roleName = roleService.getListByIds(roleId, null, true)
|
||||
.stream().filter(t -> t.getGlobalMark() != 1).collect(Collectors.toList());
|
||||
List<String> containsRole = roleName.stream().filter(t -> roleListByTypeAndOrgId.contains(t.getId())).collect(Collectors.toList())
|
||||
.stream().map(RoleEntity::getId).collect(Collectors.toList());
|
||||
for (String containsId : containsRole) {
|
||||
if (list.stream().anyMatch(entity -> entity.getPermissionMember().contains(containsId))) {
|
||||
return organizeEntity.getId();
|
||||
}
|
||||
}
|
||||
// 岗位
|
||||
List<String> positionListByTypeAndOrgId = listByOrganizeId.stream().filter(t -> t.getOrganizeId().equals(organizeEntity.getId()))
|
||||
.map(PositionEntity::getId).collect(Collectors.toList());
|
||||
List<String> positionId = listByUserId.stream().filter(t -> PermissionConst.POSITION.equals(t.getObjectType()))
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<String> containsPosition = positionListByTypeAndOrgId.stream().filter(positionId::contains).collect(Collectors.toList());
|
||||
List<String> positionName = positionService.getPositionName(containsPosition, true)
|
||||
.stream().map(PositionEntity::getId).collect(Collectors.toList());
|
||||
for (String containsId : positionName) {
|
||||
if (list.stream().anyMatch(entity -> entity.getPermissionMember().contains(containsId))) {
|
||||
return organizeEntity.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> getPermissionGroupAllByUserId(String userId) {
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().like(PermissionGroupEntity::getPermissionMember, userId);
|
||||
queryWrapper.lambda().eq(PermissionGroupEntity::getEnabledMark, 1);
|
||||
return this.list(queryWrapper);
|
||||
// UserEntity userEntity = userService.getInfo(userId);
|
||||
// // 通过用户id获取相关的组织、部门、岗位、角色、分组
|
||||
// if (userEntity == null) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
// if (userEntity.getIsAdministrator() == 1) {
|
||||
// return this.list(true, null);
|
||||
// }
|
||||
// Set<String> objIds = new HashSet<>();
|
||||
//
|
||||
// // 用户与组织关系
|
||||
// List<String> orgIds = new ArrayList<>();
|
||||
// List<String> orgId = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.ORGANIZE).stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
// orgId.forEach(t -> orgIds.add(t + "--" + PermissionConst.ORGANIZE));
|
||||
// // 用户与岗位关系
|
||||
// List<String> positionIds = new ArrayList<>();
|
||||
// List<String> positionId = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.POSITION).stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
// positionId.forEach(t -> positionIds.add(t + "--" + PermissionConst.POSITION));
|
||||
// // 用户与角色关系
|
||||
// List<String> roleIds = new ArrayList<>();
|
||||
// List<String> roleId = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.ROLE).stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
// roleId.forEach(t -> roleIds.add(t + "--" + PermissionConst.ROLE));
|
||||
// // 用户与跟分组关系
|
||||
// List<String> groupIds = new ArrayList<>();
|
||||
// List<String> groupId = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.GROUP).stream().map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
// groupId.forEach(t -> groupIds.add(t + "--" + PermissionConst.GROUP));
|
||||
//
|
||||
// objIds.addAll(orgIds);
|
||||
// objIds.addAll(positionIds);
|
||||
// objIds.addAll(roleIds);
|
||||
// objIds.addAll(groupIds);
|
||||
//
|
||||
// Set<String> permissionGroupIds = new HashSet<>();
|
||||
//
|
||||
// List<PermissionGroupEntity> permissionGroupEntities = this.list(true, null);
|
||||
// objIds.forEach(objId -> {
|
||||
// List<PermissionGroupEntity> collect = permissionGroupEntities.stream().filter(entity -> entity.getPermissionMember().contains(objId)).collect(Collectors.toList());
|
||||
// if (collect.size() > 0) {
|
||||
// permissionGroupIds.addAll(collect.stream().map(PermissionGroupEntity::getId).collect(Collectors.toList()));
|
||||
// }
|
||||
// });
|
||||
// return this.list(true, new ArrayList<>(permissionGroupIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateByUser(String fromId, String toId, List<String> permissionList) {
|
||||
if (StringUtil.isEmpty(fromId)) {
|
||||
return false;
|
||||
}
|
||||
String fromIds = fromId + "--" + PermissionConst.USER;
|
||||
List<PermissionGroupEntity> permissionGroupAllByUserId = this.getPermissionGroupAllByUserId(fromId);
|
||||
permissionGroupAllByUserId.forEach(t -> {
|
||||
if (permissionList.contains(t.getId())) {
|
||||
t.setPermissionMember(StringUtil.isNotEmpty(t.getPermissionMember()) ? t.getPermissionMember().replaceAll(fromIds, toId + "--" + PermissionConst.USER) : "");
|
||||
this.updateById(t);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> getPermissionGroupByModuleId(String moduleId) {
|
||||
// 获取到菜单和权限组的关系
|
||||
List<AuthorizeEntity> authorizeEntityList = authorizeService.getListByObjectAndItem(moduleId, AuthorizeType.MODULE);
|
||||
// 获取权限组信息
|
||||
List<PermissionGroupEntity> list = this.list(true,
|
||||
authorizeEntityList.stream().map(AuthorizeEntity::getObjectId).collect(Collectors.toList()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> list(List<String> ids) {
|
||||
if (ids.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<PermissionGroupEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PermissionGroupEntity::getId, ids);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionGroupEntity> getPermissionGroupByObjectId(String objectId, String objectType) {
|
||||
List<PermissionGroupEntity> permissionGroupEntities = this.list(true, null).stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).collect(Collectors.toList());
|
||||
String id = objectId + "--" + objectType;
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
if (AuthorizeConst.USER.equalsIgnoreCase(objectType)) {
|
||||
List<UserRelationEntity> allOrgRelationByUserId = userRelationService.getListByObjectType(objectId,null);
|
||||
for (UserRelationEntity item : allOrgRelationByUserId) {
|
||||
String oType = item.getObjectType();
|
||||
if (PermissionConst.ORGANIZE.equals(oType)) {
|
||||
oType = PermissionConst.COMPANY;
|
||||
idList.add(item.getObjectId() + "--" + PermissionConst.DEPARTMENT);
|
||||
}
|
||||
idList.add(item.getObjectId() + "--" + oType.toLowerCase());
|
||||
}
|
||||
}
|
||||
List<PermissionGroupEntity> collect = permissionGroupEntities.stream().filter(entity -> {
|
||||
boolean hashOperations = false;
|
||||
for (String s : idList) {
|
||||
if (entity.getPermissionMember().contains(s)) {
|
||||
hashOperations = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hashOperations;
|
||||
}).collect(Collectors.toList());
|
||||
List<PermissionGroupEntity> allGroupList = this.list(true, null).stream().filter(t -> Objects.equals(0,t.getType())).collect(Collectors.toList());
|
||||
for (PermissionGroupEntity entity : allGroupList) {
|
||||
if(!collect.contains(entity)) {
|
||||
collect.add(entity);
|
||||
}
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,484 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.model.permission.PermissionModel;
|
||||
import com.yunzhupaas.permission.model.position.PaginationPosition;
|
||||
import com.yunzhupaas.permission.mapper.PositionMapper;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 岗位信息
|
||||
*
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Service
|
||||
public class PositionServiceImpl extends SuperServiceImpl<PositionMapper, PositionEntity> implements PositionService {
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private CacheKeyUtil cacheKeyUtil;
|
||||
@Autowired
|
||||
private OrganizeRelationService organizeRelationService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private OrganizeAdministratorService organizeAdministratorService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getList(boolean filterEnabledMark) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark, 1);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(PositionEntity::getSortCode).orderByDesc(PositionEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getPosList(List<String> idList) {
|
||||
if (idList.size()>0){
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PositionEntity::getId,idList).select(PositionEntity::getId,PositionEntity::getFullName, PositionEntity::getEnabledMark);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getPosList(Set<String> idList) {
|
||||
if (idList.size()>0){
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().orderByAsc(PositionEntity::getSortCode).orderByDesc(PositionEntity::getCreatorTime);
|
||||
queryWrapper.lambda().select(PositionEntity::getId,PositionEntity::getFullName).in(PositionEntity::getId,idList);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPosMap() {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(PositionEntity::getId,PositionEntity::getFullName);
|
||||
return this.list(queryWrapper).stream().collect(Collectors.toMap(PositionEntity::getId,PositionEntity::getFullName,(p1, p2) -> p1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPosEncodeAndName() {
|
||||
return getPosEncodeAndName(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPosEncodeAndName(boolean enabledMark) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
if(enabledMark){
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark,1);
|
||||
}
|
||||
queryWrapper.lambda().select(PositionEntity::getId,PositionEntity::getFullName,PositionEntity::getEnCode);
|
||||
return this.list(queryWrapper).stream().collect(Collectors.toMap(p->p.getFullName() + "/" + p.getEnCode(),PositionEntity::getId,(p1, p2) -> p1));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getPosRedisList() {
|
||||
if(redisUtil.exists(cacheKeyUtil.getPositionList())){
|
||||
return JsonUtil.getJsonToList(redisUtil.getString(cacheKeyUtil.getPositionList()).toString(),PositionEntity.class);
|
||||
}
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark,1);
|
||||
|
||||
List<PositionEntity> list=this.list(queryWrapper);
|
||||
if(list.size()>0){
|
||||
redisUtil.insert(cacheKeyUtil.getPositionList(), JsonUtil.getObjectToString(list),300);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getList(PaginationPosition paginationPosition) {
|
||||
// 需要查询哪些组织
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
// 所有有权限的组织
|
||||
Set<String> orgId = new HashSet<>(16);
|
||||
if (!UserProvider.getUser().getIsAdministrator()) {
|
||||
// 通过权限转树
|
||||
List<OrganizeAdministratorEntity> listss = organizeAdministratorService.getOrganizeAdministratorEntity(UserProvider.getUser().getUserId());
|
||||
// 判断自己是哪些组织的管理员
|
||||
listss.forEach(t -> {
|
||||
if (t != null) {
|
||||
if (t.getThisLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
orgId.add(t.getOrganizeId());
|
||||
}
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), false);
|
||||
orgId.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
orgId.addAll(organizeService.getOrgMapsAll(OrganizeEntity::getId).keySet());
|
||||
}
|
||||
if (orgId.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(paginationPosition.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(PositionEntity::getFullName, paginationPosition.getKeyword())
|
||||
.or().like(PositionEntity::getEnCode, paginationPosition.getKeyword())
|
||||
);
|
||||
}
|
||||
if (paginationPosition.getEnabledMark() != null) {
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark, paginationPosition.getEnabledMark());
|
||||
}
|
||||
if (StringUtil.isNotEmpty(paginationPosition.getEnCode())) {
|
||||
queryWrapper.lambda().eq(PositionEntity::getType, paginationPosition.getEnCode());
|
||||
}
|
||||
if (StringUtil.isNotEmpty(paginationPosition.getOrganizeId())) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(paginationPosition.getOrganizeId(), false);
|
||||
// 判断哪些组织时有权限的
|
||||
List<String> collect = underOrganizations.stream().filter(orgId::contains).collect(Collectors.toList());
|
||||
orgIds.add(paginationPosition.getOrganizeId());
|
||||
orgIds.addAll(collect);
|
||||
orgIds.add(paginationPosition.getOrganizeId());
|
||||
queryWrapper.lambda().in(PositionEntity::getOrganizeId, orgIds);
|
||||
} else {
|
||||
queryWrapper.lambda().in(PositionEntity::getOrganizeId, orgId);
|
||||
}
|
||||
long count = this.count(queryWrapper);
|
||||
queryWrapper.lambda().select(PositionEntity::getId, PositionEntity::getEnCode, PositionEntity::getCreatorTime,
|
||||
PositionEntity::getOrganizeId, PositionEntity::getEnabledMark, PositionEntity::getFullName,
|
||||
PositionEntity::getSortCode, PositionEntity::getType, PositionEntity::getDescription);
|
||||
queryWrapper.lambda().orderByAsc(PositionEntity::getSortCode).orderByDesc(PositionEntity::getCreatorTime);
|
||||
|
||||
if(Objects.equals(paginationPosition.getDataType(),1)){
|
||||
return list(queryWrapper);
|
||||
}
|
||||
Page<PositionEntity> page = new Page<>(paginationPosition.getCurrentPage(), paginationPosition.getPageSize(), count, false);
|
||||
page.setOptimizeCountSql(false);
|
||||
IPage<PositionEntity> iPage = this.page(page, queryWrapper);
|
||||
return paginationPosition.setData(iPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getListByUserId(String userId) {
|
||||
QueryWrapper<PositionEntity> query = new QueryWrapper<>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
userRelationService.getListByObjectType(userId, PermissionConst.POSITION).forEach(r->{
|
||||
ids.add(r.getObjectId());
|
||||
});
|
||||
if(ids.size() > 0){
|
||||
query.lambda().in(PositionEntity::getId, ids);
|
||||
return this.list(query);
|
||||
}else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionEntity getInfo(String id) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PositionEntity::getId,id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionEntity getByFullName(String fullName) {
|
||||
PositionEntity positionEntity = new PositionEntity();
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PositionEntity::getFullName, fullName);
|
||||
queryWrapper.lambda().select(PositionEntity::getId);
|
||||
List<PositionEntity> list = this.list(queryWrapper);
|
||||
if (list.size() > 0) {
|
||||
positionEntity = list.get(0);
|
||||
}
|
||||
return positionEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionEntity getByFullName(String fullName,String encode) {
|
||||
PositionEntity positionEntity = new PositionEntity();
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PositionEntity::getFullName, fullName);
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnCode, encode);
|
||||
queryWrapper.lambda().select(PositionEntity::getId);
|
||||
List<PositionEntity> list = this.list(queryWrapper);
|
||||
if (list.size() > 0) {
|
||||
positionEntity = list.get(0);
|
||||
}
|
||||
return positionEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(PositionEntity entity, boolean isFilter) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
if(entity != null) {
|
||||
queryWrapper.lambda().eq(PositionEntity::getFullName, entity.getFullName());
|
||||
}
|
||||
//是否需要过滤
|
||||
if (isFilter) {
|
||||
queryWrapper.lambda().ne(PositionEntity::getId, entity.getId());
|
||||
}
|
||||
List<PositionEntity> entityList = this.list(queryWrapper);
|
||||
for (PositionEntity positionEntity : entityList) {
|
||||
//如果组织id相同则代表已存在
|
||||
if (entity != null && entity.getOrganizeId().equals(positionEntity.getOrganizeId())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(PositionEntity entity, boolean isFilter) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
if(entity != null){
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnCode, entity.getEnCode());
|
||||
if (isFilter) {
|
||||
queryWrapper.lambda().ne(PositionEntity::getId, entity.getId());
|
||||
}
|
||||
}
|
||||
List<PositionEntity> entityList = this.list(queryWrapper);
|
||||
// for (PositionEntity positionEntity : entityList) {
|
||||
// //如果组织id相同则代表已存在
|
||||
// if (entity != null && entity.getOrganizeId().equals(positionEntity.getOrganizeId())){
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
return entityList.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(PositionEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, PositionEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void delete(PositionEntity entity) {
|
||||
this.removeById(entity.getId());
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectId,entity.getId());
|
||||
userRelationService.remove(queryWrapper);
|
||||
QueryWrapper<AuthorizeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(AuthorizeEntity::getObjectId,entity.getId());
|
||||
authorizeService.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public boolean first(String id) {
|
||||
boolean isOk = false;
|
||||
//获取要上移的那条数据的信息
|
||||
PositionEntity upEntity = this.getById(id);
|
||||
Long upSortCode = upEntity.getSortCode() == null ? 0 : upEntity.getSortCode();
|
||||
//查询上几条记录
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda()
|
||||
.lt(PositionEntity::getSortCode, upSortCode)
|
||||
.eq(PositionEntity::getOrganizeId,upEntity.getOrganizeId())
|
||||
.orderByDesc(PositionEntity::getSortCode);
|
||||
List<PositionEntity> downEntity = this.list(queryWrapper);
|
||||
if(downEntity.size()>0){
|
||||
//交换两条记录的sort值
|
||||
Long temp = upEntity.getSortCode();
|
||||
upEntity.setSortCode(downEntity.get(0).getSortCode());
|
||||
downEntity.get(0).setSortCode(temp);
|
||||
this.updateById(downEntity.get(0));
|
||||
this.updateById(upEntity);
|
||||
isOk = true;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public boolean next(String id) {
|
||||
boolean isOk = false;
|
||||
//获取要下移的那条数据的信息
|
||||
PositionEntity downEntity = this.getById(id);
|
||||
Long upSortCode = downEntity.getSortCode() == null ? 0 : downEntity.getSortCode();
|
||||
//查询下几条记录
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda()
|
||||
.gt(PositionEntity::getSortCode, upSortCode)
|
||||
.eq(PositionEntity::getOrganizeId,downEntity.getOrganizeId())
|
||||
.orderByAsc(PositionEntity::getSortCode);
|
||||
List<PositionEntity> upEntity = this.list(queryWrapper);
|
||||
if(upEntity.size()>0){
|
||||
//交换两条记录的sort值
|
||||
Long temp = downEntity.getSortCode();
|
||||
downEntity.setSortCode(upEntity.get(0).getSortCode());
|
||||
upEntity.get(0).setSortCode(temp);
|
||||
this.updateById(upEntity.get(0));
|
||||
this.updateById(downEntity);
|
||||
isOk = true;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getPositionName(List<String> id, boolean filterEnabledMark) {
|
||||
List<PositionEntity> roleList = new ArrayList<>();
|
||||
if (id.size() > 0) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PositionEntity::getId, id);
|
||||
roleList = this.list(queryWrapper);
|
||||
}
|
||||
return roleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getPositionName(List<String> id, String keyword) {
|
||||
List<PositionEntity> roleList = new ArrayList<>();
|
||||
if (id.size() > 0) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PositionEntity::getId, id);
|
||||
//关键字(名称、编码)
|
||||
if (!StringUtil.isEmpty(keyword)) {
|
||||
queryWrapper.lambda().and(
|
||||
t->t.like(PositionEntity::getFullName,keyword)
|
||||
.or().like(PositionEntity::getEnCode,keyword)
|
||||
);
|
||||
}
|
||||
roleList = this.list(queryWrapper);
|
||||
}
|
||||
return roleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getListByOrganizeId(List<String> organizeIds, boolean enabledMark) {
|
||||
if (organizeIds.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PositionEntity::getOrganizeId, organizeIds);
|
||||
if (enabledMark) {
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark, 1);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(PositionEntity::getSortCode).orderByDesc(PositionEntity::getCreatorTime);
|
||||
// queryWrapper.lambda().select(PositionEntity::getId, PositionEntity::getFullName);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getListByOrgIdAndUserId(String organizeId, String userId) {
|
||||
// 用户绑定的所有岗位
|
||||
List<String> positionIds = userRelationService.getListByUserIdAndObjType(userId, PermissionConst.POSITION).stream()
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
if(positionIds.size() > 0){
|
||||
List<PositionEntity> positionEntities = this.listByIds(positionIds);
|
||||
return positionEntities.stream().filter(p-> p.getOrganizeId().equals(organizeId)).collect(Collectors.toList());
|
||||
}else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getListByFullName(String fullName, String enCode) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PositionEntity::getFullName, fullName).eq(PositionEntity::getEnCode, enCode);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getCurPositionsByOrgId(String orgId) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
List<UserRelationEntity> userRelations = userRelationService.getListByObjectType(userId, PermissionConst.POSITION);
|
||||
List<PositionEntity> positions = new ArrayList<>();
|
||||
userRelations.forEach(ur->{
|
||||
PositionEntity entity = this.getInfo(ur.getObjectId());
|
||||
if(entity.getOrganizeId().equals(orgId)){
|
||||
positions.add(entity);
|
||||
}
|
||||
});
|
||||
return positions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionEntity> getList(List<String> idList, Pagination pagination, boolean isPage) {
|
||||
if (idList.size() > 0) {
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(PositionEntity::getId, idList);
|
||||
queryWrapper.lambda().eq(PositionEntity::getEnabledMark, 1);
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(PositionEntity::getFullName, pagination.getKeyword())
|
||||
.or().like(PositionEntity::getEnCode, pagination.getKeyword())
|
||||
);
|
||||
}
|
||||
if(isPage) {
|
||||
Page<PositionEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<PositionEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), iPage.getTotal());
|
||||
}else {
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionModel> getListByOrganizeIds(List<String> organizeIds, boolean needCode, boolean enabledMark) {
|
||||
List<PermissionModel> permissionList = new LinkedList<>();
|
||||
for (String organizeId : organizeIds) {
|
||||
OrganizeEntity info = organizeService.getInfo(organizeId);
|
||||
if (info != null) {
|
||||
PermissionModel parentModel = new PermissionModel();
|
||||
List<PositionEntity> list = this.getListByOrganizeId(Collections.singletonList(organizeId), enabledMark);
|
||||
list.stream().forEach(t->{
|
||||
if(needCode){
|
||||
t.setFullName(t.getFullName()+"/"+t.getEnCode());
|
||||
}
|
||||
});
|
||||
List<PermissionModel> positionModels = JsonUtil.getJsonToList(list, PermissionModel.class);
|
||||
parentModel.setChildren(positionModels);
|
||||
parentModel.setHasChildren(true);
|
||||
parentModel.setFullName(info.getFullName());
|
||||
parentModel.setId(info.getId());
|
||||
permissionList.add(parentModel);
|
||||
}
|
||||
}
|
||||
return permissionList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,524 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.mapper.RoleMapper;
|
||||
import com.yunzhupaas.permission.model.role.RoleModel;
|
||||
import com.yunzhupaas.permission.model.role.RolePagination;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统角色
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl extends SuperServiceImpl<RoleMapper, RoleEntity> implements RoleService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
private OrganizeRelationService organizeRelationService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private OrganizeAdministratorService organizeAdministratorService;
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getList(boolean filterEnabledMark) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnabledMark, 1);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(RoleEntity::getSortCode).orderByDesc(RoleEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getList(RolePagination pagination, Integer globalMark) {
|
||||
// 需要查询哪些组织
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
// 所有有权限的组织
|
||||
Set<String> orgId = new HashSet<>(16);
|
||||
if (!UserProvider.getUser().getIsAdministrator()) {
|
||||
// 通过权限转树
|
||||
List<OrganizeAdministratorEntity> listss = organizeAdministratorService.getOrganizeAdministratorEntity(UserProvider.getUser().getUserId());
|
||||
// 判断自己是哪些组织的管理员
|
||||
listss.forEach(t -> {
|
||||
if (t != null) {
|
||||
if (t.getThisLayerSelect() != null && t.getThisLayerSelect() == 1) {
|
||||
orgId.add(t.getOrganizeId());
|
||||
}
|
||||
if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), false);
|
||||
orgId.addAll(underOrganizations);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
orgId.addAll(organizeService.getOrgMapsAll(OrganizeEntity::getId).keySet());
|
||||
}
|
||||
|
||||
if (!StringUtil.isEmpty(pagination.getOrganizeId())) {
|
||||
List<String> underOrganizations = organizeService.getUnderOrganizations(pagination.getOrganizeId(), false);
|
||||
// 判断哪些组织时有权限的
|
||||
List<String> collect = underOrganizations.stream().filter(orgId::contains).collect(Collectors.toList());
|
||||
orgIds.add(pagination.getOrganizeId());
|
||||
orgIds.addAll(collect);
|
||||
orgIds.add(pagination.getOrganizeId());
|
||||
} else {
|
||||
if (orgId.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(RoleEntity::getFullName, pagination.getKeyword())
|
||||
.or().like(RoleEntity::getEnCode, pagination.getKeyword())
|
||||
);
|
||||
}
|
||||
if (globalMark > -1) {
|
||||
queryWrapper.lambda().eq(RoleEntity::getGlobalMark, globalMark);
|
||||
}
|
||||
if (!UserProvider.getUser().getIsAdministrator()) {
|
||||
queryWrapper.lambda().ne(RoleEntity::getGlobalMark, 1);
|
||||
List<String> collect = organizeRelationService.getRelationListByOrganizeId(new ArrayList<>(orgId), PermissionConst.ROLE).stream().map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
if (collect.size() == 0) {
|
||||
collect.add("");
|
||||
}
|
||||
queryWrapper.lambda().in(RoleEntity::getId, collect);
|
||||
}
|
||||
if (pagination.getEnabledMark() != null) {
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnabledMark, pagination.getEnabledMark());
|
||||
}
|
||||
if(Objects.equals(pagination.getDataType(),1)){
|
||||
queryWrapper.lambda().orderByAsc(RoleEntity::getSortCode).orderByDesc(RoleEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
long count = this.count(queryWrapper);
|
||||
queryWrapper.lambda().orderByAsc(RoleEntity::getSortCode).orderByDesc(RoleEntity::getCreatorTime);
|
||||
Page<RoleEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize(), count, false);
|
||||
page.setOptimizeCountSql(false);
|
||||
IPage<RoleEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
String keyword = "";
|
||||
if (!StringUtil.isEmpty(pagination.getKeyword())) {
|
||||
keyword = "%" + pagination.getKeyword() + "%";
|
||||
}
|
||||
PageHelper.startPage((int) pagination.getCurrentPage(), (int) pagination.getPageSize(), false);
|
||||
PageMethod.getLocalPage().keepOrderBy(true);
|
||||
List<String> query = this.baseMapper.query(orgIds, keyword, globalMark, pagination.getEnabledMark());
|
||||
Long count = this.baseMapper.count(orgIds, keyword, globalMark, pagination.getEnabledMark());
|
||||
PageInfo pageInfo = new PageInfo(query);
|
||||
// 赋值分页参数
|
||||
pagination.setTotal(count);
|
||||
pagination.setCurrentPage(pageInfo.getPageNum());
|
||||
pagination.setPageSize(pageInfo.getPageSize());
|
||||
if (pageInfo.getList() != null && pageInfo.getList().size() > 0) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(RoleEntity::getId, pageInfo.getList());
|
||||
queryWrapper.lambda().orderByAsc(RoleEntity::getSortCode).orderByDesc(RoleEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getListByUserId(String userId) {
|
||||
QueryWrapper<RoleEntity> query = new QueryWrapper<>();
|
||||
List<String> roleRelations = userRelationService.getListByObjectType(userId, PermissionConst.ROLE).stream()
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
if (roleRelations.size() > 0) {
|
||||
query.lambda().in(RoleEntity::getId, roleRelations);
|
||||
return this.list(query);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getListByUserIdAndOrgId(String userId, String orgId) {
|
||||
return getListByUserId(userId).stream()
|
||||
.filter(role -> organizeRelationService.existByRoleIdAndOrgId(role.getId(), orgId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleIdsByCurrentUser() {
|
||||
UserEntity userEntity = userService.getInfo(UserProvider.getUser().getUserId());
|
||||
return getAllRoleIdsByUserIdAndOrgId(userEntity.getId(), userEntity.getOrganizeId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleIdsByCurrentUser(String orgId) {
|
||||
UserEntity userEntity = userService.getInfo(UserProvider.getUser().getUserId());
|
||||
return getAllRoleIdsByUserIdAndOrgId(userEntity.getId(), orgId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllRoleIdsByUserIdAndOrgId(String userId, String orgId) {
|
||||
// 用户当前组织下的角色
|
||||
List<String> roleIds = getListByUserIdAndOrgId(userId, orgId).stream()
|
||||
.map(RoleEntity::getId).collect(Collectors.toList());
|
||||
// 用户绑定的全局角色
|
||||
List<String> globalRoleIds = userRelationService.getListByUserIdAndObjType(userId, PermissionConst.ROLE).stream()
|
||||
.map(UserRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
globalRoleIds = roleService.getListByIds(globalRoleIds, null, false).stream().filter(r -> r.getGlobalMark() != null && r.getGlobalMark() == 1)
|
||||
.map(RoleEntity::getId).collect(Collectors.toList());
|
||||
roleIds.addAll(globalRoleIds);
|
||||
return roleIds.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleEntity getInfo(String id) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RoleEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByFullName(String fullName, String id, Integer globalMark) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RoleEntity::getFullName, fullName);
|
||||
queryWrapper.lambda().eq(RoleEntity::getGlobalMark, globalMark);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(RoleEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByEnCode(String enCode, String id) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnCode, enCode);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(RoleEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, RoleEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(RoleEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(RoleEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AuthorizeEntity::getObjectId, entity.getId());
|
||||
authorizeService.remove(queryWrapper);
|
||||
QueryWrapper<UserRelationEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(UserRelationEntity::getObjectId, entity.getId());
|
||||
userRelationService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getListByIds(List<String> id, String keyword, boolean filterEnabledMark) {
|
||||
List<RoleEntity> roleList = new ArrayList<>();
|
||||
if (id.size() > 0) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(RoleEntity::getId, id);
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnabledMark, 1);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(keyword)) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(RoleEntity::getFullName, keyword)
|
||||
.or().like(RoleEntity::getEnCode, keyword)
|
||||
);
|
||||
}
|
||||
roleList = this.list(queryWrapper);
|
||||
}
|
||||
return roleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getSwaptListByIds(Set<String> roleIds) {
|
||||
if (roleIds.size() > 0) {
|
||||
QueryWrapper<RoleEntity> roleWrapper = new QueryWrapper<>();
|
||||
roleWrapper.lambda().select(RoleEntity::getFullName, RoleEntity::getId).in(RoleEntity::getId, roleIds);
|
||||
List<RoleEntity> list = roleService.list(roleWrapper);
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRoleMap() {
|
||||
QueryWrapper<RoleEntity> roleWrapper = new QueryWrapper<>();
|
||||
roleWrapper.lambda().select(RoleEntity::getFullName, RoleEntity::getId);
|
||||
List<RoleEntity> list = roleService.list(roleWrapper);
|
||||
return list.stream().collect(Collectors.toMap(RoleEntity::getId, RoleEntity::getFullName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRoleNameAndIdMap() {
|
||||
return getRoleNameAndIdMap(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRoleNameAndIdMap(boolean enabledMark) {
|
||||
QueryWrapper<RoleEntity> roleWrapper = new QueryWrapper<>();
|
||||
if(enabledMark){
|
||||
roleWrapper.lambda().eq(RoleEntity::getEnabledMark, 1);
|
||||
}
|
||||
List<RoleEntity> list = roleService.list(roleWrapper);
|
||||
Map<String, Object> roleNameMap = new HashMap<>();
|
||||
list.stream().forEach(role -> roleNameMap.put(role.getFullName() + "/" + role.getEnCode(), role.getId()));
|
||||
return roleNameMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleEntity getInfoByFullName(String fullName) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RoleEntity::getFullName, fullName);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleEntity getInfoByFullName(String fullName, String enCode) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RoleEntity::getFullName, fullName);
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnCode, enCode);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getGlobalList() {
|
||||
return getGlobalList(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getGlobalList(boolean enabledMark) {
|
||||
QueryWrapper<RoleEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(RoleEntity::getGlobalMark, 1);
|
||||
if(enabledMark){
|
||||
query.lambda().eq(RoleEntity::getEnabledMark, 1);
|
||||
}
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getGlobalList(List<String> ids) {
|
||||
if (ids.isEmpty()) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
QueryWrapper<RoleEntity> query = new QueryWrapper<>();
|
||||
query.lambda().in(RoleEntity::getId, ids);
|
||||
query.lambda().eq(RoleEntity::getGlobalMark, 1).eq(RoleEntity::getEnabledMark, 1);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existCurRoleByOrgId(String orgId) {
|
||||
List<UserRelationEntity> roleRelationList = userRelationService
|
||||
.getListByObjectType(UserProvider.getUser().getUserId(), PermissionConst.ROLE);
|
||||
for (UserRelationEntity userRelationEntity : roleRelationList) {
|
||||
if (organizeRelationService.existByRoleIdAndOrgId(userRelationEntity.getObjectId(), orgId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getCurRolesByOrgId(String orgId) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
List<UserRelationEntity> userRelations = userRelationService.getListByObjectType(userId, PermissionConst.ROLE);
|
||||
List<RoleEntity> roles = new ArrayList<>();
|
||||
userRelations.forEach(ur -> {
|
||||
// 获取全局角色
|
||||
RoleEntity roleEntity = this.getInfo(ur.getObjectId());
|
||||
if (roleEntity != null && roleEntity.getGlobalMark() != null && roleEntity.getGlobalMark() == 1 && roleEntity.getEnabledMark() == 1) {
|
||||
roles.add(roleEntity);
|
||||
} else {
|
||||
organizeRelationService.getRelationListByRoleId(ur.getObjectId()).forEach(or -> {
|
||||
if (roleEntity.getEnabledMark() == 1 && or.getOrganizeId().equals(orgId)) {
|
||||
roles.add(roleEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getRolesByOrgId(String orgId) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
organizeRelationService.getListByTypeAndOrgId(PermissionConst.ROLE, orgId).forEach(o -> {
|
||||
ids.add(o.getObjectId());
|
||||
});
|
||||
QueryWrapper<RoleEntity> query = new QueryWrapper<>();
|
||||
if (ids.size() > 0) {
|
||||
query.lambda().in(RoleEntity::getId, ids);
|
||||
return this.list(query);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBindInfo(String roleId, List<String> reduceOrgIds) {
|
||||
if (reduceOrgIds.size() > 0) {
|
||||
StringBuilder info = new StringBuilder();
|
||||
RoleEntity roleEntity = this.getInfo(roleId);
|
||||
List<UserRelationEntity> bingUserByRoleList = userRelationService.getListByObjectId(roleId, PermissionConst.ROLE);
|
||||
if (bingUserByRoleList.size() < 1) {
|
||||
return null;
|
||||
}
|
||||
info.append("已绑定用户:");
|
||||
boolean bindFlag = false;
|
||||
for (UserRelationEntity bingUser : bingUserByRoleList) {
|
||||
String userId = bingUser.getUserId();
|
||||
if (roleEntity.getGlobalMark() == 1) {
|
||||
UserEntity user = userService.getInfo(userId);
|
||||
info.append("[ ").append(user.getRealName()).append("/").append(user.getAccount()).append(" ] ");
|
||||
bindFlag = true;
|
||||
} else {
|
||||
// 这个用户所绑定的组织
|
||||
List<UserRelationEntity> bingUserByOrg = userRelationService.getListByObjectType(userId, PermissionConst.ORGANIZE);
|
||||
for (UserRelationEntity bingOrg : bingUserByOrg) {
|
||||
String orgId = bingOrg.getObjectId();
|
||||
if (reduceOrgIds.contains(orgId)) {
|
||||
OrganizeEntity org = organizeService.getInfo(orgId);
|
||||
UserEntity user = userService.getInfo(bingOrg.getUserId());
|
||||
info.append("[").append(org.getFullName()).append(":用户(").append(user.getRealName()).append(")]; ");
|
||||
bindFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bindFlag) {
|
||||
return info.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> getList(List<String> idList, Pagination pagination, boolean filterEnabledMark) {
|
||||
if (idList.size() > 0) {
|
||||
QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(RoleEntity::getId, idList);
|
||||
if (filterEnabledMark) {
|
||||
queryWrapper.lambda().eq(RoleEntity::getEnabledMark, 1);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(RoleEntity::getFullName, pagination.getKeyword())
|
||||
.or().like(RoleEntity::getEnCode, pagination.getKeyword())
|
||||
);
|
||||
}
|
||||
Page<RoleEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<RoleEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleModel> getListByOrganizeIds(List<String> organizeIds, boolean needCode, boolean enabledMark) {
|
||||
List<RoleModel> modelAll = new ArrayList<>();
|
||||
|
||||
for (String organizeId : organizeIds) {
|
||||
OrganizeEntity organizeEntity = organizeService.getInfo(organizeId);
|
||||
if (organizeEntity != null) {
|
||||
RoleModel organizeModel = JsonUtil.getJsonToBean(organizeEntity, RoleModel.class);
|
||||
List<OrganizeRelationEntity> roleRelations = organizeRelationService.getListByTypeAndOrgId(PermissionConst.ROLE, organizeId);
|
||||
List<SumTree<RoleModel>> roleList = new ArrayList<>();
|
||||
for (OrganizeRelationEntity roleRelation : roleRelations) {
|
||||
RoleEntity roleEntity = roleService.getInfo(roleRelation.getObjectId());
|
||||
if (roleEntity == null || (enabledMark && roleEntity.getEnabledMark() != 1)) {
|
||||
continue;
|
||||
}
|
||||
// 非全局
|
||||
if (roleEntity.getGlobalMark() == 0) {
|
||||
RoleModel roleModel = JsonUtil.getJsonToBean(roleEntity, RoleModel.class);
|
||||
String fullName = roleEntity.getFullName();
|
||||
if (needCode) {
|
||||
fullName += "/" + roleEntity.getEnCode();
|
||||
}
|
||||
roleModel.setFullName(fullName);
|
||||
roleModel.setHasChildren(false);
|
||||
roleList.add(roleModel);
|
||||
}
|
||||
}
|
||||
organizeModel.setHasChildren(true);
|
||||
organizeModel.setChildren(roleList);
|
||||
modelAll.add(organizeModel);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取全局角色
|
||||
List<SumTree<RoleModel>> models = new ArrayList<>();
|
||||
roleService.getGlobalList(enabledMark).forEach(r -> {
|
||||
RoleModel jsonToBean = JsonUtil.getJsonToBean(r, RoleModel.class);
|
||||
String fullName = r.getFullName();
|
||||
if (needCode) {
|
||||
fullName += "/" + r.getEnCode();
|
||||
}
|
||||
jsonToBean.setFullName(fullName);
|
||||
models.add(jsonToBean);
|
||||
});
|
||||
RoleModel modelGlobal = new RoleModel();
|
||||
modelGlobal.setFullName("全局");
|
||||
modelGlobal.setHasChildren(true);
|
||||
modelGlobal.setId("0");
|
||||
modelGlobal.setChildren(models);
|
||||
modelAll.add(modelGlobal);
|
||||
return modelAll;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.permission.entity.SocialsUserEntity;
|
||||
import com.yunzhupaas.permission.mapper.SocialsUserMapper;
|
||||
import com.yunzhupaas.permission.service.SocialsUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 9:33:16
|
||||
*/
|
||||
@Service
|
||||
public class SocialsUserServiceImpl extends SuperServiceImpl<SocialsUserMapper, SocialsUserEntity> implements SocialsUserService {
|
||||
@Override
|
||||
public List<SocialsUserEntity> getListByUserId(String userId) {
|
||||
QueryWrapper<SocialsUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getUserId,userId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SocialsUserEntity> getUserIfnoBySocialIdAndType(String socialId, String socialType) {
|
||||
QueryWrapper<SocialsUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getSocialId,socialId);
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getSocialType,socialType);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SocialsUserEntity> getListByUserIdAndSource(String userId, String socialType) {
|
||||
QueryWrapper<SocialsUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getUserId,userId);
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getSocialType,socialType);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocialsUserEntity getInfoBySocialId(String socialId,String socialType){
|
||||
QueryWrapper<SocialsUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getSocialId,socialId);
|
||||
queryWrapper.lambda().eq(SocialsUserEntity::getSocialType,socialType);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.permission.connector.UserInfoService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.Md5Util;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户信息保存
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/7/28 14:38
|
||||
*/
|
||||
@Service
|
||||
public class UserInfoServiceImpl implements UserInfoService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public Boolean create(Map<String, Object> map) {
|
||||
UserEntity entity = JsonUtil.getJsonToBean(map, UserEntity.class);
|
||||
QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserEntity::getAccount, entity.getAccount());
|
||||
UserEntity entity1 = userService.getOne(queryWrapper);
|
||||
if (entity1 != null) {
|
||||
entity.setId(entity1.getId());
|
||||
if(StringUtil.isNotEmpty(entity.getPassword())) {
|
||||
entity.setPassword(Md5Util.getStringMd5(Md5Util.getStringMd5(entity.getPassword()) + entity1.getSecretkey().toLowerCase()));
|
||||
}
|
||||
return userService.updateById(entity);
|
||||
} else {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
String userId = RandomUtil.uuId();
|
||||
entity.setId(userId);
|
||||
}
|
||||
entity.setSecretkey(RandomUtil.uuId());
|
||||
entity.setPassword(Md5Util.getStringMd5(Md5Util.getStringMd5(entity.getPassword()) + entity.getSecretkey().toLowerCase()));
|
||||
entity.setIsAdministrator(0);
|
||||
return userService.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(Map<String, Object> map) {
|
||||
return create(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(Map<String, Object> map) {
|
||||
UserEntity entity = JsonUtil.getJsonToBean(map, UserEntity.class);
|
||||
QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserEntity::getAccount, entity.getAccount());
|
||||
UserEntity entity1 = userService.getOne(queryWrapper);
|
||||
if (entity1 != null) {
|
||||
entity.setId(entity1.getId());
|
||||
}
|
||||
return userService.removeById(entity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInfo(String id) {
|
||||
UserEntity entity = userService.getInfo(id);
|
||||
return JsonUtil.entityToMap(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.permission.entity.UserOldPasswordEntity;
|
||||
import com.yunzhupaas.permission.mapper.UserOldPasswordMapper;
|
||||
import com.yunzhupaas.permission.service.UserOldPasswordService;
|
||||
import com.yunzhupaas.permission.service.UserRelationService;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Service
|
||||
@DSTransactional
|
||||
public class UserOldPasswordServiceImpl extends SuperServiceImpl<UserOldPasswordMapper, UserOldPasswordEntity> implements UserOldPasswordService {
|
||||
|
||||
@Override
|
||||
public List<UserOldPasswordEntity> getList(String userId) {
|
||||
QueryWrapper<UserOldPasswordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserOldPasswordEntity::getUserId,userId);
|
||||
queryWrapper.lambda().orderByDesc(UserOldPasswordEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean create(UserOldPasswordEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
this.save(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
package com.yunzhupaas.permission.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.message.entity.SynThirdInfoEntity;
|
||||
import com.yunzhupaas.message.service.SynThirdInfoService;
|
||||
import com.yunzhupaas.message.util.SynThirdConsts;
|
||||
import com.yunzhupaas.permission.entity.PermissionEntityBase;
|
||||
import com.yunzhupaas.permission.entity.PositionEntity;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.mapper.UserRelationMapper;
|
||||
import com.yunzhupaas.permission.model.permission.PermissionModel;
|
||||
import com.yunzhupaas.permission.model.userrelation.UserRelationForm;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.permission.util.PermissionUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.yunzhupaas.util.Constants.ADMIN_KEY;
|
||||
|
||||
/**
|
||||
* 用户关系
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Service
|
||||
public class UserRelationServiceImpl extends SuperServiceImpl<UserRelationMapper, UserRelationEntity> implements UserRelationService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private PositionService positionService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private OrganizeRelationService organizeRelationService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private SynThirdInfoService synThirdInfoService;
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByUserId(String userId) {
|
||||
return getListByUserIdAll(Collections.singletonList(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByUserIdAndObjType(String userId, String objectType) {
|
||||
QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().in(UserRelationEntity::getUserId, userId);
|
||||
query.lambda().in(UserRelationEntity::getObjectType, objectType);
|
||||
query.lambda().orderByAsc(UserRelationEntity::getSortCode).orderByDesc(UserRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByUserIdAll(List<String> userId) {
|
||||
if (userId.size() > 0) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(UserRelationEntity::getUserId, userId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByObjectId(String objectId) {
|
||||
return getListByObjectId(objectId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByObjectType(String objectType) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectType, objectType);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByObjectId(String objectId, String objectType) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectId, objectId);
|
||||
if(objectType != null){
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectType, objectType);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(UserRelationEntity::getSortCode).orderByDesc(UserRelationEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByObjectIdAll(List<String> objectId) {
|
||||
List<UserRelationEntity> list = new ArrayList<>();
|
||||
if (objectId.size() > 0) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(UserRelationEntity::getObjectId, objectId);
|
||||
list = this.list(queryWrapper);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllByObjId(String objId) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectId, objId);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllByUserId(String userId) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getUserId, userId);
|
||||
queryWrapper.lambda().ne(UserRelationEntity::getObjectType, PermissionConst.GROUP);
|
||||
userRelationService.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createByList(List<UserRelationEntity> userRelationEntityList) {
|
||||
userRelationEntityList.forEach(t -> {
|
||||
this.save(t);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRelationEntity getInfo(String id) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void save(String objectId, List<UserRelationEntity> entitys) {
|
||||
List<UserRelationEntity> existList = this.getListByObjectId(objectId);
|
||||
List<UserRelationEntity> relationList = new ArrayList<>();
|
||||
for (int i = 0; i < entitys.size(); i++) {
|
||||
UserRelationEntity entity = entitys.get(i);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setSortCode(Long.parseLong(i + ""));
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
if (existList.stream().filter(t -> t.getUserId().equals(entity.getUserId())).count() == 0) {
|
||||
relationList.add(entity);
|
||||
}
|
||||
}
|
||||
for (UserRelationEntity entity : relationList) {
|
||||
this.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(List<UserRelationEntity> list) {
|
||||
for (UserRelationEntity entity : list) {
|
||||
this.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void delete(String[] ids) {
|
||||
for (String item : ids) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getId, item);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void saveObjectId(String objectId, UserRelationForm userRelationForm) {
|
||||
// 修改前的岗位绑定人员ID
|
||||
List<String> beforeUserIds = userRelationService.getListByObjectId(objectId)
|
||||
.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
|
||||
//清除原有成员数据
|
||||
deleteAllByObjId(objectId);
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<UserRelationEntity> list = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (String userId : userRelationForm.getUserIds()) {
|
||||
UserRelationEntity entity = new UserRelationEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setSortCode(Long.parseLong(i + ""));
|
||||
entity.setObjectId(objectId);
|
||||
entity.setObjectType(userRelationForm.getObjectType());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setUserId(userId);
|
||||
list.add(entity);
|
||||
i++;
|
||||
}
|
||||
save(objectId, list);
|
||||
|
||||
// 并集:所有未修改的人员
|
||||
List<String> unUpdateUserId = beforeUserIds.stream().filter(b-> userRelationForm.getUserIds()
|
||||
.contains(b)).collect(Collectors.toList());
|
||||
// 差集:所有修改过的人员(包括:删除此岗位、添加此岗位的人员)
|
||||
beforeUserIds.addAll(userRelationForm.getUserIds());
|
||||
List<String> allUpdateIds = beforeUserIds.stream().filter(u-> !unUpdateUserId.contains(u))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (PermissionConst.POSITION.equals(userRelationForm.getObjectType())) {
|
||||
// 自动切换岗位
|
||||
organizeRelationService.autoSetPosition(allUpdateIds);
|
||||
}
|
||||
userService.delCurUser(MsgCode.PS010.get(), allUpdateIds,3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getRelationByUserIds(List<String> userIds) {
|
||||
if (userIds.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().in(UserRelationEntity::getUserId, userIds);
|
||||
query.lambda().eq(UserRelationEntity::getObjectType, PermissionConst.ORGANIZE);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByObjectType(String userId, String objectType) {
|
||||
QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(UserRelationEntity::getUserId, userId);
|
||||
if (StringUtil.isNotEmpty(objectType)) {
|
||||
query.lambda().eq(UserRelationEntity::getObjectType, objectType);
|
||||
}
|
||||
query.lambda().orderByAsc(UserRelationEntity::getSortCode).orderByDesc(UserRelationEntity::getCreatorTime);
|
||||
return this.list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getAllOrgRelationByUserId(String userId){
|
||||
return this.getListByObjectType(userId,PermissionConst.ORGANIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionModel> getObjectVoList(String objectType) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
UserEntity userEntity = userService.getInfo(userId);
|
||||
String majorOrgId = UserProvider.getUser().getOrganizeId();
|
||||
|
||||
// 组装对应组织/岗位/角色对象
|
||||
switch (objectType) {
|
||||
case PermissionConst.ORGANIZE:
|
||||
// 使用in查询减少数据库查询次数
|
||||
List<String> ids = new ArrayList<>();
|
||||
this.getListByObjectType(userId, objectType).forEach(r -> ids.add(r.getObjectId()));
|
||||
List<PermissionModel> permissionModels = setModel(organizeService.getOrgEntityList(ids, false), majorOrgId);
|
||||
permissionModels.forEach(p->p.setFullName(PermissionUtil.getLinkInfoByOrgId(p.getId(), organizeService, false)));
|
||||
return permissionModels;
|
||||
case PermissionConst.POSITION:
|
||||
// 岗位遵循一对多关系
|
||||
List<PositionEntity> positionList = positionService.getListByUserId(userId);
|
||||
if (positionList.size() > 0) {
|
||||
return setModel(positionList.stream().filter(p -> p.getOrganizeId().equals(majorOrgId))
|
||||
.collect(Collectors.toList()), userEntity.getPositionId());
|
||||
}
|
||||
default:
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置返回模型
|
||||
*
|
||||
* @param permissionList
|
||||
* @param majorId
|
||||
*/
|
||||
private <T extends PermissionEntityBase> List<PermissionModel> setModel (List<T> permissionList, String majorId){
|
||||
List<PermissionModel> voList = new ArrayList<>();
|
||||
permissionList.forEach(p -> {
|
||||
PermissionModel model = new PermissionModel();
|
||||
if (p.getId().equals(majorId)) {
|
||||
model.setIsDefault(true);
|
||||
} else {
|
||||
model.setIsDefault(false);
|
||||
}
|
||||
model.setFullName(p.getFullName());
|
||||
model.setId(p.getId());
|
||||
model.setFullName(p.getFullName());
|
||||
voList.add(model);
|
||||
});
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existByObj(String objectType, String objectId) {
|
||||
QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda()
|
||||
.eq(UserRelationEntity::getObjectType, objectType)
|
||||
.eq(UserRelationEntity::getObjectId, objectId);
|
||||
return this.count(query) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByRoleId(String roleId) {
|
||||
List<UserRelationEntity> list = new ArrayList<>();
|
||||
organizeRelationService.getRelationListByRoleId(roleId).forEach(o->{
|
||||
QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda()
|
||||
.eq(UserRelationEntity::getObjectType, PermissionConst.ORGANIZE)
|
||||
.eq(UserRelationEntity::getObjectId, o.getOrganizeId());
|
||||
list.addAll(this.list(query));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByUserId(String userId, String objectType) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getUserId, userId);
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectType, objectType);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRelationEntity> getListByOrgId(List<String> orgIdList) {
|
||||
if (orgIdList.size() > 0) {
|
||||
QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserRelationEntity::getObjectType, PermissionConst.ORGANIZE).in(UserRelationEntity::getObjectId, orgIdList);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncDingUserRelation(String sysObjId, List<Long> deptIdList) {
|
||||
List<UserRelationEntity> list = new ArrayList<>();
|
||||
UserRelationEntity entity = null;
|
||||
// 查询对应的中间表,获取到对应的本地组织id
|
||||
QueryWrapper<SynThirdInfoEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(SynThirdInfoEntity::getThirdObjId,deptIdList);
|
||||
wrapper.lambda().eq(SynThirdInfoEntity::getThirdType, SynThirdConsts.THIRD_TYPE_DING_To_Sys);
|
||||
List<SynThirdInfoEntity> synThirdInfoLists = synThirdInfoService.getBaseMapper().selectList(wrapper);
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
for (SynThirdInfoEntity obj : synThirdInfoLists) {
|
||||
map.put(obj.getThirdObjId(),obj.getSysObjId());
|
||||
}
|
||||
// 已经存在的数据
|
||||
List<String> collect = deptIdList.stream().map(t -> String.valueOf(t)).collect(Collectors.toList());
|
||||
QueryWrapper<UserRelationEntity> relationWrapper = new QueryWrapper<>();
|
||||
relationWrapper.lambda().in(UserRelationEntity::getObjectId,collect);
|
||||
relationWrapper.lambda().eq(UserRelationEntity::getObjectType,"Organize");
|
||||
relationWrapper.lambda().eq(UserRelationEntity::getUserId,sysObjId);
|
||||
List<UserRelationEntity> userRelationEntities = this.getBaseMapper().selectList(relationWrapper);
|
||||
List<String> deleteIdS = userRelationEntities.stream().map(t -> t.getId()).collect(Collectors.toList());
|
||||
this.removeByIds(deleteIdS);
|
||||
|
||||
UserEntity adminAccount = userService.getUserByAccount(ADMIN_KEY);
|
||||
String adminId = adminAccount == null ? null : adminAccount.getId();
|
||||
for (Long id : deptIdList) {
|
||||
String objectId = String.valueOf(id);
|
||||
entity= new UserRelationEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setObjectId(map.get(objectId));
|
||||
entity.setCreatorUserId(adminId);
|
||||
entity.setSortCode(0L);
|
||||
entity.setUserId(sysObjId);
|
||||
entity.setObjectType("Organize");
|
||||
list.add(entity);
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,190 @@
|
||||
package com.yunzhupaas.permission.util;
|
||||
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.permission.entity.OrganizeEntity;
|
||||
import com.yunzhupaas.permission.service.OrganizeService;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 类功能
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/1/27
|
||||
*/
|
||||
public class PermissionUtil {
|
||||
|
||||
/**
|
||||
* 递归取组织结构id
|
||||
*
|
||||
* @param organizeInfo 组织信息集合
|
||||
* @param organizeId 组织id
|
||||
* @param infoType 信息类型 1:id 2:fullName
|
||||
*/
|
||||
private static LinkedList<String> getOrganizeInfos(LinkedList<String> organizeInfo, String organizeId, Integer infoType, OrganizeService organizeService) {
|
||||
OrganizeEntity infoEntity = organizeService.getInfo(organizeId);
|
||||
if (infoEntity != null) {
|
||||
organizeInfo.add(infoType.equals(1) ? organizeId : infoEntity.getFullName());
|
||||
// -1 为顶级节点
|
||||
if (!"-1".equals(infoEntity.getParentId())) {
|
||||
getOrganizeInfos(organizeInfo, infoEntity.getParentId(), infoType, organizeService);
|
||||
} else {
|
||||
// 结束时,进行倒序排列
|
||||
Collections.reverse(organizeInfo);
|
||||
}
|
||||
}
|
||||
return organizeInfo;
|
||||
}
|
||||
|
||||
public static List<LinkedList<String>> getOrgIdsTree(List<String> organizeIds, Integer infoType, OrganizeService organizeService) {
|
||||
List<LinkedList<String>> organizeIdsTree = new ArrayList<>();
|
||||
organizeIds.forEach(id -> {
|
||||
organizeIdsTree.add(getOrganizeInfos(new LinkedList<>(), id, infoType, organizeService));
|
||||
});
|
||||
return organizeIdsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组名连接信息
|
||||
*
|
||||
* @param organizeIds 组织id集合
|
||||
* @return 组织链式信息
|
||||
*/
|
||||
public static String getLinkInfoByOrgId(List<String> organizeIds, OrganizeService organizeService) {
|
||||
StringBuilder organizeInfoVo = new StringBuilder();
|
||||
for (String id : organizeIds) {
|
||||
if (id != null) {
|
||||
StringBuilder organizeInfo = new StringBuilder();
|
||||
for (String name : getOrganizeInfos(new LinkedList<>(), id, 2, organizeService)) {
|
||||
organizeInfo.append(name).append("/");
|
||||
}
|
||||
// 去除最后一个斜杠
|
||||
if (organizeInfo.length() > 0) {
|
||||
organizeInfo = new StringBuilder(organizeInfo.substring(0, organizeInfo.length() - 1));
|
||||
}
|
||||
organizeInfo.append(",");
|
||||
organizeInfoVo.append(organizeInfo);
|
||||
}
|
||||
}
|
||||
return organizeInfoVo.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组名连接信息
|
||||
*
|
||||
* @param organizeId 组织id
|
||||
* @return 组织链式信息
|
||||
*/
|
||||
public static String getLinkInfoByOrgId(String organizeId, OrganizeService organizeService) {
|
||||
return getLinkInfoByOrgId(Collections.singletonList(organizeId), organizeService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去掉尾部的封号
|
||||
*/
|
||||
public static String getLinkInfoByOrgId(String organizeId, OrganizeService organizeService, Boolean separateFlag) {
|
||||
String linkInfo = getLinkInfoByOrgId(organizeId, organizeService);
|
||||
if (StringUtil.isEmpty(linkInfo)) {
|
||||
return linkInfo;
|
||||
}
|
||||
if (!separateFlag) {
|
||||
linkInfo = linkInfo.substring(0, linkInfo.length() - 1);
|
||||
}
|
||||
return linkInfo;
|
||||
}
|
||||
|
||||
public static List<String> getOrgIdsByFormTree(OrganizeService organizeService, List<List<String>> organizeIdsTree) throws DataException {
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
for (List<String> organizeIds : organizeIdsTree) {
|
||||
// 组织id数组树最后一个数组最后一个id,是需要储存的id
|
||||
String organizeId = organizeIds.get(organizeIds.size() - 1);
|
||||
orgIds.add(organizeId);
|
||||
}
|
||||
// 判断每个OrgId的有效性
|
||||
int count = organizeService.listByIds(orgIds).size();
|
||||
if (count != orgIds.size()) {
|
||||
throw new DataException(MsgCode.FA026.get());
|
||||
}
|
||||
return orgIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将树形数据移出
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> getListFromTree(List<Map<String, Object>> list) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Map<String, Object> map : list) {
|
||||
if (map.get("children") != null) {
|
||||
result.add(map);
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) map.get("children");
|
||||
result.addAll(getListFromTree(children));
|
||||
} else {
|
||||
result.add(map);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归讲list转换成树形
|
||||
*
|
||||
* @param list
|
||||
* @param parentField
|
||||
* @param childField
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> getTreeObj(List<Map<String, Object>> list, String parentField, String childField) {
|
||||
List<Map<String, Object>> result = new ArrayList<>(list);
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
Map<String, Object> item = result.get(i);
|
||||
if ((item.get(parentField) != null && !StringUtil.isNotEmpty(item.get(parentField).toString())) || (item.get(parentField) != null && !"[]".equals(item.get(parentField).toString()))) {
|
||||
if (hasChild(item, result, parentField, childField) && result.size() > 0) {
|
||||
result.remove(item);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子数据
|
||||
*
|
||||
* @param node
|
||||
* @param list
|
||||
* @param parentField
|
||||
* @param childField
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasChild(Map<String, Object> node, List<Map<String, Object>> list, String parentField, String childField) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> ele = list.get(i);
|
||||
if (ele.get(childField).equals(node.get(parentField))) {
|
||||
if (ele.get("children") == null) {
|
||||
ele.put("children", new ArrayList<>());
|
||||
}
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) ele.get("children");
|
||||
children.add(node);
|
||||
ele.put("children", children);
|
||||
return true;
|
||||
}
|
||||
if (ele.get("children") != null) {
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) ele.get("children");
|
||||
if (hasChild(node, children, parentField, childField)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yunzhupaas.permission.util.implicit;
|
||||
|
||||
import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.request.AuthDingTalkRequest;
|
||||
|
||||
/**
|
||||
* 免登陆接口 通用接口
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version v5.0.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/5/23 11:09:55
|
||||
*/
|
||||
public enum ImplicitDefaultSource implements AuthSource {
|
||||
WECHAT_ENTERPRISE {
|
||||
public String authorize() {
|
||||
return "https://open.weixin.qq.com/connect/oauth2/authorize";
|
||||
}
|
||||
|
||||
public String accessToken() {
|
||||
return "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
|
||||
}
|
||||
|
||||
public String userInfo() {
|
||||
return "https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo";
|
||||
}
|
||||
|
||||
public Class<? extends AuthDefaultRequest> getTargetClass() {
|
||||
return AuthDingTalkRequest.class;
|
||||
}
|
||||
},
|
||||
DINGTALK {
|
||||
public String authorize() {
|
||||
return "https://oapi.dingtalk.com/connect/oauth2/sns_authorize";
|
||||
}
|
||||
|
||||
public String accessToken() {
|
||||
return "https://oapi.dingtalk.com/gettoken";
|
||||
|
||||
}
|
||||
|
||||
public String userInfo() {
|
||||
return "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo";
|
||||
}
|
||||
|
||||
public Class<? extends AuthDefaultRequest> getTargetClass() {
|
||||
return AuthDingTalkRequest.class;
|
||||
}
|
||||
},
|
||||
;
|
||||
|
||||
private ImplicitDefaultSource() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunzhupaas.permission.util.implicit;
|
||||
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
|
||||
/**
|
||||
* 免登陆接口
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version v5.0.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/5/23 14:09:49
|
||||
*/
|
||||
public interface ImplicitLoginRequest {
|
||||
|
||||
/**
|
||||
* 获取网页授权链接
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getAuthLoginLink();
|
||||
|
||||
/**
|
||||
* 获取网页授权链接
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
AuthResponse getUserId(AuthCallback authCallback);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.yunzhupaas.permission.util.implicit;
|
||||
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.LoginException;
|
||||
import com.yunzhupaas.permission.util.implicit.request.ImplicitDingTalkRequest;
|
||||
import com.yunzhupaas.permission.util.implicit.request.ImplicitQywxRequest;
|
||||
import com.yunzhupaas.permission.util.socials.AuthCallbackNew;
|
||||
import com.yunzhupaas.permission.util.socials.SocialsConfig;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 免登工具类
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version v5.0.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/5/23 11:09:26
|
||||
*/
|
||||
@Component
|
||||
public class ImplicitLoginUtil {
|
||||
@Autowired
|
||||
private SocialsConfig socialsConfig;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
public String getAuthLink(String source) {
|
||||
ImplicitLoginRequest authRequest = this.getAuthRequest(source, null, null);
|
||||
return authRequest.getAuthLoginLink();
|
||||
}
|
||||
|
||||
public String loginByCode(String source, String code, String state) {
|
||||
//获取第三方请求
|
||||
AuthCallbackNew callback = new AuthCallbackNew();
|
||||
callback.setAuthCode(code);
|
||||
callback.setAuth_code(code);
|
||||
callback.setAuthorization_code(code);
|
||||
callback.setCode(code);
|
||||
callback.setState(state);
|
||||
ImplicitLoginRequest authRequest = this.getAuthRequest(source, null, null);
|
||||
AuthResponse<AuthUser> res = authRequest.getUserId(callback);
|
||||
if (AuthResponseStatus.FAILURE.getCode() == res.getCode()) {
|
||||
throw new LoginException("连接失败!");
|
||||
} else if (AuthResponseStatus.SUCCESS.getCode() != res.getCode()) {
|
||||
throw new LoginException("授权失败:" + res.getMsg());
|
||||
}
|
||||
//登录用户第三方id
|
||||
return getSocialUuid(res);
|
||||
}
|
||||
|
||||
private String getSocialUuid(AuthResponse<AuthUser> res) {
|
||||
String uuid = res.getData().getUuid();
|
||||
if (res.getData().getToken() != null && StringUtil.isNotEmpty(res.getData().getToken().getUnionId())) {
|
||||
uuid = res.getData().getToken().getUnionId();
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置信息获取请求对象
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/21
|
||||
*/
|
||||
public ImplicitLoginRequest getAuthRequest(String source, String userId, String tenantId) {
|
||||
ImplicitLoginRequest authRequest = null;
|
||||
String url = configValueUtil.getApiDomain() + "/api/oauth/Login/implicit";
|
||||
SocialsConfig.Config socialConfig;
|
||||
switch (source.toLowerCase()) {
|
||||
case "dingtalk":
|
||||
socialConfig = socialsConfig.getSocialMap().get("dingtalk");
|
||||
authRequest = new ImplicitDingTalkRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(url))
|
||||
.build());
|
||||
break;
|
||||
case "wechat_enterprise":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_enterprise");
|
||||
authRequest = new ImplicitQywxRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(url))
|
||||
.agentId(socialConfig.getAgentId())
|
||||
.build());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (null == authRequest) {
|
||||
throw new AuthException(MsgCode.OA024.get());
|
||||
}
|
||||
return authRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.yunzhupaas.permission.util.implicit.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.permission.util.implicit.ImplicitDefaultSource;
|
||||
import com.yunzhupaas.permission.util.implicit.ImplicitLoginRequest;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.log.Log;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
|
||||
public class ImplicitDingTalkRequest extends AuthDefaultRequest implements ImplicitLoginRequest {
|
||||
public ImplicitDingTalkRequest(AuthConfig config) {
|
||||
super(config, ImplicitDefaultSource.DINGTALK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthLoginLink() {
|
||||
return UrlBuilder.fromBaseUrl(this.source.authorize())
|
||||
.queryParam("appid", this.config.getClientId())
|
||||
.queryParam("redirect_uri", this.config.getRedirectUri())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("scope", "snsapi_auth")
|
||||
.queryParam("state", "STATE")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse getUserId(AuthCallback authCallback) {
|
||||
try {
|
||||
AuthToken authToken = AuthToken.builder()
|
||||
.code(authCallback.getCode()).build();
|
||||
AuthUser user = this.getUserByCode(authToken);
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();
|
||||
} catch (Exception var4) {
|
||||
Exception e = var4;
|
||||
Log.error("Failed to login with oauth authorization.", e);
|
||||
return this.responseError(e);
|
||||
}
|
||||
}
|
||||
|
||||
AuthResponse responseError(Exception e) {
|
||||
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
||||
String errorMsg = e.getMessage();
|
||||
if (e instanceof AuthException) {
|
||||
AuthException authException = (AuthException) e;
|
||||
errorCode = authException.getErrorCode();
|
||||
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
|
||||
errorMsg = authException.getErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 钉钉签名计算
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
private String getSignature(long time) {
|
||||
// 根据timestamp, appSecret计算签名值
|
||||
String appSecret = this.config.getClientSecret();
|
||||
// 根据timestamp, appSecret计算签名值
|
||||
String stringToSign = "" + time;
|
||||
Mac mac = null;
|
||||
try {
|
||||
mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(new SecretKeySpec(appSecret.getBytes("UTF-8"), "HmacSHA256"));
|
||||
byte[] signatureBytes = mac.doFinal(stringToSign.getBytes("UTF-8"));
|
||||
String signature = new String(Base64.encodeBase64(signatureBytes));
|
||||
if ("".equals(signature)) {
|
||||
return "";
|
||||
}
|
||||
String encoded = URLEncoder.encode(signature, "UTF-8");
|
||||
return encoded.replace("+", "%20").replace("*", "%2A").replace("~", "%7E").replace("/", "%2F");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String doGetUserByCode(AuthToken authToken) {
|
||||
long time = new Date().getTime();
|
||||
String signature = this.getSignature(time);
|
||||
String url = UrlBuilder.fromBaseUrl("https://oapi.dingtalk.com/sns/getuserinfo_bycode")
|
||||
.queryParam("accessKey", this.config.getClientId())
|
||||
.queryParam("timestamp", time)
|
||||
.queryParam("signature", signature)
|
||||
.build();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("tmp_auth_code", authToken.getCode());
|
||||
return (new HttpUtils(this.config.getHttpConfig())).post(url, map.toJSONString(), new HttpHeader().add("Content-Type", "application/json")).getBody();
|
||||
}
|
||||
|
||||
protected AuthUser getUserByCode(AuthToken authToken) {
|
||||
String response = this.doGetUserByCode(authToken);
|
||||
JSONObject object = this.checkResponse(response);
|
||||
if (object.get("user_info") != null) {
|
||||
JSONObject userInfo = (JSONObject) object.get("user_info");
|
||||
AuthToken token = AuthToken.builder().openId(userInfo.getString("openid")).unionId(userInfo.getString("unionid")).build();
|
||||
return AuthUser.builder().rawUserInfo(userInfo).uuid(userInfo.getString("unionid")).nickname(userInfo.getString("nick"))
|
||||
.username(object.getString("nick")).gender(AuthUserGender.UNKNOWN).source(this.source.toString()).token(token).build();
|
||||
} else {
|
||||
throw new AuthException(MsgCode.OA024.get());
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject checkResponse(String response) {
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
if (object.containsKey("errcode") && object.getIntValue("errcode") != 0) {
|
||||
throw new AuthException(object.getString("errmsg"), this.source);
|
||||
} else {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.permission.util.implicit.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunzhupaas.permission.util.implicit.ImplicitDefaultSource;
|
||||
import com.yunzhupaas.permission.util.implicit.ImplicitLoginRequest;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.log.Log;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
public class ImplicitQywxRequest extends AuthDefaultRequest implements ImplicitLoginRequest {
|
||||
|
||||
public ImplicitQywxRequest(AuthConfig config) {
|
||||
super(config, ImplicitDefaultSource.WECHAT_ENTERPRISE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthLoginLink() {
|
||||
return UrlBuilder.fromBaseUrl(this.source.authorize())
|
||||
.queryParam("appid", this.config.getClientId())
|
||||
.queryParam("redirect_uri", this.config.getRedirectUri())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("scope", "snsapi_privateinfo")
|
||||
.queryParam("agentid", this.config.getAgentId())
|
||||
.queryParam("state", "STATE#wechat_redirect")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthResponse getUserId(AuthCallback authCallback) {
|
||||
try {
|
||||
this.checkCode(authCallback);
|
||||
AuthToken authToken = this.getAccessToken(authCallback);
|
||||
AuthUser user = this.getUserInfo(authToken);
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();
|
||||
} catch (Exception var4) {
|
||||
Exception e = var4;
|
||||
Log.error("Failed to login with oauth authorization.", e);
|
||||
return this.responseError(e);
|
||||
}
|
||||
}
|
||||
|
||||
AuthResponse responseError(Exception e) {
|
||||
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
||||
String errorMsg = e.getMessage();
|
||||
if (e instanceof AuthException) {
|
||||
AuthException authException = (AuthException) e;
|
||||
errorCode = authException.getErrorCode();
|
||||
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
|
||||
errorMsg = authException.getErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
try {
|
||||
String response = this.doGetAccessToken();
|
||||
JSONObject object = this.checkResponse(response);
|
||||
AuthToken authToken = AuthToken.builder()
|
||||
.accessToken(object.getString("access_token"))
|
||||
.code(authCallback.getCode())
|
||||
.expireIn(object.getIntValue("expires_in")).build();
|
||||
return authToken;
|
||||
} catch (Exception var5) {
|
||||
Exception e = var5;
|
||||
throw new AuthException("企业微信获取token失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
String response = this.doGetUserInfo(authToken);
|
||||
JSONObject object = this.checkResponse(response);
|
||||
if (!object.containsKey("userid")) {
|
||||
throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, this.source);
|
||||
} else {
|
||||
return AuthUser.builder().rawUserInfo(object).uuid(object.getString("userid")).token(authToken).source(this.source.toString()).build();
|
||||
}
|
||||
}
|
||||
|
||||
protected String doGetAccessToken() {
|
||||
return (new HttpUtils(this.config.getHttpConfig())).get(this.accessTokenUrl()).getBody();
|
||||
}
|
||||
|
||||
protected String accessTokenUrl() {
|
||||
return UrlBuilder.fromBaseUrl(this.source.accessToken())
|
||||
.queryParam("corpid", this.config.getClientId())
|
||||
.queryParam("corpsecret", this.config.getClientSecret())
|
||||
.build();
|
||||
}
|
||||
|
||||
protected String doGetUserInfo(AuthToken authToken) {
|
||||
return (new HttpUtils(this.config.getHttpConfig())).get(this.userInfoUrl(authToken)).getBody();
|
||||
}
|
||||
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(this.source.userInfo())
|
||||
.queryParam("access_token", authToken.getAccessToken())
|
||||
.queryParam("code", authToken.getCode())
|
||||
.build();
|
||||
}
|
||||
|
||||
private JSONObject checkResponse(String response) {
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
if (object.containsKey("errcode") && object.getIntValue("errcode") != 0) {
|
||||
throw new AuthException(object.getString("errmsg"), this.source);
|
||||
} else {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/21 17:17:44
|
||||
*/
|
||||
@Data
|
||||
public class AuthCallbackNew extends AuthCallback {
|
||||
private String authCode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import me.zhyd.oauth.config.AuthSource;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.request.AuthDingTalkRequest;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/15 17:20:40
|
||||
*/
|
||||
public enum AuthDefaultSourceNew implements AuthSource {
|
||||
DINGTALK_NEW {
|
||||
public String authorize() {
|
||||
return "https://login.dingtalk.com/oauth2/auth";
|
||||
// return "https://oapi.dingtalk.com/connect/sns_authorize";
|
||||
}
|
||||
|
||||
public String accessToken() {
|
||||
return "https://api.dingtalk.com/v1.0/oauth2/userAccessToken";
|
||||
// return "https://oapi.dingtalk.com/gettoken";
|
||||
|
||||
}
|
||||
|
||||
public String userInfo() {
|
||||
return "https://api.dingtalk.com/v1.0/contact/users/me";
|
||||
// return "https://oapi.dingtalk.com/user/getuserinfo";
|
||||
}
|
||||
|
||||
public Class<? extends AuthDefaultRequest> getTargetClass() {
|
||||
return AuthDingTalkRequest.class;
|
||||
}
|
||||
},
|
||||
WECHAT_APPLETS {
|
||||
@Override
|
||||
public String authorize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String accessToken() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String userInfo() {
|
||||
return "https://api.weixin.qq.com/sns/jscode2session";
|
||||
}
|
||||
public Class<? extends AuthDefaultRequest> getTargetClass() {
|
||||
return AuthWechatAppletsRequest.class;
|
||||
}
|
||||
},;
|
||||
private AuthDefaultSourceNew() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.enums.AuthUserGender;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.log.Log;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/15 17:19:14
|
||||
*/
|
||||
public class AuthDingTalkNewRequest extends AuthDefaultRequest {
|
||||
|
||||
public AuthDingTalkNewRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSourceNew.DINGTALK_NEW);
|
||||
}
|
||||
|
||||
public AuthDingTalkNewRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSourceNew.DINGTALK_NEW, authStateCache);
|
||||
}
|
||||
|
||||
public String authorize(String state) {
|
||||
String encode = null;
|
||||
try {
|
||||
encode = URLEncoder.encode(this.config.getRedirectUri(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
;
|
||||
return UrlBuilder.fromBaseUrl(this.source.authorize()).queryParam("response_type", "code").queryParam("client_id", this.config.getClientId()).queryParam("scope", "openid").queryParam("redirect_uri", encode).queryParam("prompt", "consent").build();
|
||||
}
|
||||
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return this.getToken(this.accessTokenUrl(authCallback.getCode()), authCallback);
|
||||
}
|
||||
|
||||
protected String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(this.source.accessToken()).build();
|
||||
}
|
||||
|
||||
public AuthResponse login(AuthCallback authCallback) {
|
||||
try {
|
||||
this.checkCode(authCallback);
|
||||
AuthToken authToken = this.getAccessToken(authCallback);
|
||||
AuthUser user = this.getUserInfo(authToken);
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();
|
||||
} catch (Exception var4) {
|
||||
Log.error("Failed to login with oauth authorization.", var4);
|
||||
return this.responseError(var4);
|
||||
}
|
||||
}
|
||||
|
||||
AuthResponse responseError(Exception e) {
|
||||
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
||||
String errorMsg = e.getMessage();
|
||||
if (e instanceof AuthException) {
|
||||
AuthException authException = (AuthException) e;
|
||||
errorCode = authException.getErrorCode();
|
||||
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
|
||||
errorMsg = authException.getErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
|
||||
}
|
||||
|
||||
private AuthToken getToken(String accessTokenUrl, AuthCallback authCallback) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("clientId", this.config.getClientId());
|
||||
map.put("clientSecret", this.config.getClientSecret());
|
||||
map.put("code", authCallback.getCode());
|
||||
map.put("refreshToken", authCallback.getCode());
|
||||
map.put("grantType", "authorization_code");
|
||||
String response = (new HttpUtils(this.config.getHttpConfig())).post(accessTokenUrl, map.toJSONString(), new HttpHeader().add("Content-Type", "application/json")).getBody();
|
||||
JSONObject accessTokenObject = JSONObject.parseObject(response);
|
||||
this.checkResponse(accessTokenObject);
|
||||
return AuthToken.builder().accessToken(accessTokenObject.getString("accessToken")).refreshToken(accessTokenObject.getString("refreshToken")).expireIn(accessTokenObject.getIntValue("expireIn")).openId(accessTokenObject.getString("openid")).build();
|
||||
}
|
||||
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("errcode")) {
|
||||
throw new AuthException(object.getIntValue("errcode"), object.getString("errmsg"));
|
||||
}
|
||||
}
|
||||
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
HttpHeader httpHeader = new HttpHeader()
|
||||
.add("x-acs-dingtalk-access-token", authToken.getAccessToken())
|
||||
.add("Content-Type", "application/json");
|
||||
String response = (new HttpUtils(this.config.getHttpConfig())).get(this.userInfoUrl(authToken), null, httpHeader, false).getHttpResponse().getBody();
|
||||
JSONObject object = JSON.parseObject(response);
|
||||
if (object.get("unionId") != null) {
|
||||
AuthToken token = AuthToken.builder().openId(object.getString("openId")).unionId(object.getString("unionId")).build();
|
||||
return AuthUser.builder().rawUserInfo(object).uuid(object.getString("unionId")).nickname(object.getString("nick")).username(object.getString("nick")).gender(AuthUserGender.UNKNOWN).source(this.source.toString()).token(token).build();
|
||||
} else {
|
||||
throw new AuthException(MsgCode.OA024.get());
|
||||
}
|
||||
}
|
||||
|
||||
protected String userInfoUrl(AuthToken authToken) {
|
||||
return UrlBuilder.fromBaseUrl(this.source.userInfo()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.scope.*;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.request.*;
|
||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/21 12:00:56
|
||||
*/
|
||||
@Component
|
||||
public class AuthSocialsUtil {
|
||||
@Autowired
|
||||
private SocialsConfig socialsConfig;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
/**
|
||||
* 根据配置信息获取请求对象
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/21
|
||||
*/
|
||||
public AuthRequest getAuthRequest(String source, String userId, boolean isLogin, String ticket, String tenantId) {
|
||||
AuthRequest authRequest = null;
|
||||
String addUrlStr = "";
|
||||
String urlStr = configValueUtil.getApiDomain() + "/api/oauth/Login/socials?source=" + source;
|
||||
if (!isLogin) {
|
||||
urlStr = configValueUtil.getApiDomain() + "/api/oauth/Login/socials?source=" + source;
|
||||
}
|
||||
if (StringUtil.isNotEmpty(userId)) {
|
||||
addUrlStr = "&userId=" + userId;
|
||||
}
|
||||
if (StringUtil.isNotEmpty(ticket)) {
|
||||
addUrlStr = "&yunzhupaas_ticket=" + ticket;
|
||||
}
|
||||
if (StringUtil.isNotEmpty(tenantId)) {
|
||||
addUrlStr += "&tenantId=" + tenantId;
|
||||
}
|
||||
String url = urlStr + addUrlStr;
|
||||
SocialsConfig.Config socialConfig;
|
||||
switch (source.toLowerCase()) {
|
||||
//todo 官方登录api调整目前数据问题
|
||||
case "dingtalk":
|
||||
socialConfig = socialsConfig.getSocialMap().get("dingtalk");
|
||||
authRequest = new AuthDingTalkNewRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
//todo 未申请企业
|
||||
case "qq":
|
||||
socialConfig = socialsConfig.getSocialMap().get("qq");
|
||||
authRequest = new AuthQqRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "wechat_open":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_open");
|
||||
authRequest = new AuthWeChatOpenRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(url))
|
||||
.build());
|
||||
break;
|
||||
case "github":
|
||||
socialConfig = socialsConfig.getSocialMap().get("github");
|
||||
authRequest = new AuthGithubRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(url))
|
||||
.scopes(AuthScopeUtils.getScopes(AuthGithubScope.values()))
|
||||
// 针对国外平台配置代理
|
||||
// .httpConfig(HttpConfig.builder()
|
||||
// .timeout(15000)
|
||||
// .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
// .build())
|
||||
.build());
|
||||
break;
|
||||
case "wechat_enterprise":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_enterprise");
|
||||
authRequest = new AuthWeChatEnterpriseQrcodeRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(URLEncoder.encode(url))
|
||||
.agentId(socialConfig.getAgentId())
|
||||
.build());
|
||||
break;
|
||||
case "feishu":
|
||||
socialConfig = socialsConfig.getSocialMap().get("feishu");
|
||||
authRequest = new AuthFeishuRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "baidu":
|
||||
socialConfig = socialsConfig.getSocialMap().get("baidu");
|
||||
authRequest = new AuthBaiduRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(Arrays.asList(
|
||||
AuthBaiduScope.BASIC.getScope(),
|
||||
AuthBaiduScope.SUPER_MSG.getScope(),
|
||||
AuthBaiduScope.NETDISK.getScope()
|
||||
))
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .redirectUri("http://localhost:9001/oauth/baidu/callback")
|
||||
.build());
|
||||
break;
|
||||
case "gitee":
|
||||
socialConfig = socialsConfig.getSocialMap().get("gitee");
|
||||
authRequest = new AuthGiteeRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(AuthScopeUtils.getScopes(AuthGiteeScope.values()))
|
||||
.build());
|
||||
break;
|
||||
case "weibo":
|
||||
socialConfig = socialsConfig.getSocialMap().get("weibo");
|
||||
authRequest = new AuthWeiboRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(Arrays.asList(
|
||||
AuthWeiboScope.EMAIL.getScope(),
|
||||
AuthWeiboScope.FRIENDSHIPS_GROUPS_READ.getScope(),
|
||||
AuthWeiboScope.STATUSES_TO_ME_READ.getScope()
|
||||
))
|
||||
.build());
|
||||
break;
|
||||
case "coding":
|
||||
socialConfig = socialsConfig.getSocialMap().get("coding");
|
||||
authRequest = new AuthCodingRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.domainPrefix("")
|
||||
.scopes(Arrays.asList(
|
||||
AuthCodingScope.USER.getScope(),
|
||||
AuthCodingScope.USER_EMAIL.getScope(),
|
||||
AuthCodingScope.USER_PHONE.getScope()
|
||||
))
|
||||
.build());
|
||||
break;
|
||||
case "oschina":
|
||||
socialConfig = socialsConfig.getSocialMap().get("oschina");
|
||||
authRequest = new AuthOschinaRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "alipay":
|
||||
socialConfig = socialsConfig.getSocialMap().get("alipay");
|
||||
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip
|
||||
authRequest = new AuthAlipayRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.alipayPublicKey("")
|
||||
.build());
|
||||
break;
|
||||
case "csdn":
|
||||
socialConfig = socialsConfig.getSocialMap().get("csdn");
|
||||
authRequest = new AuthCsdnRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "taobao":
|
||||
socialConfig = socialsConfig.getSocialMap().get("taobao");
|
||||
authRequest = new AuthTaobaoRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "google":
|
||||
socialConfig = socialsConfig.getSocialMap().get("google");
|
||||
authRequest = new AuthGoogleRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(AuthScopeUtils.getScopes(AuthGoogleScope.USER_EMAIL, AuthGoogleScope.USER_PROFILE, AuthGoogleScope.USER_OPENID))
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
break;
|
||||
case "facebook":
|
||||
socialConfig = socialsConfig.getSocialMap().get("facebook");
|
||||
authRequest = new AuthFacebookRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(AuthScopeUtils.getScopes(AuthFacebookScope.values()))
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
break;
|
||||
case "douyin":
|
||||
socialConfig = socialsConfig.getSocialMap().get("douyin");
|
||||
authRequest = new AuthDouyinRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "linkedin":
|
||||
socialConfig = socialsConfig.getSocialMap().get("linkedin");
|
||||
authRequest = new AuthLinkedinRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(null)
|
||||
.build());
|
||||
break;
|
||||
case "microsoft":
|
||||
socialConfig = socialsConfig.getSocialMap().get("microsoft");
|
||||
authRequest = new AuthMicrosoftRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(Arrays.asList(
|
||||
AuthMicrosoftScope.USER_READ.getScope(),
|
||||
AuthMicrosoftScope.USER_READWRITE.getScope(),
|
||||
AuthMicrosoftScope.USER_READBASIC_ALL.getScope(),
|
||||
AuthMicrosoftScope.USER_READ_ALL.getScope(),
|
||||
AuthMicrosoftScope.USER_READWRITE_ALL.getScope(),
|
||||
AuthMicrosoftScope.USER_INVITE_ALL.getScope(),
|
||||
AuthMicrosoftScope.USER_EXPORT_ALL.getScope(),
|
||||
AuthMicrosoftScope.USER_MANAGEIDENTITIES_ALL.getScope(),
|
||||
AuthMicrosoftScope.FILES_READ.getScope()
|
||||
))
|
||||
.build());
|
||||
break;
|
||||
case "mi":
|
||||
socialConfig = socialsConfig.getSocialMap().get("mi");
|
||||
authRequest = new AuthMiRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "toutiao":
|
||||
socialConfig = socialsConfig.getSocialMap().get("toutiao");
|
||||
authRequest = new AuthToutiaoRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "teambition":
|
||||
socialConfig = socialsConfig.getSocialMap().get("teambition");
|
||||
authRequest = new AuthTeambitionRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "pinterest":
|
||||
socialConfig = socialsConfig.getSocialMap().get("pinterest");
|
||||
authRequest = new AuthPinterestRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
break;
|
||||
case "renren":
|
||||
socialConfig = socialsConfig.getSocialMap().get("renren");
|
||||
authRequest = new AuthRenrenRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "stack_overflow":
|
||||
socialConfig = socialsConfig.getSocialMap().get("stack_overflow");
|
||||
authRequest = new AuthStackOverflowRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.stackOverflowKey("")
|
||||
.build());
|
||||
break;
|
||||
case "huawei":
|
||||
socialConfig = socialsConfig.getSocialMap().get("huawei");
|
||||
authRequest = new AuthHuaweiRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(Arrays.asList(
|
||||
AuthHuaweiScope.BASE_PROFILE.getScope(),
|
||||
AuthHuaweiScope.MOBILE_NUMBER.getScope(),
|
||||
AuthHuaweiScope.ACCOUNTLIST.getScope(),
|
||||
AuthHuaweiScope.SCOPE_DRIVE_FILE.getScope(),
|
||||
AuthHuaweiScope.SCOPE_DRIVE_APPDATA.getScope()
|
||||
))
|
||||
.build());
|
||||
break;
|
||||
case "kujiale":
|
||||
socialConfig = socialsConfig.getSocialMap().get("kujiale");
|
||||
authRequest = new AuthKujialeRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "gitlab":
|
||||
socialConfig = socialsConfig.getSocialMap().get("gitlab");
|
||||
authRequest = new AuthGitlabRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.scopes(AuthScopeUtils.getScopes(AuthGitlabScope.values()))
|
||||
.build());
|
||||
break;
|
||||
case "meituan":
|
||||
socialConfig = socialsConfig.getSocialMap().get("meituan");
|
||||
authRequest = new AuthMeituanRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "eleme":
|
||||
socialConfig = socialsConfig.getSocialMap().get("eleme");
|
||||
authRequest = new AuthElemeRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
// case "mygitlab":
|
||||
// authRequest = new AuthMyGitlabRequest(AuthConfig.builder()
|
||||
// .clientId("")
|
||||
// .clientSecret("")
|
||||
// .redirectUri("http://127.0.0.1:8443/oauth/callback/mygitlab")
|
||||
// .build());
|
||||
// break;
|
||||
case "twitter":
|
||||
socialConfig = socialsConfig.getSocialMap().get("twitter");
|
||||
authRequest = new AuthTwitterRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
// 针对国外平台配置代理
|
||||
.httpConfig(HttpConfig.builder()
|
||||
.timeout(15000)
|
||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
|
||||
.build())
|
||||
.build());
|
||||
break;
|
||||
case "wechat_mp":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_mp");
|
||||
authRequest = new AuthWeChatMpRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "aliyun":
|
||||
socialConfig = socialsConfig.getSocialMap().get("aliyun");
|
||||
authRequest = new AuthAliyunRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "xmly":
|
||||
socialConfig = socialsConfig.getSocialMap().get("xmly");
|
||||
authRequest = new AuthXmlyRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
case "wechat_enterprise_web":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_enterprise_web");
|
||||
authRequest = new AuthWeChatEnterpriseWebRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.agentId(socialConfig.getAgentId())
|
||||
.build());
|
||||
break;
|
||||
case "wechat_applets":
|
||||
socialConfig = socialsConfig.getSocialMap().get("wechat_applets");
|
||||
authRequest = new AuthWechatAppletsRequest(AuthConfig.builder()
|
||||
.clientId(socialConfig.getClientId())
|
||||
.clientSecret(socialConfig.getClientSecret())
|
||||
.redirectUri(url)
|
||||
.build());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (null == authRequest) {
|
||||
throw new AuthException(MsgCode.OA024.get());
|
||||
}
|
||||
return authRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.exception.AuthException;
|
||||
import me.zhyd.oauth.log.Log;
|
||||
import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.request.AuthDefaultRequest;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.StringUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/16 12:11:36
|
||||
*/
|
||||
public class AuthWechatAppletsRequest extends AuthDefaultRequest {
|
||||
public AuthWechatAppletsRequest(AuthConfig config) {
|
||||
super(config, AuthDefaultSourceNew.WECHAT_APPLETS);
|
||||
}
|
||||
|
||||
public AuthWechatAppletsRequest(AuthConfig config, AuthStateCache authStateCache) {
|
||||
super(config, AuthDefaultSourceNew.WECHAT_APPLETS, authStateCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthUser getUserInfo(AuthToken authToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getuserInfoUrl(AuthCallback authCallback) {
|
||||
return UrlBuilder.fromBaseUrl(this.source.userInfo())
|
||||
.queryParam("appid", this.config.getClientId())
|
||||
.queryParam("secret", this.config.getClientSecret())
|
||||
.queryParam("js_code",authCallback.getCode())
|
||||
.queryParam("grant_type", "authorization_code").build();
|
||||
|
||||
}
|
||||
|
||||
AuthResponse responseError(Exception e) {
|
||||
int errorCode = AuthResponseStatus.FAILURE.getCode();
|
||||
String errorMsg = e.getMessage();
|
||||
if (e instanceof AuthException) {
|
||||
AuthException authException = (AuthException) e;
|
||||
errorCode = authException.getErrorCode();
|
||||
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
|
||||
errorMsg = authException.getErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
|
||||
}
|
||||
public AuthResponse login(AuthCallback authCallback) {
|
||||
try {
|
||||
AuthUser user = this.getUserUnionid(authCallback);
|
||||
return AuthResponse.builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();
|
||||
} catch (Exception var4) {
|
||||
Log.error("Failed to login with oauth authorization.", var4);
|
||||
return this.responseError(var4);
|
||||
}
|
||||
}
|
||||
|
||||
protected AuthUser getUserUnionid(AuthCallback authCallback) {
|
||||
String response = (new HttpUtils(this.config.getHttpConfig())).get(this.getuserInfoUrl(authCallback)).getBody();
|
||||
JSONObject object = JSONObject.parseObject(response);
|
||||
AuthToken authToken=new AuthToken();
|
||||
if (object.containsKey("unionid")) {
|
||||
authToken.setUnionId(object.getString("unionid"));
|
||||
}
|
||||
return AuthUser.builder().rawUserInfo(object).token(authToken).source(this.source.toString()).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单点登录枚举
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 10:10:30
|
||||
*/
|
||||
public enum SocialsAuthEnum {
|
||||
WECHAT_OPEN("微信", "/cdn/socials/wechat_open.png", "绑定微信后,用户可通过微信扫码登录YUNZHUPAAS系统。",
|
||||
"", "v1.1.0", true, "icon-ym icon-ym-logo-wechat"),
|
||||
QQ("QQ", "/cdn/socials/qq.png", "绑定QQ后,用户可通过QQ扫码登录YUNZHUPAAS系统。",
|
||||
"", "v1.1.0", true, "icon-ym icon-ym-logo-qq"),
|
||||
WECHAT_ENTERPRISE("企业微信", "/cdn/socials/wxWork.png", "绑定企业微信后,您可在网页端扫码登录, 在企业微信应用内和小程序免登录, 并能实时接收小程序通知,沟通和协作将更加便捷。",
|
||||
"", "v1.10.0", true, "icon-ym icon-ym-logo-wxWork"),
|
||||
DINGTALK("钉钉", "/cdn/socials/dingtalk.png", "绑定阿里钉钉后,您可在网页端扫码登录并能接收相关通知。",
|
||||
"", "v1.0.1", true, "icon-ym icon-ym-logo-dingding"),
|
||||
FEISHU("飞书", "/cdn/socials/feishu.png", "绑定飞书后,用户可扫码登录 YUNZHUPAAS。",
|
||||
"", "1.15.9", true, "icon-ym icon-ym-logo-feishu"),
|
||||
GITHUB("Github", "/cdn/socials/gitHub.png", "绑定GitHub后,用户可扫码登录 YUNZHUPAAS。",
|
||||
"", "v1.0.1", true, "icon-ym icon-ym-logo-github"),
|
||||
GITEE("Gitee", "", "绑定Gitee后,用户可登录 YUNZHUPAAS。",
|
||||
"", "v1.0.1", false, "icon-ym icon-ym-logo-github"),
|
||||
;
|
||||
|
||||
// 平台名
|
||||
private final String name;
|
||||
// 帮助文档
|
||||
private final String logo;
|
||||
// 描述
|
||||
private final String describetion;
|
||||
// 官网api文档
|
||||
private final String apiDoc;
|
||||
// 集成该平台的 版本
|
||||
private final String since;
|
||||
// 首页展示
|
||||
private final boolean latest;
|
||||
// 官网api文档
|
||||
private final String icon;
|
||||
|
||||
SocialsAuthEnum(String name, String logo, String describetion, String apiDoc, String since, boolean latest,
|
||||
String icon) {
|
||||
this.name = name;
|
||||
this.logo = logo;
|
||||
this.describetion = describetion;
|
||||
this.apiDoc = apiDoc;
|
||||
this.since = since;
|
||||
this.latest = latest;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> getPlatformInfos() {
|
||||
List<Map<String, Object>> list = new LinkedList<>();
|
||||
Map<String, Object> map = null;
|
||||
SocialsAuthEnum[] justAuthPlatformInfos = SocialsAuthEnum.values();
|
||||
for (SocialsAuthEnum justAuthPlatformInfo : justAuthPlatformInfos) {
|
||||
map = new HashMap<>();
|
||||
map.put("name", justAuthPlatformInfo.getName());
|
||||
map.put("logo", justAuthPlatformInfo.getLogo());
|
||||
map.put("describetion", justAuthPlatformInfo.getDescribetion());
|
||||
map.put("apiDoc", justAuthPlatformInfo.getApiDoc());
|
||||
map.put("since", justAuthPlatformInfo.getSince());
|
||||
map.put("enname", justAuthPlatformInfo.name().toLowerCase());
|
||||
map.put("isLatest", justAuthPlatformInfo.isLatest());
|
||||
map.put("icon", justAuthPlatformInfo.getIcon());
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public String getDescribetion() {
|
||||
return describetion;
|
||||
}
|
||||
|
||||
public String getApiDoc() {
|
||||
return apiDoc;
|
||||
}
|
||||
|
||||
public String getSince() {
|
||||
return since;
|
||||
}
|
||||
|
||||
public boolean isLatest() {
|
||||
return latest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.yunzhupaas.permission.util.socials;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/6 14:58:23
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = SocialsConfig.PREFIX)
|
||||
public class SocialsConfig {
|
||||
public static final String PREFIX = "socials";
|
||||
|
||||
private boolean socialsEnabled = false;
|
||||
|
||||
private List<Config> config;
|
||||
|
||||
private Map<String, Config> socialMap;
|
||||
|
||||
public SocialsConfig() {
|
||||
}
|
||||
|
||||
public SocialsConfig(List<Config> config, Map<String, Config> socialMap) {
|
||||
this.config = config;
|
||||
this.socialMap = socialMap;
|
||||
}
|
||||
|
||||
public boolean isSocialsEnabled() {
|
||||
return socialsEnabled;
|
||||
}
|
||||
|
||||
public void setSocialsEnabled(boolean socialsEnabled) {
|
||||
this.socialsEnabled = socialsEnabled;
|
||||
}
|
||||
|
||||
public void setConfig(List<Config> config) {
|
||||
this.config = config;
|
||||
this.socialMap = new HashMap<>();
|
||||
config.stream().forEach(item -> {
|
||||
this.socialMap.put(item.getProvider(), item);
|
||||
});
|
||||
}
|
||||
|
||||
public List<Config> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public Map<String, Config> getSocialMap() {
|
||||
return socialMap;
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
private String provider;
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String agentId;
|
||||
|
||||
public Config() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Config config = (Config) o;
|
||||
return Objects.equals(provider, config.provider) && Objects.equals(clientId, config.clientId) && Objects.equals(clientSecret, config.clientSecret) && Objects.equals(agentId, config.agentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(provider, clientId, clientSecret, agentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Config{" +
|
||||
"provider='" + provider + '\'' +
|
||||
", clientId='" + clientId + '\'' +
|
||||
", clientSecret='" + clientSecret + '\'' +
|
||||
", agentId='" + agentId + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider(String provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public String getAgentId() {
|
||||
return agentId;
|
||||
}
|
||||
|
||||
public void setAgentId(String agentId) {
|
||||
this.agentId = agentId;
|
||||
}
|
||||
|
||||
public Config(String provider, String clientId, String clientSecret, String agentId) {
|
||||
this.provider = provider;
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
this.agentId = agentId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-permission</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-permission-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-permission-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-exception</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
package com.yunzhupaas.permission.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.DictionaryTypeService;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.permission.entity.GroupEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.model.user.mod.UserIdModel;
|
||||
import com.yunzhupaas.permission.model.usergroup.*;
|
||||
import com.yunzhupaas.permission.service.GroupService;
|
||||
import com.yunzhupaas.permission.service.UserRelationService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.enums.DictionaryDataEnum;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.newtreeutil.TreeDotUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分组管理控制器
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/10 17:57
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = "分组管理", description = "UserGroupController")
|
||||
@RequestMapping("/api/permission/Group")
|
||||
public class GroupController extends SuperController<GroupService, GroupEntity> {
|
||||
|
||||
@Autowired
|
||||
private GroupService userGroupService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private DictionaryTypeService dictionaryTypeApi;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
|
||||
/**
|
||||
* 获取分组管理列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取分组管理列表")
|
||||
@SaCheckPermission(value = {"permission.group"})
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<GroupPaginationVO>> list(PaginationGroup pagination) {
|
||||
List<GroupEntity> list = userGroupService.getList(pagination);
|
||||
List<GroupPaginationVO> jsonToList = JsonUtil.getJsonToList(list, GroupPaginationVO.class);
|
||||
// 通过数据字典获取类型
|
||||
List<DictionaryDataEntity> dictionaryDataEntities = dictionaryDataApi.getList(dictionaryTypeApi.getInfoByEnCode(DictionaryDataEnum.PERMISSION_GROUP.getDictionaryTypeId()).getId());
|
||||
for (GroupPaginationVO userGroupPaginationVO : jsonToList) {
|
||||
DictionaryDataEntity dictionaryDataEntity = dictionaryDataEntities.stream().filter(t -> t.getId().equals(userGroupPaginationVO.getType())).findFirst().orElse(null);
|
||||
userGroupPaginationVO.setType(dictionaryDataEntity != null ? dictionaryDataEntity.getFullName() : userGroupPaginationVO.getId());
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(jsonToList, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组管理下拉框
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取分组管理下拉框")
|
||||
@GetMapping("/Selector")
|
||||
public ActionResult<List<GroupSelectorVO>> selector() {
|
||||
List<GroupTreeModel> tree = new ArrayList<>();
|
||||
List<GroupEntity> data = userGroupService.list();
|
||||
List<DictionaryDataEntity> dataEntityList = dictionaryDataApi.getList(dictionaryTypeApi.getInfoByEnCode(DictionaryDataEnum.PERMISSION_GROUP.getDictionaryTypeId()).getId());
|
||||
// 获取分组管理外层菜单
|
||||
for (DictionaryDataEntity dictionaryDataEntity : dataEntityList) {
|
||||
GroupTreeModel firstModel = JsonUtil.getJsonToBean(dictionaryDataEntity, GroupTreeModel.class);
|
||||
firstModel.setId(dictionaryDataEntity.getId());
|
||||
firstModel.setType("0");
|
||||
long num = data.stream().filter(t -> t.getType().equals(dictionaryDataEntity.getId())).count();
|
||||
firstModel.setNum(num);
|
||||
if (num > 0) {
|
||||
tree.add(firstModel);
|
||||
}
|
||||
}
|
||||
for (GroupEntity entity : data) {
|
||||
GroupTreeModel treeModel = JsonUtil.getJsonToBean(entity, GroupTreeModel.class);
|
||||
treeModel.setType("group");
|
||||
treeModel.setParentId(entity.getType());
|
||||
treeModel.setIcon("icon-ym icon-ym-generator-group1");
|
||||
treeModel.setId(entity.getId());
|
||||
DictionaryDataEntity dataEntity = dictionaryDataApi.getInfo(entity.getType());
|
||||
if (dataEntity != null) {
|
||||
tree.add(treeModel);
|
||||
}
|
||||
}
|
||||
List<SumTree<GroupTreeModel>> sumTrees = TreeDotUtils.convertListToTreeDot(tree);
|
||||
List<GroupSelectorVO> list = JsonUtil.getJsonToList(sumTrees, GroupSelectorVO.class);
|
||||
ListVO<GroupSelectorVO> vo = new ListVO<>();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义范围获取分组下拉框
|
||||
*
|
||||
* @param idModel 岗位选择模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "自定义范围获取分组下拉框")
|
||||
@Parameters({
|
||||
@Parameter(name = "positionConditionModel", description = "岗位选择模型", required = true)
|
||||
})
|
||||
@PostMapping("/GroupCondition")
|
||||
public ActionResult<ListVO<GroupSelectorVO>> positionCondition(@RequestBody UserIdModel idModel) {
|
||||
List<GroupEntity> data = userGroupService.getListByIds(idModel.getIds(), true);
|
||||
List<GroupTreeModel> tree = new ArrayList<>();
|
||||
List<DictionaryDataEntity> dataEntityList = dictionaryDataApi.getListByTypeDataCode(DictionaryDataEnum.PERMISSION_GROUP.getDictionaryTypeId());
|
||||
// 获取分组管理外层菜单
|
||||
for (DictionaryDataEntity dictionaryDataEntity : dataEntityList) {
|
||||
GroupTreeModel firstModel = JsonUtil.getJsonToBean(dictionaryDataEntity, GroupTreeModel.class);
|
||||
firstModel.setId(dictionaryDataEntity.getId());
|
||||
firstModel.setType("0");
|
||||
long num = data.stream().filter(t -> t.getType().equals(dictionaryDataEntity.getId())).count();
|
||||
firstModel.setNum(num);
|
||||
if (num > 0) {
|
||||
tree.add(firstModel);
|
||||
}
|
||||
}
|
||||
for (GroupEntity entity : data) {
|
||||
GroupTreeModel treeModel = JsonUtil.getJsonToBean(entity, GroupTreeModel.class);
|
||||
treeModel.setType("group");
|
||||
treeModel.setParentId(entity.getType());
|
||||
treeModel.setIcon("icon-ym icon-ym-generator-group1");
|
||||
treeModel.setId(entity.getId());
|
||||
DictionaryDataEntity dataEntity = dictionaryDataApi.getInfo(entity.getType());
|
||||
if (dataEntity != null) {
|
||||
tree.add(treeModel);
|
||||
}
|
||||
}
|
||||
List<SumTree<GroupTreeModel>> sumTrees = TreeDotUtils.convertListToTreeDot(tree);
|
||||
List<GroupSelectorVO> list = JsonUtil.getJsonToList(sumTrees, GroupSelectorVO.class);
|
||||
ListVO<GroupSelectorVO> vo = new ListVO<>();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.group"})
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<GroupInfoVO> info(@PathVariable("id") String id) {
|
||||
GroupEntity entity = userGroupService.getInfo(id);
|
||||
GroupInfoVO vo = JsonUtil.getJsonToBean(entity, GroupInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param userGroupCrForm 新建模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "userGroupCrForm", description = "新建模型", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.group"})
|
||||
@PostMapping
|
||||
public ActionResult create(@RequestBody @Valid GroupCrForm userGroupCrForm) {
|
||||
GroupEntity entity = JsonUtil.getJsonToBean(userGroupCrForm, GroupEntity.class);
|
||||
// 判断名称是否重复
|
||||
if (userGroupService.isExistByFullName(entity.getFullName(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
// 判断编码是否重复
|
||||
if (userGroupService.isExistByEnCode(entity.getEnCode(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
userGroupService.crete(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param userGroupUpForm 修改模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "userGroupUpForm", description = "修改模型", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.group"})
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid GroupUpForm userGroupUpForm) {
|
||||
GroupEntity groupEntity = userGroupService.getInfo(id);
|
||||
if (groupEntity == null) {
|
||||
return ActionResult.fail(MsgCode.FA013.get());
|
||||
}
|
||||
if ((groupEntity.getEnabledMark() == 1 && userGroupUpForm.getEnabledMark() == 0)
|
||||
&& userRelationService.getListByObjectId(id, PermissionConst.GROUP).size() > 0) {
|
||||
return ActionResult.fail(MsgCode.FA030.get());
|
||||
}
|
||||
GroupEntity entity = JsonUtil.getJsonToBean(userGroupUpForm, GroupEntity.class);
|
||||
// 判断名称是否重复
|
||||
if (userGroupService.isExistByFullName(entity.getFullName(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
// 判断编码是否重复
|
||||
if (userGroupService.isExistByEnCode(entity.getEnCode(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
userGroupService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.group"})
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
GroupEntity entity = userGroupService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
List<UserRelationEntity> bingUserByRoleList = userRelationService.getListByObjectId(id, PermissionConst.GROUP);
|
||||
if (bingUserByRoleList.size() > 0) {
|
||||
return ActionResult.fail(MsgCode.FA024.get());
|
||||
}
|
||||
userGroupService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,719 @@
|
||||
package com.yunzhupaas.permission.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.entity.*;
|
||||
import com.yunzhupaas.base.model.portalManage.PortalModel;
|
||||
import com.yunzhupaas.base.model.print.PaginationPrint;
|
||||
import com.yunzhupaas.base.model.print.PrintDevTreeModel;
|
||||
import com.yunzhupaas.base.model.vo.PrintDevVO;
|
||||
import com.yunzhupaas.base.service.*;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.model.template.TemplateTreeListVo;
|
||||
import com.yunzhupaas.model.FlowWorkModel;
|
||||
import com.yunzhupaas.permission.constant.AuthorizeConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.model.permissiongroup.*;
|
||||
import com.yunzhupaas.permission.model.user.UserIdListVo;
|
||||
import com.yunzhupaas.permission.model.user.mod.UserIdModel;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.newtreeutil.TreeDotUtils;
|
||||
import com.yunzhupaas.workflow.service.TemplateApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "权限组控制器", description = "PermissionGroup")
|
||||
@RequestMapping("/api/permission/PermissionGroup")
|
||||
public class PermissionGroupController extends SuperController<PermissionGroupService, PermissionGroupEntity> {
|
||||
|
||||
@Autowired
|
||||
private PermissionGroupService permissionGroupService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
@Autowired
|
||||
private ModuleButtonService buttonApi;
|
||||
@Autowired
|
||||
private ModuleColumnService columnApi;
|
||||
@Autowired
|
||||
private ModuleFormService formApi;
|
||||
@Autowired
|
||||
private ModuleDataAuthorizeSchemeService schemeApi;
|
||||
@Autowired
|
||||
private SystemService systemApi;
|
||||
@Autowired
|
||||
private ModuleService moduleApi;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private PositionService positionService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
@Autowired
|
||||
private TemplateApi templateApi;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private PrintDevService printDevApi;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<PermissionGroupListVO>> list(PaginationPermissionGroup pagination) {
|
||||
List<PermissionGroupEntity> data = permissionGroupService.list(pagination);
|
||||
List<PermissionGroupListVO> list = JsonUtil.getJsonToList(data, PermissionGroupListVO.class);
|
||||
list.forEach(t -> {
|
||||
String permissionMember = t.getPermissionMember();
|
||||
if (StringUtil.isEmpty(permissionMember)) {
|
||||
t.setPermissionMember("");
|
||||
return;
|
||||
}
|
||||
List<String> fullNameByIds = userService.getFullNameByIds(Arrays.asList(permissionMember.split(",")));
|
||||
StringJoiner stringJoiner = new StringJoiner(",");
|
||||
fullNameByIds.forEach(stringJoiner::add);
|
||||
t.setPermissionMember(stringJoiner.toString());
|
||||
});
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉选择
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "下拉框")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@GetMapping("/Selector")
|
||||
public ActionResult<ListVO<FlowWorkModel>> list() {
|
||||
List<PermissionGroupEntity> data = permissionGroupService.list(true, null);
|
||||
List<FlowWorkModel> list = JsonUtil.getJsonToList(data, FlowWorkModel.class);
|
||||
list.forEach(t -> t.setIcon("icon-ym icon-ym-authGroup"));
|
||||
ListVO<FlowWorkModel> listVO = new ListVO<>();
|
||||
listVO.setList(list);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看权限成员
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "权限成员")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
@GetMapping("/PermissionMember/{id}")
|
||||
public ActionResult<ListVO<UserIdListVo>> permissionMember(@PathVariable("id") String id) {
|
||||
PermissionGroupEntity entity = permissionGroupService.permissionMember(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
ListVO<UserIdListVo> listVO = new ListVO<>();
|
||||
List<UserIdListVo> list = new ArrayList<>();
|
||||
if (StringUtil.isEmpty(entity.getPermissionMember())) {
|
||||
listVO.setList(list);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
List<String> ids = Arrays.asList(entity.getPermissionMember().split(",")).stream().distinct().collect(Collectors.toList());
|
||||
list = userService.selectedByIds(ids);
|
||||
listVO.setList(list);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存权限成员
|
||||
*
|
||||
* @param id 主键
|
||||
* @param userIdModel 用户id模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "保存权限成员")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "userIdModel", description = "用户id模型", required = true)
|
||||
})
|
||||
@PostMapping("/PermissionMember/{id}")
|
||||
public ActionResult<ListVO<UserIdListVo>> savePermissionMember(@PathVariable("id") String id, @RequestBody UserIdModel userIdModel) {
|
||||
PermissionGroupEntity entity = permissionGroupService.info(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
//删除退出的用户
|
||||
List<String> oldPermission = StringUtil.isNotEmpty(entity.getPermissionMember()) ? Arrays.asList(entity.getPermissionMember().split(",")) : new ArrayList<>();
|
||||
// List<String> permission = userIdModel.getIds();
|
||||
// List<String> allUpdateIds = oldPermission.stream().filter(t->!permission.contains(t)).collect(Collectors.toList());
|
||||
List<String> deleteUser = userService.getUserIdList(oldPermission, null);
|
||||
//保存新的用户
|
||||
StringJoiner stringJoiner = new StringJoiner(",");
|
||||
List<String> userId = userIdModel.getIds();
|
||||
userId.forEach(t -> {
|
||||
stringJoiner.add(t);
|
||||
});
|
||||
entity.setPermissionMember(stringJoiner.toString());
|
||||
// 修改前的用户
|
||||
List<String> member = permissionGroupService.list(Collections.singletonList(id))
|
||||
.stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).map(PermissionGroupEntity::getPermissionMember).collect(Collectors.toList());
|
||||
// 新的用户
|
||||
member.addAll(userId);
|
||||
member = member.stream().distinct().collect(Collectors.toList());
|
||||
List<String> userIdList = userService.getUserIdList(member, null);
|
||||
permissionGroupService.update(id, entity);
|
||||
userService.delCurRoleUser(MsgCode.PS010.get(), Collections.singletonList(id));
|
||||
//移除权限缓存
|
||||
authorizeService.removeAuthByUserOrMenu(deleteUser, null);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "详情")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<PermissionGroupModel> info(@PathVariable("id") String id) {
|
||||
PermissionGroupEntity entity = permissionGroupService.info(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
PermissionGroupModel model = JsonUtil.getJsonToBean(entity, PermissionGroupModel.class);
|
||||
return ActionResult.success(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param model 模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameter(name = "id", description = "模型", required = true)
|
||||
@PostMapping
|
||||
public ActionResult<String> crete(@RequestBody PermissionGroupModel model) {
|
||||
PermissionGroupEntity entity = JsonUtil.getJsonToBean(model, PermissionGroupEntity.class);
|
||||
if (permissionGroupService.isExistByFullName(entity.getId(), entity)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (permissionGroupService.isExistByEnCode(entity.getId(), entity)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
permissionGroupService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param id 主键
|
||||
* @param model 模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "model", description = "模型", required = true)
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult<String> update(@PathVariable("id") String id, @RequestBody PermissionGroupModel model) {
|
||||
PermissionGroupEntity entity = JsonUtil.getJsonToBean(model, PermissionGroupEntity.class);
|
||||
if (permissionGroupService.isExistByFullName(id, entity)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (permissionGroupService.isExistByEnCode(id, entity)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
userService.delCurRoleUser(MsgCode.PS010.get(), Collections.singletonList(id));
|
||||
permissionGroupService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult<String> delete(@PathVariable("id") String id) {
|
||||
PermissionGroupEntity entity = permissionGroupService.info(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
userService.delCurRoleUser(MsgCode.PS010.get(), ImmutableList.of(id));
|
||||
permissionGroupService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制")
|
||||
@SaCheckPermission("permission.authorize")
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
@Transactional
|
||||
public ActionResult<String> copy(@PathVariable("id") String id) {
|
||||
PermissionGroupEntity entity = permissionGroupService.info(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA004.get());
|
||||
}
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
|
||||
if (entity.getFullName().length() > 50) return ActionResult.fail(MsgCode.COPY001.get());
|
||||
entity.setEnCode(entity.getEnCode() + copyNum);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setEnabledMark(0);
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getLoginUserId());
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
permissionGroupService.save(entity);
|
||||
// 赋值权限表
|
||||
List<AuthorizeEntity> listByObjectId = authorizeService.getListByObjectId(Collections.singletonList(id));
|
||||
listByObjectId.forEach(t -> {
|
||||
t.setId(RandomUtil.uuId());
|
||||
t.setObjectId(entity.getId());
|
||||
});
|
||||
authorizeService.saveBatch(listByObjectId);
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取菜单权限返回权限组
|
||||
*
|
||||
* @param model 模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "获取菜单权限返回权限组")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@GetMapping("/getPermissionGroup")
|
||||
public ActionResult<Map<String, Object>> getPermissionGroup(ViewPermissionsModel model) {
|
||||
String objectType = model.getObjectType();
|
||||
String id = model.getId();
|
||||
if (checkDataById(id, objectType)) {
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
int type = 0; // 0未开启权限,1有
|
||||
List<FlowWorkModel> list = new ArrayList<>();
|
||||
List<PermissionGroupEntity> permissionGroupByUserId = permissionGroupService.getPermissionGroupByObjectId(id, objectType);
|
||||
// List<String> roleId = permissionGroupByUserId.stream().map(PermissionGroupEntity::getId).collect(Collectors.toList());
|
||||
// List<AuthorizeEntity> authorizeByItem = authorizeService.getListByObjectId(roleId);
|
||||
list = JsonUtil.getJsonToList(permissionGroupByUserId, FlowWorkModel.class);
|
||||
list.forEach(t -> t.setIcon("icon-ym icon-ym-authGroup"));
|
||||
if (list.size() > 0) {
|
||||
type = 1;
|
||||
} else {
|
||||
type = 2;
|
||||
}
|
||||
map.put("list", list);
|
||||
map.put("type", type);
|
||||
return ActionResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过权限组id获取相关权限
|
||||
*
|
||||
* @param model 模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "通过权限组id获取相关权限")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "权限组id", required = true)
|
||||
})
|
||||
@GetMapping("/getPermission")
|
||||
public ActionResult<List<ViewPermissionsVO>> getPermission(ViewPermissionsModel model) {
|
||||
String objectType = model.getObjectType();
|
||||
String id = model.getId();
|
||||
String permissionId = model.getPermissionId();
|
||||
if (StringUtil.isEmpty(permissionId)) {
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
// 获取当前菜单开启了哪些权限
|
||||
if (checkDataById(id, objectType)) {
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
PermissionGroupEntity permissionGroupEntity = permissionGroupService.info(permissionId);
|
||||
if (permissionGroupEntity == null) {
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
String itemType = model.getItemType();
|
||||
// 权限组的权限
|
||||
List<AuthorizeEntity> authList = authorizeService.getListByObjectId(Collections.singletonList(permissionId));
|
||||
List<ViewPermissionsTreeModel> list = new ArrayList<>();
|
||||
if (AuthorizeConst.SYSTEM.equals(itemType)) {
|
||||
list = this.system(authList, itemType);
|
||||
} else if (AuthorizeConst.MODULE.equals(itemType)) {
|
||||
list = this.module(authList, itemType);
|
||||
} else if (AuthorizeConst.BUTTON.equals(itemType)) {
|
||||
list = this.button(authList, itemType);
|
||||
} else if (AuthorizeConst.COLUMN.equals(itemType)) {
|
||||
list = this.column(authList, itemType);
|
||||
} else if (AuthorizeConst.FROM.equals(itemType)) {
|
||||
list = this.form(authList, itemType);
|
||||
} else if (AuthorizeConst.RESOURCE.equals(itemType)) {
|
||||
list = this.resources(authList, itemType);
|
||||
} else if (AuthorizeConst.AUTHORIZE_PORTAL_MANAGE.equals(itemType)) {
|
||||
list = this.portal(authList, itemType);
|
||||
} else if (AuthorizeConst.FLOW.equals(itemType)) {
|
||||
list = this.flow(authList, itemType);
|
||||
} else if (AuthorizeConst.PRINT.equals(itemType)) {
|
||||
list = this.print(authList, itemType);
|
||||
}
|
||||
list = list.stream().sorted(Comparator.comparing(ViewPermissionsTreeModel::getSortCode, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(ViewPermissionsTreeModel::getCreatorTime, Comparator.nullsLast(Comparator.reverseOrder()))).collect(Collectors.toList());
|
||||
List<SumTree<ViewPermissionsTreeModel>> sumTrees = TreeDotUtils.convertListToTreeDot(list);
|
||||
List<ViewPermissionsVO> jsonToList = JsonUtil.getJsonToList(sumTrees, ViewPermissionsVO.class);
|
||||
return ActionResult.success(jsonToList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有系统信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> system(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
return JsonUtil.getJsonToList(systemApi.getListByIds(ids, null), ViewPermissionsTreeModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有菜单信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> module(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> systemList = this.system(authList, AuthorizeConst.SYSTEM);
|
||||
systemList.forEach(systemEntity -> systemEntity.setParentId("-1"));
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<ModuleEntity> moduleByIds = moduleApi.getModuleByIds(ids, null, null, false);
|
||||
Map<String, List<ModuleEntity>> systemGroupMap = moduleByIds.stream().collect(Collectors.groupingBy(ModuleEntity::getSystemId));
|
||||
List<ModuleEntity> categoryList = new ArrayList<>();
|
||||
Date datetime = new Date();
|
||||
if (systemGroupMap != null) {
|
||||
ids.forEach(systemId -> {
|
||||
List<ModuleEntity> moduleEntities = systemGroupMap.get(systemId);
|
||||
if (moduleEntities != null && moduleEntities.size() > 0) {
|
||||
Map<String, List<ModuleEntity>> categoryMap = moduleEntities.stream().collect(Collectors.groupingBy(ModuleEntity::getCategory));
|
||||
if (categoryMap != null) {
|
||||
List<ModuleEntity> webModuleList = categoryMap.get("Web");
|
||||
if (webModuleList != null && webModuleList.size() > 0) {
|
||||
ModuleEntity entity = new ModuleEntity();
|
||||
entity.setParentId(webModuleList.get(0).getSystemId());
|
||||
entity.setId(webModuleList.get(0).getSystemId() + "1");
|
||||
entity.setFullName("WEB菜单");
|
||||
entity.setIcon("icon-ym icon-ym-pc");
|
||||
entity.setSortCode(-1L);
|
||||
entity.setCreatorTime(datetime);
|
||||
categoryList.add(entity);
|
||||
}
|
||||
List<ModuleEntity> appModuleList = categoryMap.get("App");
|
||||
if (appModuleList != null && appModuleList.size() > 0) {
|
||||
ModuleEntity entity = new ModuleEntity();
|
||||
entity.setParentId(appModuleList.get(0).getSystemId());
|
||||
entity.setId(appModuleList.get(0).getSystemId() + "2");
|
||||
entity.setFullName("APP菜单");
|
||||
entity.setIcon("icon-ym icon-ym-mobile");
|
||||
entity.setSortCode(0L);
|
||||
entity.setCreatorTime(datetime);
|
||||
categoryList.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
moduleByIds.addAll(categoryList);
|
||||
moduleByIds.forEach(t -> {
|
||||
if ("-1".equals(t.getParentId())) {
|
||||
if ("Web".equals(t.getCategory())) {
|
||||
t.setParentId(t.getSystemId() + "1");
|
||||
} else {
|
||||
t.setParentId(t.getSystemId() + "2");
|
||||
}
|
||||
}
|
||||
});
|
||||
List<ViewPermissionsTreeModel> moduleList = JsonUtil.getJsonToList(moduleByIds, ViewPermissionsTreeModel.class);
|
||||
List<String> systemId = moduleByIds.stream().map(ModuleEntity::getSystemId).distinct().collect(Collectors.toList());
|
||||
List<ViewPermissionsTreeModel> collect = systemList.stream().filter(t -> systemId.contains(t.getId())).collect(Collectors.toList());
|
||||
moduleList.addAll(collect);
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有按钮权限信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> button(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> module = this.module(authList, AuthorizeConst.MODULE);
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<ModuleButtonEntity> listByIds = buttonApi.getListByIds(ids);
|
||||
listByIds.forEach(t -> t.setParentId(t.getModuleId()));
|
||||
List<ViewPermissionsTreeModel> moduleList = JsonUtil.getJsonToList(listByIds, ViewPermissionsTreeModel.class);
|
||||
Map<String, ViewPermissionsTreeModel> moduleModel = module.stream().collect(Collectors.toMap(ViewPermissionsTreeModel::getId, Function.identity()));
|
||||
// 上级菜单id
|
||||
List<String> moduleIds = listByIds.stream().map(ModuleButtonEntity::getModuleId).distinct().collect(Collectors.toList());
|
||||
moduleIds.forEach(t -> {
|
||||
ViewPermissionsTreeModel viewPermissionsTreeModel = moduleModel.get(t);
|
||||
moduleList.add(viewPermissionsTreeModel);
|
||||
getParentModule(moduleModel, viewPermissionsTreeModel.getParentId(), moduleList);
|
||||
});
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有列表权限信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> column(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> module = this.module(authList, AuthorizeConst.MODULE);
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<ModuleColumnEntity> listByIds = columnApi.getListByIds(ids);
|
||||
listByIds.forEach(t -> t.setParentId(t.getModuleId()));
|
||||
List<ViewPermissionsTreeModel> moduleList = JsonUtil.getJsonToList(listByIds, ViewPermissionsTreeModel.class);
|
||||
Map<String, ViewPermissionsTreeModel> moduleModel = module.stream().collect(Collectors.toMap(ViewPermissionsTreeModel::getId, Function.identity()));
|
||||
// 上级菜单id
|
||||
List<String> moduleIds = listByIds.stream().map(ModuleColumnEntity::getModuleId).distinct().collect(Collectors.toList());
|
||||
moduleIds.forEach(t -> {
|
||||
ViewPermissionsTreeModel viewPermissionsTreeModel = moduleModel.get(t);
|
||||
moduleList.add(viewPermissionsTreeModel);
|
||||
getParentModule(moduleModel, viewPermissionsTreeModel.getParentId(), moduleList);
|
||||
});
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有表单权限信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> form(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> module = this.module(authList, AuthorizeConst.MODULE);
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<ModuleFormEntity> listByIds = formApi.getListByIds(ids);
|
||||
listByIds.forEach(t -> t.setParentId(t.getModuleId()));
|
||||
List<ViewPermissionsTreeModel> moduleList = JsonUtil.getJsonToList(listByIds, ViewPermissionsTreeModel.class);
|
||||
Map<String, ViewPermissionsTreeModel> moduleModel = module.stream().collect(Collectors.toMap(ViewPermissionsTreeModel::getId, Function.identity()));
|
||||
// 上级菜单id
|
||||
List<String> moduleIds = listByIds.stream().map(ModuleFormEntity::getModuleId).distinct().collect(Collectors.toList());
|
||||
moduleIds.forEach(t -> {
|
||||
ViewPermissionsTreeModel viewPermissionsTreeModel = moduleModel.get(t);
|
||||
moduleList.add(viewPermissionsTreeModel);
|
||||
getParentModule(moduleModel, viewPermissionsTreeModel.getParentId(), moduleList);
|
||||
});
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有数据权限信息
|
||||
*
|
||||
* @param authList
|
||||
* @param itemType
|
||||
* @return
|
||||
*/
|
||||
private List<ViewPermissionsTreeModel> resources(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> module = this.module(authList, AuthorizeConst.MODULE);
|
||||
List<String> ids = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<ModuleDataAuthorizeSchemeEntity> listByIds = schemeApi.getListByIds(ids);
|
||||
List<ViewPermissionsTreeModel> moduleList = JsonUtil.getJsonToList(listByIds, ViewPermissionsTreeModel.class);
|
||||
moduleList.forEach(t -> t.setParentId(t.getModuleId()));
|
||||
Map<String, ViewPermissionsTreeModel> moduleModel = module.stream().collect(Collectors.toMap(ViewPermissionsTreeModel::getId, Function.identity()));
|
||||
// 上级菜单id
|
||||
List<String> moduleIds = listByIds.stream().map(ModuleDataAuthorizeSchemeEntity::getModuleId).distinct().collect(Collectors.toList());
|
||||
moduleIds.forEach(t -> {
|
||||
ViewPermissionsTreeModel viewPermissionsTreeModel = moduleModel.get(t);
|
||||
moduleList.add(viewPermissionsTreeModel);
|
||||
getParentModule(moduleModel, viewPermissionsTreeModel.getParentId(), moduleList);
|
||||
});
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
private List<ViewPermissionsTreeModel> portal(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<String> ids = authList.stream().filter(t -> AuthorizeConst.SYSTEM.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
List<PortalModel> myPortalList = new ArrayList<>();
|
||||
List<SystemEntity> mySystemList = systemApi.getListByIds(ids, null);
|
||||
List<String> collect = authList.stream().filter(t -> itemType.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
if (ObjectUtil.isEmpty(collect)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
authorizeService.getPortal(mySystemList, myPortalList, System.currentTimeMillis(), collect);
|
||||
return JsonUtil.getJsonToList(myPortalList.stream().sorted(Comparator.comparing(PortalModel::getSortCode).thenComparing(PortalModel::getCreatorTime).reversed()).collect(Collectors.toList()), ViewPermissionsTreeModel.class);
|
||||
}
|
||||
|
||||
private List<ViewPermissionsTreeModel> flow(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> listVO = new ArrayList<>();
|
||||
List<AuthorizeEntity> authorizeList = authList.stream().filter(t -> itemType.equals(t.getItemType())).collect(Collectors.toList());
|
||||
List<String> itemId = authorizeList.stream().map(AuthorizeEntity::getItemId).distinct().collect(Collectors.toList());
|
||||
if (itemId.isEmpty()) {
|
||||
return listVO;
|
||||
}
|
||||
List<TemplateEntity> list = templateApi.getListByFlowIds(itemId);
|
||||
List<String> category = list.stream().map(TemplateEntity::getCategory).collect(Collectors.toList());
|
||||
List<DictionaryDataEntity> dictionName = dictionaryDataApi.getDictionName(category);
|
||||
List<ViewPermissionsTreeModel> childListAll = new ArrayList<>();
|
||||
Long date = System.currentTimeMillis();
|
||||
for (DictionaryDataEntity dict : dictionName) {
|
||||
ViewPermissionsTreeModel vo = JsonUtil.getJsonToBean(dict, ViewPermissionsTreeModel.class);
|
||||
vo.setSortCode(0L);
|
||||
vo.setCreatorTime(date);
|
||||
List<TemplateEntity> childList = list.stream()
|
||||
.filter(e -> dict.getId().equals(e.getCategory()))
|
||||
.sorted(Comparator.comparing(TemplateEntity::getSortCode).thenComparing(TemplateEntity::getCreatorTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
if (childList.size() > 0) {
|
||||
listVO.add(vo);
|
||||
for (TemplateEntity entity : childList) {
|
||||
ViewPermissionsTreeModel user = JsonUtil.getJsonToBean(entity, ViewPermissionsTreeModel.class);
|
||||
user.setParentId(dict.getId());
|
||||
childListAll.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
listVO.addAll(childListAll);
|
||||
return listVO;
|
||||
}
|
||||
|
||||
private List<ViewPermissionsTreeModel> print(List<AuthorizeEntity> authList, String itemType) {
|
||||
List<ViewPermissionsTreeModel> listVO = new ArrayList<>();
|
||||
List<AuthorizeEntity> authorizeList = authList.stream().filter(t -> itemType.equals(t.getItemType())).collect(Collectors.toList());
|
||||
List<String> itemId = authorizeList.stream().map(AuthorizeEntity::getItemId).distinct().collect(Collectors.toList());
|
||||
if (itemId.isEmpty()) {
|
||||
return listVO;
|
||||
}
|
||||
List<PrintDevEntity> list = printDevApi.getWorkSelector(itemId);
|
||||
List<String> category = list.stream().map(PrintDevEntity::getCategory).collect(Collectors.toList());
|
||||
List<DictionaryDataEntity> dictionName = dictionaryDataApi.getDictionName(category);
|
||||
List<ViewPermissionsTreeModel> childListAll = new ArrayList<>();
|
||||
Long date = System.currentTimeMillis();
|
||||
for (DictionaryDataEntity dict : dictionName) {
|
||||
ViewPermissionsTreeModel vo = JsonUtil.getJsonToBean(dict, ViewPermissionsTreeModel.class);
|
||||
vo.setSortCode(0L);
|
||||
vo.setCreatorTime(date);
|
||||
List<PrintDevEntity> childList = list.stream()
|
||||
.filter(e -> dict.getId().equals(e.getCategory()))
|
||||
.sorted(Comparator.comparing(PrintDevEntity::getSortCode).thenComparing(PrintDevEntity::getCreatorTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
if (childList.size() > 0) {
|
||||
listVO.add(vo);
|
||||
for (PrintDevEntity entity : childList) {
|
||||
ViewPermissionsTreeModel user = JsonUtil.getJsonToBean(entity, ViewPermissionsTreeModel.class);
|
||||
user.setParentId(dict.getId());
|
||||
childListAll.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
listVO.addAll(childListAll);
|
||||
return listVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级菜单
|
||||
*
|
||||
* @param moduleModel
|
||||
* @param parentId
|
||||
* @param moduleList
|
||||
*/
|
||||
private void getParentModule(Map<String, ViewPermissionsTreeModel> moduleModel, String parentId, List<ViewPermissionsTreeModel> moduleList) {
|
||||
if (!"-1".equals(parentId)) {
|
||||
if (moduleModel.get(parentId) != null) {
|
||||
moduleList.add(moduleModel.get(parentId));
|
||||
this.getParentModule(moduleModel, moduleModel.get(parentId).getParentId(), moduleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证对象数据是否存在
|
||||
*
|
||||
* @param id
|
||||
* @param objectType
|
||||
* @return
|
||||
*/
|
||||
private boolean checkDataById(String id, String objectType) {
|
||||
if (PermissionConst.COMPANY.equals(objectType) || PermissionConst.DEPARTMENT.equals(objectType)) {
|
||||
// 获取当前菜单开启了哪些权限
|
||||
OrganizeEntity entity = organizeService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return true;
|
||||
}
|
||||
} else if ("position".equals(objectType)) {
|
||||
PositionEntity entity = positionService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return true;
|
||||
}
|
||||
} else if ("user".equals(objectType)) {
|
||||
UserEntity entity = userService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return true;
|
||||
}
|
||||
} else if ("role".equals(objectType)) {
|
||||
RoleEntity entity = roleService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return true;
|
||||
}
|
||||
} else if ("group".equals(objectType)) {
|
||||
GroupEntity entity = groupService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,976 @@
|
||||
package com.yunzhupaas.permission.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.annotation.PositionPermission;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.ExcelColumnAttr;
|
||||
import com.yunzhupaas.model.ExcelImportForm;
|
||||
import com.yunzhupaas.model.ExcelImportVO;
|
||||
import com.yunzhupaas.model.ExcelModel;
|
||||
import com.yunzhupaas.permission.constant.PosColumnMap;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.model.check.CheckResult;
|
||||
import com.yunzhupaas.permission.model.permission.PermissionModel;
|
||||
import com.yunzhupaas.permission.model.position.*;
|
||||
import com.yunzhupaas.permission.model.user.UserIdListVo;
|
||||
import com.yunzhupaas.permission.model.user.mod.UserIdModel;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.base.util.ExcelTool;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.util.enums.DictionaryDataEnum;
|
||||
import com.yunzhupaas.util.treeutil.ListToTreeUtil;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.newtreeutil.TreeDotUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 岗位信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "岗位管理", description = "Position")
|
||||
@RestController
|
||||
@RequestMapping("/api/permission/Position")
|
||||
public class PositionController extends SuperController<PositionService, PositionEntity> {
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private PositionService positionService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private OrganizeRelationService organizeRelationService;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
/**
|
||||
* 获取岗位管理信息列表
|
||||
*
|
||||
* @param paginationPosition 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取岗位列表(分页)")
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<PositionListVO>> list(PaginationPosition paginationPosition) {
|
||||
List<DictionaryDataEntity> dictionaryDataEntities = dictionaryDataApi.getListByTypeDataCode(DictionaryDataEnum.POSITION_TYPE.getDictionaryTypeId());
|
||||
if (StringUtil.isNotEmpty(paginationPosition.getType())) {
|
||||
DictionaryDataEntity dictionaryDataEntity = dictionaryDataEntities.stream().filter(t -> paginationPosition.getType().equals(t.getId())).findFirst().orElse(null);
|
||||
if (dictionaryDataEntity != null) {
|
||||
paginationPosition.setEnCode(dictionaryDataEntity.getEnCode());
|
||||
}
|
||||
}
|
||||
List<PositionEntity> data = positionService.getList(paginationPosition);
|
||||
//添加部门信息,部门映射到organizeId
|
||||
List<PositionListVO> voList = JsonUtil.getJsonToList(data, PositionListVO.class);
|
||||
List<String> collect = data.stream().map(PositionEntity::getOrganizeId).collect(Collectors.toList());
|
||||
List<OrganizeEntity> list = organizeService.getOrgEntityList(collect, true);
|
||||
//添加部门信息
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
for (PositionListVO entity1 : voList) {
|
||||
OrganizeEntity entity = list.stream().filter(t -> t.getId().equals(entity1.getOrganizeId())).findFirst().orElse(new OrganizeEntity());
|
||||
if (entity1.getOrganizeId().equals(entity.getId())) {
|
||||
entity1.setDepartment(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, entity.getOrganizeIdTree(), "/"));
|
||||
}
|
||||
}
|
||||
//将type成中文名
|
||||
for (PositionListVO entity1 : voList) {
|
||||
dictionaryDataEntities.stream().filter(t -> t.getEnCode().equals(entity1.getType())).findFirst().ifPresent(entity -> entity1.setType(entity.getFullName()));
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationPosition, PaginationVO.class);
|
||||
return ActionResult.page(voList, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping("/All")
|
||||
public ActionResult<ListVO<PositionListAllVO>> listAll() {
|
||||
List<PositionEntity> list = positionService.getList(true);
|
||||
List<PositionListAllVO> vos = JsonUtil.getJsonToList(list, PositionListAllVO.class);
|
||||
ListVO<PositionListAllVO> vo = new ListVO<>();
|
||||
vo.setList(vos);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 树形(机构+岗位)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取岗位下拉列表(公司+部门+岗位)")
|
||||
@GetMapping("/Selector")
|
||||
public ActionResult<ListVO<PositionSelectorVO>> selector() {
|
||||
List<PositionEntity> list1 = positionService.getList(true);
|
||||
Map<String, OrganizeEntity> orgMaps = organizeService.getOrgMaps(null, false, null);
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
List<OrganizeEntity> list2 = new ArrayList<>(orgMaps.values());
|
||||
;
|
||||
List<PosOrgModel> posList = new ArrayList<>();
|
||||
for (PositionEntity entity : list1) {
|
||||
PosOrgModel posOrgModel = JsonUtil.getJsonToBean(entity, PosOrgModel.class);
|
||||
String organizeId = entity.getOrganizeId();
|
||||
posOrgModel.setParentId(organizeId);
|
||||
posOrgModel.setType("position");
|
||||
posOrgModel.setIcon("icon-ym icon-ym-tree-position1");
|
||||
OrganizeEntity organizeEntity = orgMaps.get(organizeId);
|
||||
if (organizeEntity != null) {
|
||||
posOrgModel.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/"));
|
||||
posOrgModel.setOrganizeIds(organizeService.getOrgIdTree(organizeEntity));
|
||||
} else {
|
||||
posOrgModel.setOrganizeIds(new ArrayList<>());
|
||||
}
|
||||
posList.add(posOrgModel);
|
||||
}
|
||||
List<PosOrgModel> orgList = JsonUtil.getJsonToList(list2, PosOrgModel.class);
|
||||
for (PosOrgModel entity1 : orgList) {
|
||||
if ("department".equals(entity1.getType())) {
|
||||
entity1.setIcon("icon-ym icon-ym-tree-department1");
|
||||
} else if ("company".equals(entity1.getType())) {
|
||||
entity1.setIcon("icon-ym icon-ym-tree-organization3");
|
||||
}
|
||||
OrganizeEntity organizeEntity = orgMaps.get(entity1.getId());
|
||||
if (organizeEntity != null) {
|
||||
entity1.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/"));
|
||||
entity1.setOrganizeIds(organizeService.getOrgIdTree(organizeEntity));
|
||||
} else {
|
||||
entity1.setOrganizeIds(new ArrayList<>());
|
||||
}
|
||||
entity1.setOrganizeIds(new ArrayList<>());
|
||||
}
|
||||
JSONArray objects = ListToTreeUtil.treeWhere(posList, orgList);
|
||||
List<PosOrgModel> jsonToList = JsonUtil.getJsonToList(objects, PosOrgModel.class);
|
||||
|
||||
List<PosOrgModel> list = new ArrayList<>(16);
|
||||
// 得到角色的值
|
||||
List<PosOrgModel> collect = jsonToList.stream().filter(t -> "position".equals(t.getType())).sorted(Comparator.comparing(PosOrgModel::getSortCode)).collect(Collectors.toList());
|
||||
list.addAll(collect);
|
||||
jsonToList.removeAll(collect);
|
||||
List<PosOrgModel> collect1 = jsonToList.stream().sorted(Comparator.comparing(PosOrgModel::getSortCode).thenComparing(PosOrgModel::getCreatorTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
list.addAll(collect1);
|
||||
|
||||
List<SumTree<PosOrgModel>> trees = TreeDotUtils.convertListToTreeDot(list);
|
||||
List<PositionSelectorVO> jsonToList1 = JsonUtil.getJsonToList(trees, PositionSelectorVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(jsonToList1);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过部门、岗位获取岗位下拉框
|
||||
*
|
||||
* @param idModel 岗位选择模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "通过部门、岗位获取岗位下拉框")
|
||||
@Parameters({
|
||||
@Parameter(name = "positionConditionModel", description = "岗位选择模型", required = true)
|
||||
})
|
||||
@PostMapping("/PositionCondition")
|
||||
public ActionResult<ListVO<PositionSelectorVO>> positionCondition(@RequestBody UserIdModel idModel) {
|
||||
// 定义返回对象
|
||||
List<PositionSelectorVO> modelList = new ArrayList<>();
|
||||
|
||||
List<String> list = organizeRelationService.getOrgIds(idModel.getIds(), null);
|
||||
List<String> lists = new ArrayList<>();
|
||||
list.forEach(t -> lists.add(t.split("--")[0]));
|
||||
list = lists;
|
||||
List<String> collect = positionService.getListByOrganizeId(list, false).stream().map(PositionEntity::getId).collect(Collectors.toList());
|
||||
collect.addAll(list);
|
||||
List<PositionEntity> positionName = positionService.getPositionName(collect, null);
|
||||
positionName = positionName.stream().filter(t -> "1".equals(String.valueOf(t.getEnabledMark()))).collect(Collectors.toList());
|
||||
|
||||
Map<String, OrganizeEntity> orgMaps = organizeService.getOrganizeName(positionName.stream().map(PositionEntity::getOrganizeId).collect(Collectors.toList()), null, false, null);
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
|
||||
List<PosOrgConditionModel> posOrgModels = new ArrayList<>(16);
|
||||
positionName.forEach(t -> {
|
||||
PosOrgConditionModel posOrgModel = JsonUtil.getJsonToBean(t, PosOrgConditionModel.class);
|
||||
OrganizeEntity entity = orgMaps.get(t.getOrganizeId());
|
||||
if (entity != null) {
|
||||
posOrgModel.setOrganizeId(entity.getId());
|
||||
posOrgModel.setParentId(entity.getId());
|
||||
if (StringUtil.isNotEmpty(entity.getOrganizeIdTree())) {
|
||||
posOrgModel.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, entity.getOrganizeIdTree(), "/"));
|
||||
}
|
||||
}
|
||||
posOrgModel.setType("position");
|
||||
posOrgModel.setIcon("icon-ym icon-ym-tree-position1");
|
||||
posOrgModels.add(posOrgModel);
|
||||
});
|
||||
|
||||
// 处理组织
|
||||
orgMaps.values().forEach(org -> {
|
||||
PosOrgConditionModel orgVo = JsonUtil.getJsonToBean(org, PosOrgConditionModel.class);
|
||||
if ("department".equals(orgVo.getType())) {
|
||||
orgVo.setIcon("icon-ym icon-ym-tree-department1");
|
||||
} else if ("company".equals(orgVo.getType())) {
|
||||
orgVo.setIcon("icon-ym icon-ym-tree-organization3");
|
||||
}
|
||||
// 处理断层
|
||||
if (StringUtil.isNotEmpty(org.getOrganizeIdTree())) {
|
||||
List<String> list1 = new ArrayList<>();
|
||||
String[] split = org.getOrganizeIdTree().split(",");
|
||||
list1 = Arrays.asList(split);
|
||||
Collections.reverse(list1);
|
||||
for (String orgId : list1) {
|
||||
OrganizeEntity organizeEntity1 = orgMaps.get(orgId);
|
||||
if (organizeEntity1 != null && !organizeEntity1.getId().equals(orgVo.getId())) {
|
||||
orgVo.setParentId(organizeEntity1.getId());
|
||||
String[] split1 = org.getOrganizeIdTree().split(organizeEntity1.getId());
|
||||
if (split1.length > 1) {
|
||||
orgVo.setFullName(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, split1[1], "/"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
posOrgModels.add(orgVo);
|
||||
});
|
||||
|
||||
List<SumTree<PosOrgConditionModel>> trees = TreeDotUtils.convertListToTreeDot(posOrgModels);
|
||||
List<PositionSelectorVO> positionSelectorVO = JsonUtil.getJsonToList(trees, PositionSelectorVO.class);
|
||||
// 处理数据
|
||||
positionSelectorVO.forEach(t -> {
|
||||
if (!"position".equals(t.getType())) {
|
||||
t.setFullName(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, t.getOrganizeIdTree(), "/"));
|
||||
}
|
||||
});
|
||||
modelList.addAll(positionSelectorVO);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(modelList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过组织id获取岗位列表
|
||||
*
|
||||
* @param organizeId 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "通过组织id获取岗位列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "organizeId", description = "主键值", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping("/getList/{organizeId}")
|
||||
public ActionResult<List<PositionVo>> getListByOrganizeId(@PathVariable("organizeId") String organizeId) {
|
||||
List<PositionEntity> list = positionService.getListByOrganizeId(Collections.singletonList(organizeId), false);
|
||||
List<PositionVo> jsonToList = JsonUtil.getJsonToList(list, PositionVo.class);
|
||||
return ActionResult.success(jsonToList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位管理信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取岗位管理信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<PositionInfoVO> getInfo(@PathVariable("id") String id) throws DataException {
|
||||
PositionEntity entity = positionService.getInfo(id);
|
||||
PositionInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, PositionInfoVO.class);
|
||||
String organizeId = entity.getOrganizeId();
|
||||
OrganizeEntity organizeEntity = organizeService.getInfo(organizeId);
|
||||
vo.setOrganizeIdTree(StringUtil.isNotEmpty(organizeEntity.getOrganizeIdTree()) ? Arrays.asList(organizeEntity.getOrganizeIdTree().split(",")) : new ArrayList<>());
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新建岗位管理
|
||||
*
|
||||
* @param positionCrForm 实体对象
|
||||
* @return
|
||||
*/
|
||||
@PositionPermission
|
||||
@Operation(summary = "新建岗位管理")
|
||||
@Parameters({
|
||||
@Parameter(name = "positionCrForm", description = "实体对象", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@PostMapping
|
||||
public ActionResult create(@RequestBody @Valid PositionCrForm positionCrForm) {
|
||||
PositionEntity entity = JsonUtil.getJsonToBean(positionCrForm, PositionEntity.class);
|
||||
if (positionService.isExistByFullName(entity, false)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (positionService.isExistByEnCode(entity, false)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
// 设置岗位id
|
||||
entity.setId(RandomUtil.uuId());
|
||||
// createOrganizeRoleRelation(entity.getOrganizeId(), entity.getId());
|
||||
positionService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新岗位管理
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param positionUpForm 实体对象
|
||||
* @return
|
||||
*/
|
||||
@PositionPermission
|
||||
@Operation(summary = "更新岗位管理")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true),
|
||||
@Parameter(name = "positionUpForm", description = "实体对象", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid PositionUpForm positionUpForm) {
|
||||
PositionEntity positionEntity = positionService.getInfo(id);
|
||||
if (positionEntity == null) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
// 当岗位绑定用户不让其更改
|
||||
if (userRelationService.existByObj(PermissionConst.POSITION, id)) {
|
||||
if (!positionService.getInfo(id).getOrganizeId().equals(positionUpForm.getOrganizeId())) {
|
||||
return ActionResult.fail(MsgCode.FA023.get());
|
||||
}
|
||||
if (positionUpForm.getEnabledMark() == 0 && positionEntity.getEnabledMark() == 1) {
|
||||
return ActionResult.fail(MsgCode.FA030.get());
|
||||
}
|
||||
}
|
||||
PositionEntity entity = JsonUtil.getJsonToBean(positionUpForm, PositionEntity.class);
|
||||
entity.setId(id);
|
||||
if (positionService.isExistByFullName(entity, true)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (positionService.isExistByEnCode(entity, true)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
// createOrganizeRoleRelation(entity.getOrganizeId(), id);
|
||||
boolean flag = positionService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位管理
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@PositionPermission
|
||||
@Operation(summary = "删除岗位管理")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
// 当岗位绑定用户不让其更改
|
||||
if (userRelationService.existByObj(PermissionConst.POSITION, id)) {
|
||||
return ActionResult.fail(MsgCode.FA024.get());
|
||||
}
|
||||
PositionEntity entity = positionService.getInfo(id);
|
||||
if (entity != null) {
|
||||
List<UserRelationEntity> userRelList = userRelationService.getListByObjectId(id);
|
||||
if (userRelList.size() > 0) {
|
||||
return ActionResult.fail(MsgCode.FA024.get());
|
||||
}
|
||||
for (UserRelationEntity entity1 : userRelList) {
|
||||
UserEntity entity2 = userService.getById(entity1.getUserId());
|
||||
if (entity2 != null) {
|
||||
String newPositionId = entity2.getPositionId().replace(id, "");
|
||||
if (entity2.getPositionId().contains(id)) {
|
||||
if (newPositionId.length() != 0 && newPositionId.substring(0, 1).equals(",")) {
|
||||
entity2.setPositionId(newPositionId.substring(1));
|
||||
} else if (newPositionId.length() != 0) {
|
||||
entity2.setPositionId(newPositionId.replace(",,", ","));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userRelationService.deleteAllByObjId(id);
|
||||
|
||||
// 删除岗位与组织之间的关联数据
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.POSITION);
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectId, id);
|
||||
organizeRelationService.remove(query);
|
||||
|
||||
positionService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单状态
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新菜单状态")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@PutMapping("/{id}/Actions/State")
|
||||
public ActionResult upState(@PathVariable("id") String id) {
|
||||
PositionEntity entity = positionService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if (entity.getEnabledMark() == null || "1".equals(String.valueOf(entity.getEnabledMark()))) {
|
||||
entity.setEnabledMark(0);
|
||||
} else {
|
||||
entity.setEnabledMark(1);
|
||||
}
|
||||
positionService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过组织id获取岗位列表
|
||||
*
|
||||
* @param organizeIds 组织id数组
|
||||
* @return 岗位列表
|
||||
*/
|
||||
@Operation(summary = "获取岗位列表通过组织id数组")
|
||||
@Parameters({
|
||||
@Parameter(name = "organizeIds", description = "组织id数组", required = true)
|
||||
})
|
||||
@SaCheckPermission("permission.position")
|
||||
@PostMapping("/getListByOrgIds")
|
||||
public ActionResult<ListVO<PermissionModel>> getListByOrganizeIds(@RequestBody @Valid Map<String, List<String>> organizeIds) {
|
||||
List<PermissionModel> PositionModelAll = new LinkedList<>();
|
||||
if (organizeIds.get("organizeIds") != null) {
|
||||
List<String> ids = organizeIds.get("organizeIds");
|
||||
PositionModelAll = positionService.getListByOrganizeIds(ids, false,true);
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(PositionModelAll);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加组织角色关联关系
|
||||
*
|
||||
* @param organizeId 组织id
|
||||
* @param positionId 岗位id
|
||||
*/
|
||||
private void createOrganizeRoleRelation(String organizeId, String positionId) {
|
||||
// 清除之前的关联关系
|
||||
QueryWrapper<OrganizeRelationEntity> query = new QueryWrapper<>();
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectType, PermissionConst.POSITION);
|
||||
query.lambda().eq(OrganizeRelationEntity::getObjectId, positionId);
|
||||
organizeRelationService.remove(query);
|
||||
// 添加与组织的关联关系
|
||||
OrganizeRelationEntity organizeRelationEntity = new OrganizeRelationEntity();
|
||||
organizeRelationEntity.setId(RandomUtil.uuId());
|
||||
organizeRelationEntity.setOrganizeId(organizeId);
|
||||
organizeRelationEntity.setObjectType(PermissionConst.POSITION);
|
||||
organizeRelationEntity.setObjectId(positionId);
|
||||
organizeRelationService.save(organizeRelationEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@GetMapping("/SelectAsyncList/{id}")
|
||||
public ActionResult<?> selectAsyncList(@PathVariable("id") String id,PaginationPosition pagination) {
|
||||
List<PositionSelectorVO> listVO = new ArrayList<>();
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
Map<String, OrganizeEntity> orgMaps = organizeService.getOrgMaps(null, true, null);
|
||||
List<OrganizeRelationEntity> organizeList = organizeRelationService.getRelationListByType(PermissionConst.POSITION);
|
||||
boolean isKeyWord = StringUtil.isNotEmpty(pagination.getKeyword());
|
||||
if(isKeyWord) {
|
||||
List<String> objectId = organizeList.stream().map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<PositionEntity> list = positionService.getList(objectId, pagination, true);
|
||||
for (PositionEntity entity : list) {
|
||||
PositionSelectorVO vo =new PositionSelectorVO();
|
||||
vo.setId(entity.getId());
|
||||
vo.setFullName(entity.getFullName());
|
||||
vo.setType("position");
|
||||
vo.setIcon("icon-ym icon-ym-tree-position1");
|
||||
vo.setHasChildren(false);
|
||||
vo.setOnlyId(UUID.randomUUID().toString());
|
||||
List<OrganizeRelationEntity> relationList = organizeList.stream().filter(t -> t.getObjectId().equals(entity.getId())).collect(Collectors.toList());
|
||||
StringJoiner orgName = new StringJoiner(",");
|
||||
List<String> organizeId = new ArrayList<>();
|
||||
relationList.forEach(organizeRelationEntity -> {
|
||||
OrganizeEntity organizeEntity = organizeService.getInfo(organizeRelationEntity.getOrganizeId());
|
||||
if (organizeEntity != null) {
|
||||
String fullNameByOrgIdTree = organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/");
|
||||
orgName.add(fullNameByOrgIdTree);
|
||||
organizeId.addAll(organizeService.getOrgIdTree(organizeEntity));
|
||||
}
|
||||
});
|
||||
vo.setOrganize(orgName.toString());
|
||||
vo.setOrganizeIds(organizeId);
|
||||
listVO.add(vo);
|
||||
}
|
||||
}else {
|
||||
if (!"0".equals(id)) {
|
||||
List<String> objectId = organizeList.stream().filter(t -> t.getOrganizeId().equals(id)).map(OrganizeRelationEntity::getObjectId).collect(Collectors.toList());
|
||||
List<PositionEntity> list = positionService.getList(objectId, pagination, false);
|
||||
for (PositionEntity entity : list) {
|
||||
PositionSelectorVO vo =JsonUtil.getJsonToBean(entity,PositionSelectorVO.class);
|
||||
vo.setType("position");
|
||||
vo.setIcon("icon-ym icon-ym-tree-position1");
|
||||
vo.setHasChildren(false);
|
||||
vo.setOnlyId(UUID.randomUUID().toString());
|
||||
OrganizeRelationEntity relationEntity = organizeList.stream().filter(t -> t.getOrganizeId().equals(id)).findFirst().orElse(null);
|
||||
List<String> organizeId = new ArrayList<>();
|
||||
if(relationEntity!=null){
|
||||
OrganizeEntity organizeEntity = orgMaps.get(relationEntity.getOrganizeId());
|
||||
if(organizeEntity!=null){
|
||||
vo.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/"));
|
||||
organizeId.addAll(organizeService.getOrgIdTree(organizeEntity));
|
||||
}
|
||||
}
|
||||
vo.setOrganizeIds(organizeId);
|
||||
listVO.add(vo);
|
||||
}
|
||||
//单个组织
|
||||
List<OrganizeEntity> collect = new ArrayList<>(orgMaps.values());
|
||||
OrganizeEntity organizeEntity = orgMaps.get(id);
|
||||
if(organizeEntity!=null){
|
||||
List<OrganizeEntity> collect1 = collect.stream().filter(t -> t.getParentId().equals(organizeEntity.getId())).collect(Collectors.toList());
|
||||
for (OrganizeEntity entity : collect1) {
|
||||
PositionSelectorVO vo = JsonUtil.getJsonToBean(entity, PositionSelectorVO.class);
|
||||
vo.setIcon("company".equals(entity.getCategory()) ? "icon-ym icon-ym-tree-organization3" : "icon-ym icon-ym-tree-department1");
|
||||
vo.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, entity.getOrganizeIdTree(), "/"));
|
||||
vo.setOrganizeIds(organizeService.getOrgIdTree(entity));
|
||||
vo.setHasChildren(true);
|
||||
listVO.add(vo);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<OrganizeEntity> list = new ArrayList<>(orgMaps.values()).stream().filter(t->"-1".equals(t.getParentId()) && Objects.equals(t.getEnabledMark(),1)).collect(Collectors.toList());
|
||||
for (OrganizeEntity entity : list) {
|
||||
PositionSelectorVO vo =JsonUtil.getJsonToBean(entity,PositionSelectorVO.class);
|
||||
vo.setType(entity.getCategory());
|
||||
vo.setIcon("company".equals(entity.getCategory()) ? "icon-ym icon-ym-tree-organization3" : "icon-ym icon-ym-tree-department1");
|
||||
vo.setOnlyId(UUID.randomUUID().toString());
|
||||
vo.setOrganize(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, entity.getOrganizeIdTree(), "/"));
|
||||
vo.setOrganizeIds(organizeService.getOrgIdTree(entity));
|
||||
vo.setHasChildren(true);
|
||||
listVO.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
if(!isKeyWord){
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
PaginationVO jsonToBean = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, jsonToBean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选中值
|
||||
*
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "获取选中值")
|
||||
@Parameters({
|
||||
@Parameter(name = "userIdModel", description = "id", required = true)
|
||||
})
|
||||
@PostMapping("/SelectedList")
|
||||
public ActionResult<ListVO<UserIdListVo>> SelectedList(@RequestBody UserIdModel userIdModel) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for(String id : userIdModel.getIds()){
|
||||
ids.add(id+"--"+PermissionConst.POSITION);
|
||||
}
|
||||
List<UserIdListVo> list = userService.selectedByIds(ids);
|
||||
ListVO<UserIdListVo> listVO = new ListVO<>();
|
||||
listVO.setList(list);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模板下载")
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping("/TemplateDownload")
|
||||
public ActionResult<DownloadVO> TemplateDownload() {
|
||||
PosColumnMap columnMap = new PosColumnMap();
|
||||
String excelName = columnMap.getExcelName();
|
||||
Map<String, String> keyMap = columnMap.getColumnByType(0);
|
||||
List<ExcelColumnAttr> models = columnMap.getFieldsModel(false);
|
||||
List<Map<String, Object>> list = columnMap.getDefaultList();
|
||||
Map<String, String[]> optionMap = getOptionMap();
|
||||
ExcelModel excelModel = ExcelModel.builder().models(models).selectKey(new ArrayList<>(keyMap.keySet())).optionMap(optionMap).build();
|
||||
DownloadVO vo = ExcelTool.getImportTemplate(configValueUtil.getTemporaryFilePath(), excelName, keyMap, list, excelModel);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传Excel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "上传导入Excel")
|
||||
@SaCheckPermission("permission.position")
|
||||
@PostMapping("/Uploader")
|
||||
public ActionResult<Object> Uploader() {
|
||||
return ExcelTool.uploader();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入预览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入预览")
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping("/ImportPreview")
|
||||
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
|
||||
// 导入字段
|
||||
PosColumnMap columnMap = new PosColumnMap();
|
||||
Map<String, String> keyMap = columnMap.getColumnByType(0);
|
||||
Map<String, Object> headAndDataMap = ExcelTool.importPreview(configValueUtil.getTemporaryFilePath(), fileName, keyMap);
|
||||
return ActionResult.success(headAndDataMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出异常报告
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出异常报告")
|
||||
@SaCheckPermission("permission.position")
|
||||
@PostMapping("/ExportExceptionData")
|
||||
public ActionResult<DownloadVO> ExportExceptionData(@RequestBody ExcelImportForm visualImportModel) {
|
||||
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
||||
List<Map<String, Object>> dataList = visualImportModel.getList();
|
||||
PosColumnMap columnMap = new PosColumnMap();
|
||||
String excelName = columnMap.getExcelName();
|
||||
Map<String, String> keyMap = columnMap.getColumnByType(0);
|
||||
List<ExcelColumnAttr> models = columnMap.getFieldsModel(true);
|
||||
ExcelModel excelModel = ExcelModel.builder().optionMap(getOptionMap()).models(models).build();
|
||||
DownloadVO vo = ExcelTool.exportExceptionReport(temporaryFilePath, excelName, keyMap, dataList, excelModel);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入数据")
|
||||
@SaCheckPermission("permission.position")
|
||||
@PostMapping("/ImportData")
|
||||
public ActionResult<ExcelImportVO> ImportData(@RequestBody ExcelImportForm visualImportModel) throws Exception {
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
List<Map<String, Object>> headerRow = new ArrayList<>();
|
||||
if (visualImportModel.isType()){
|
||||
ActionResult result = ImportPreview(visualImportModel.getFileName());
|
||||
if (result == null){
|
||||
throw new Exception(MsgCode.FA018.get());
|
||||
}
|
||||
if (result.getCode() != 200){
|
||||
throw new Exception(result.getMsg());
|
||||
}
|
||||
if (result.getData() instanceof Map){
|
||||
Map<String,Object> data = (Map<String, Object>) result.getData();
|
||||
listData = (List<Map<String, Object>>) data.get("dataRow");
|
||||
headerRow = (List<Map<String, Object>>) data.get("headerRow");
|
||||
}
|
||||
}else {
|
||||
listData = visualImportModel.getList();
|
||||
}
|
||||
List<PositionEntity> addList = new ArrayList<PositionEntity>();
|
||||
List<Map<String, Object>> failList = new ArrayList<>();
|
||||
// 对数据做校验
|
||||
this.validateImportData(listData, addList, failList);
|
||||
|
||||
//正常数据插入
|
||||
for (PositionEntity each : addList) {
|
||||
positionService.create(each);
|
||||
}
|
||||
ExcelImportVO importModel = new ExcelImportVO();
|
||||
importModel.setSnum(addList.size());
|
||||
importModel.setFnum(failList.size());
|
||||
importModel.setResultType(failList.size() > 0 ? 1 : 0);
|
||||
importModel.setFailResult(failList);
|
||||
importModel.setHeaderRow(headerRow);
|
||||
return ActionResult.success(importModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出Excel")
|
||||
@SaCheckPermission("permission.position")
|
||||
@GetMapping("/ExportData")
|
||||
public ActionResult ExportData(PaginationPosition paginationPosition) throws IOException {
|
||||
if (StringUtil.isEmpty(paginationPosition.getSelectKey())) {
|
||||
return ActionResult.fail(MsgCode.IMP011.get());
|
||||
}
|
||||
List<DictionaryDataEntity> dictionaryDataEntities = dictionaryDataApi.getListByTypeDataCode(DictionaryDataEnum.POSITION_TYPE.getDictionaryTypeId());
|
||||
if (StringUtil.isNotEmpty(paginationPosition.getType())) {
|
||||
DictionaryDataEntity dictionaryDataEntity = dictionaryDataEntities.stream().filter(t -> paginationPosition.getType().equals(t.getId())).findFirst().orElse(null);
|
||||
if (dictionaryDataEntity != null) {
|
||||
paginationPosition.setEnCode(dictionaryDataEntity.getEnCode());
|
||||
}
|
||||
}
|
||||
List<PositionEntity> dataList = positionService.getList(paginationPosition);
|
||||
//组织部门
|
||||
List<String> collect = dataList.stream().map(PositionEntity::getOrganizeId).collect(Collectors.toList());
|
||||
List<OrganizeEntity> list = organizeService.getOrgEntityList(collect, true);
|
||||
Map<String, String> orgIdNameMaps = organizeService.getInfoList();
|
||||
|
||||
List<Map<String, Object>> realList = new ArrayList<>();
|
||||
for (PositionEntity entity : dataList) {
|
||||
Map<String, Object> positionMap = JsonUtil.entityToMap(entity);
|
||||
//组织
|
||||
OrganizeEntity organizeEntity = list.stream().filter(t -> t.getId().equals(entity.getOrganizeId())).findFirst().orElse(new OrganizeEntity());
|
||||
if (entity.getOrganizeId().equals(organizeEntity.getId())) {
|
||||
positionMap.put("organizeId", organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/"));
|
||||
}
|
||||
//岗位类型
|
||||
DictionaryDataEntity dictionaryDataEntity = dictionaryDataEntities.stream().filter(t -> t.getEnCode().equals(entity.getType()) && "1".equals(String.valueOf(t.getEnabledMark())) && t.getDeleteMark() == null).findFirst().orElse(null);
|
||||
if (dictionaryDataEntity != null) {
|
||||
positionMap.put("type", dictionaryDataEntity.getFullName());
|
||||
} else {
|
||||
positionMap.put("type", "");
|
||||
}
|
||||
positionMap.put("enabledMark", "1".equals(String.valueOf(entity.getEnabledMark())) ? "启用" : "禁用");
|
||||
realList.add(positionMap);
|
||||
}
|
||||
String[] keys = !StringUtil.isEmpty(paginationPosition.getSelectKey()) ? paginationPosition.getSelectKey() : new String[0];
|
||||
PosColumnMap posColumnMap = new PosColumnMap();
|
||||
String excelName = posColumnMap.getExcelName();
|
||||
List<ExcelColumnAttr> models = posColumnMap.getFieldsModel(false);
|
||||
Map<String, String> keyMap = posColumnMap.getColumnByType(null);
|
||||
ExcelModel excelModel = ExcelModel.builder().selectKey(Arrays.asList(keys)).models(models).optionMap(null).build();
|
||||
DownloadVO vo = ExcelTool.creatModelExcel(configValueUtil.getTemporaryFilePath(), excelName, keyMap, realList, excelModel);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
private void validateImportData(List<Map<String, Object>> listData, List<PositionEntity> addList, List<Map<String, Object>> failList) {
|
||||
PosColumnMap columnMap = new PosColumnMap();
|
||||
Map<String, String> keyMap = columnMap.getColumnByType(0);
|
||||
QueryWrapper<PositionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().isNull(PositionEntity::getDeleteMark);
|
||||
queryWrapper.lambda().orderByAsc(PositionEntity::getSortCode).orderByDesc(PositionEntity::getCreatorTime);
|
||||
List<PositionEntity> allPositionList = positionService.list(queryWrapper);
|
||||
List<DictionaryDataEntity> typeDictionaryList = dictionaryDataApi.getListByTypeDataCode(DictionaryDataEnum.POSITION_TYPE.getDictionaryTypeId());
|
||||
Map<String, Object> allOrgsTreeName = organizeService.getAllOrgsTreeName();
|
||||
for (int i = 0, len = listData.size(); i < len; i++) {
|
||||
Map<String, Object> eachMap = listData.get(i);
|
||||
Map<String, Object> realMap = JsonUtil.getJsonToBean(eachMap, Map.class);
|
||||
StringJoiner errInfo = new StringJoiner(",");
|
||||
boolean checkOrganizeIdPass = false;
|
||||
for (String column : keyMap.keySet()) {
|
||||
Object valueObj = eachMap.get(column);
|
||||
String value = valueObj == null ? null : String.valueOf(valueObj);
|
||||
String columnName = keyMap.get(column);
|
||||
switch (column) {
|
||||
case "organizeId":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
errInfo.add(columnName + "不能为空");
|
||||
break;
|
||||
}
|
||||
CheckResult organizeIdCheckResult = checkOrganizeId(value, allOrgsTreeName);
|
||||
if (!organizeIdCheckResult.isPass()) {
|
||||
errInfo.add("找不到该所属组织");
|
||||
break;
|
||||
}
|
||||
realMap.put("organizeId", organizeIdCheckResult.getValue());
|
||||
checkOrganizeIdPass = true;
|
||||
break;
|
||||
case "fullName":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
errInfo.add(columnName + "不能为空");
|
||||
break;
|
||||
}
|
||||
if (value.length() > 50) {
|
||||
errInfo.add(columnName + "值超出最多输入字符限制");
|
||||
}
|
||||
//值不能含有特殊符号
|
||||
if (!RegexUtils.checkSpecoalSymbols(value)) {
|
||||
errInfo.add(columnName + "值不能含有特殊符号");
|
||||
}
|
||||
//组织不通过
|
||||
if (!checkOrganizeIdPass) {
|
||||
break;
|
||||
}
|
||||
String thisOrganizeId = (String) realMap.get("organizeId");
|
||||
//库里重复
|
||||
long fullNameCount = allPositionList.stream().filter(t -> t.getOrganizeId().equals(thisOrganizeId) && t.getFullName().equals(value)).count();
|
||||
if (fullNameCount > 0) {
|
||||
errInfo.add(columnName + "值已存在");
|
||||
break;
|
||||
}
|
||||
//表格内重复
|
||||
fullNameCount = addList.stream().filter(t -> t.getOrganizeId().equals(thisOrganizeId) && t.getFullName().equals(value)).count();
|
||||
if (fullNameCount > 0) {
|
||||
errInfo.add(columnName + "值已存在");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "enCode":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
errInfo.add(columnName + "不能为空");
|
||||
break;
|
||||
}
|
||||
if (value.length() > 50) {
|
||||
errInfo.add(columnName + "值超出最多输入字符限制");
|
||||
}
|
||||
if(!RegexUtils.checkEnCode(value)){
|
||||
errInfo.add(columnName + "只能输入英文、数字和小数点且小数点不能放在首尾");
|
||||
}
|
||||
//库里重复
|
||||
long enCodeCount = allPositionList.stream().filter(t -> t.getEnCode().equals(value)).count();
|
||||
if (enCodeCount > 0) {
|
||||
errInfo.add(columnName + "值已存在");
|
||||
break;
|
||||
}
|
||||
//表格内重复
|
||||
enCodeCount = addList.stream().filter(t -> t.getEnCode().equals(value)).count();
|
||||
if (enCodeCount > 0) {
|
||||
errInfo.add(columnName + "值已存在");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "type":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
errInfo.add(columnName + "不能为空");
|
||||
break;
|
||||
}
|
||||
DictionaryDataEntity typeDictionary = typeDictionaryList.stream().filter(t -> t.getFullName().equals(value)).findFirst().orElse(null);
|
||||
if (typeDictionary == null) {
|
||||
errInfo.add("找不到该" + columnName + "值");
|
||||
break;
|
||||
}
|
||||
realMap.put("type", typeDictionary.getEnCode());
|
||||
break;
|
||||
case "sortCode":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
realMap.put("sortCode", 0);
|
||||
break;
|
||||
}
|
||||
Long numValue = 0l;
|
||||
try {
|
||||
numValue = Long.parseLong(value);
|
||||
} catch (Exception e) {
|
||||
errInfo.add(columnName + "值不正确");
|
||||
break;
|
||||
}
|
||||
if (numValue < 0) {
|
||||
errInfo.add(columnName + "值不能小于0");
|
||||
break;
|
||||
}
|
||||
if (numValue > 1000000) {
|
||||
errInfo.add(columnName + "值不能大于999999");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "enabledMark":
|
||||
if (StringUtil.isEmpty(value)) {
|
||||
errInfo.add(columnName + "不能为空");
|
||||
break;
|
||||
}
|
||||
if ("启用".equals(value)) {
|
||||
realMap.put("enabledMark", 1);
|
||||
} else if ("禁用".equals(value)) {
|
||||
realMap.put("enabledMark", 0);
|
||||
} else {
|
||||
errInfo.add(columnName + "值不正确");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (errInfo.length() == 0) {
|
||||
PositionEntity positionEntity = JsonUtil.getJsonToBean(realMap, PositionEntity.class);
|
||||
positionEntity.setCreatorTime(new Date());
|
||||
addList.add(positionEntity);
|
||||
} else {
|
||||
eachMap.put("errorsInfo", errInfo.toString());
|
||||
failList.add(eachMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CheckResult checkOrganizeId(String organizeName, Map<String, Object> allOrgsTreeName) {
|
||||
for (String key : allOrgsTreeName.keySet()) {
|
||||
Object o = allOrgsTreeName.get(key);
|
||||
if (organizeName.equals(o.toString())) {
|
||||
String[] split = key.split(",");
|
||||
return new CheckResult(true, null, split[split.length - 1]);
|
||||
}
|
||||
}
|
||||
return new CheckResult(false, "所属组织不正确", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下拉框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String[]> getOptionMap() {
|
||||
Map<String, String[]> optionMap = new HashMap<>();
|
||||
//岗位类型
|
||||
List<DictionaryDataEntity> typeList = dictionaryDataApi.getByTypeCodeEnable(DictionaryDataEnum.POSITION_TYPE.getDictionaryTypeId());
|
||||
String[] type = typeList.stream().map(DictionaryDataEntity::getFullName).toArray(String[]::new);
|
||||
optionMap.put("type", type);
|
||||
//状态
|
||||
optionMap.put("enabledMark", new String[]{"启用", "禁用"});
|
||||
return optionMap;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,434 @@
|
||||
package com.yunzhupaas.permission.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.annotation.UserPermission;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.util.NoDataSourceBind;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.exception.LoginException;
|
||||
import com.yunzhupaas.permission.entity.SocialsUserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.model.socails.SocialsUserInfo;
|
||||
import com.yunzhupaas.permission.model.socails.SocialsUserModel;
|
||||
import com.yunzhupaas.permission.model.socails.SocialsUserVo;
|
||||
import com.yunzhupaas.permission.service.SocialsUserService;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.permission.util.socials.AuthCallbackNew;
|
||||
import com.yunzhupaas.permission.util.socials.AuthSocialsUtil;
|
||||
import com.yunzhupaas.permission.util.socials.SocialsAuthEnum;
|
||||
import com.yunzhupaas.permission.util.socials.SocialsConfig;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.wxutil.HttpUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.enums.AuthResponseStatus;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单点登录
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 10:48:00
|
||||
*/
|
||||
@Tag(name = "第三方登录和绑定", description = "Socials")
|
||||
@RestController
|
||||
@RequestMapping("/api/permission/socials")
|
||||
@Slf4j
|
||||
public class SocialsUserController extends SuperController<SocialsUserService, SocialsUserEntity> {
|
||||
@Autowired
|
||||
private SocialsUserService socialsUserService;
|
||||
@Autowired
|
||||
private AuthSocialsUtil authSocialsUtil;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private SocialsConfig socialsConfig;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*
|
||||
* @param
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "获取用户授权列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "userId", description = "用户id")
|
||||
})
|
||||
@GetMapping
|
||||
public ActionResult<List<SocialsUserVo>> getList(@RequestParam(value = "userId", required = false) String userId) {
|
||||
if (StringUtil.isEmpty(userId)) {
|
||||
userId = UserProvider.getUser().getUserId();
|
||||
}
|
||||
List<Map<String, Object>> platformInfos = SocialsAuthEnum.getPlatformInfos();
|
||||
String s = JSONArray.toJSONString(platformInfos);
|
||||
List<SocialsUserVo> socialsUserVos = JsonUtil.getJsonToList(s, SocialsUserVo.class);
|
||||
List<SocialsConfig.Config> config = socialsConfig.getConfig();
|
||||
List<SocialsUserVo> res = new ArrayList<>();
|
||||
if (config == null) {
|
||||
return ActionResult.fail(MsgCode.PS019.get());
|
||||
}
|
||||
config.stream().forEach(item -> {
|
||||
socialsUserVos.stream().forEach(item2 -> {
|
||||
if (item2.getEnname().toLowerCase().equals(item.getProvider())) {
|
||||
res.add(item2);
|
||||
}
|
||||
});
|
||||
});
|
||||
//查询绑定信息
|
||||
List<SocialsUserEntity> listByUserId = socialsUserService.getListByUserId(userId);
|
||||
List<SocialsUserModel> listModel = JsonUtil.getJsonToList(listByUserId, SocialsUserModel.class);
|
||||
res.stream().forEach(item -> {
|
||||
listModel.stream().forEach(item2 -> {
|
||||
if (item.getEnname().equals(item2.getSocialType())) item.setEntity(item2);
|
||||
});
|
||||
});
|
||||
return ActionResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定:重定向第三方登录页面
|
||||
*
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "重定向第三方登录页面")
|
||||
@Parameters({
|
||||
@Parameter(name = "source", description = "地址", required = true)
|
||||
})
|
||||
@GetMapping("/render/{source}")
|
||||
@ResponseBody
|
||||
public ActionResult render(@PathVariable String source) {
|
||||
AuthRequest authRequest = authSocialsUtil.getAuthRequest(source, UserProvider.getUser().getUserId(), false, null, UserProvider.getUser().getTenantId());
|
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
return ActionResult.success(authorizeUrl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置租户库
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/8
|
||||
*/
|
||||
private boolean setTenantData(String tenantId, UserInfo userInfo) {
|
||||
try{
|
||||
TenantDataSourceUtil.switchTenant(tenantId);
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@UserPermission
|
||||
@Operation(summary = "解绑")
|
||||
@Parameters({
|
||||
@Parameter(name = "userId", description = "用户id"),
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult deleteSocials(@RequestParam(value = "userId",required = false)String userId,@PathVariable("id") String id) {
|
||||
SocialsUserEntity byId = socialsUserService.getById(id);
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
boolean b = socialsUserService.removeById(id);
|
||||
if (b) {
|
||||
//多租户开启-解除绑定
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
String param = "?userId=" + byId.getUserId() + "&tenantId=" + userInfo.getTenantId() + "&socialsType=" + byId.getSocialType();
|
||||
JSONObject object = HttpUtil.httpRequest(configValueUtil.getMultiTenancyUrl() + "socials" + param, "DELETE", null);
|
||||
if (object == null || "500".equals(object.get("code").toString()) || "400".equals(object.getString("code"))) {
|
||||
return ActionResult.fail(MsgCode.PS018.get());
|
||||
}
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.PS018.get());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
@NoDataSourceBind
|
||||
public List<SocialsUserVo> getLoginList(@RequestParam("ticket") String ticket) {
|
||||
if (!socialsConfig.isSocialsEnabled()) return null;
|
||||
List<Map<String, Object>> platformInfos = SocialsAuthEnum.getPlatformInfos();
|
||||
String s = JSONArray.toJSONString(platformInfos);
|
||||
List<SocialsUserVo> socialsUserVos = JsonUtil.getJsonToList(s, SocialsUserVo.class);
|
||||
List<SocialsConfig.Config> config = socialsConfig.getConfig();
|
||||
List<SocialsUserVo> res = new ArrayList<>();
|
||||
config.stream().forEach(item -> {
|
||||
socialsUserVos.stream().forEach(item2 -> {
|
||||
if (item2.getEnname().toLowerCase().equals(item.getProvider())) {
|
||||
AuthRequest authRequest = authSocialsUtil.getAuthRequest(item2.getEnname(), null, true, ticket, null);
|
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
|
||||
item2.setRenderUrl(authorizeUrl);
|
||||
res.add(item2);
|
||||
}
|
||||
});
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/getSocialsUserInfo")
|
||||
@NoDataSourceBind
|
||||
public SocialsUserInfo getSocialsUserInfo(@RequestParam("source") String source, @RequestParam("code") String code,
|
||||
@RequestParam(value = "state", required = false) String state) throws LoginException {
|
||||
//获取第三方请求
|
||||
AuthCallbackNew callback = setAuthCallback(code, state);
|
||||
AuthRequest authRequest = authSocialsUtil.getAuthRequest(source, null, false, null, null);
|
||||
AuthResponse<AuthUser> res = authRequest.login(callback);
|
||||
if(AuthResponseStatus.FAILURE.getCode()==res.getCode()){
|
||||
throw new LoginException("连接失败!");
|
||||
}else if(AuthResponseStatus.SUCCESS.getCode()!=res.getCode()){
|
||||
throw new LoginException("授权失败:"+res.getMsg());
|
||||
}
|
||||
//登录用户第三方id
|
||||
String uuid = getSocialUuid(res);
|
||||
String socialName=StringUtil.isNotEmpty(res.getData().getUsername())?res.getData().getUsername():res.getData().getNickname();
|
||||
SocialsUserInfo socialsUserInfo = getUserInfo(source, uuid, socialName);
|
||||
return socialsUserInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户绑定信息列表
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/20
|
||||
*/
|
||||
@NoDataSourceBind
|
||||
public SocialsUserInfo getUserInfo(String source, String uuid, String socialName) throws LoginException {
|
||||
SocialsUserInfo socialsUserInfo=new SocialsUserInfo();
|
||||
UserInfo userInfo=new UserInfo();
|
||||
//查询租户绑定
|
||||
if ("wechat_applets".equals(source)) {
|
||||
source = "wechat_open";
|
||||
}
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
JSONObject object = HttpUtil.httpRequest(configValueUtil.getMultiTenancyUrl() + "socials/list?socialsId=" + uuid, "GET", null);
|
||||
if (object == null || "500".equals(object.get("code").toString()) || "400".equals(object.getString("code"))) {
|
||||
throw new LoginException("租户绑定信息查询错误!");
|
||||
}
|
||||
if ("200".equals(object.get("code").toString())) {
|
||||
JSONArray data = JSONArray.parseArray(object.get("data").toString());
|
||||
int size = data.size();
|
||||
System.out.println(size);
|
||||
if (data == null || data.size() == 0) {
|
||||
socialsUserInfo.setSocialUnionid(uuid);
|
||||
socialsUserInfo.setSocialName(socialName);
|
||||
return socialsUserInfo;
|
||||
} else if (data.size() == 1) {
|
||||
//租户开启时-切换租户库
|
||||
JSONObject oneUser = (JSONObject) data.get(0);
|
||||
setTenantData(oneUser.get("tenantId").toString(), userInfo);
|
||||
List<SocialsUserEntity> list = socialsUserService.getUserIfnoBySocialIdAndType(uuid, source);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
throw new LoginException("第三方未绑定账号!");
|
||||
}
|
||||
UserEntity infoById = userService.getInfo(list.get(0).getUserId());
|
||||
userInfo = JsonUtil.getJsonToBean(infoById, UserInfo.class);
|
||||
userInfo.setUserId(infoById.getId());
|
||||
userInfo.setUserAccount(oneUser.get("tenantId").toString() + "@" + infoById.getAccount());
|
||||
socialsUserInfo.setTenantUserInfo(data);
|
||||
socialsUserInfo.setUserInfo(userInfo);
|
||||
} else {
|
||||
socialsUserInfo.setTenantUserInfo(data);
|
||||
}
|
||||
}
|
||||
} else {//非多租户
|
||||
//查询绑定
|
||||
List<SocialsUserEntity> list = socialsUserService.getUserIfnoBySocialIdAndType(uuid, source);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
UserEntity infoById = userService.getInfo(list.get(0).getUserId());
|
||||
userInfo = JsonUtil.getJsonToBean(infoById, UserInfo.class);
|
||||
userInfo.setUserId(infoById.getId());
|
||||
userInfo.setUserAccount(infoById.getAccount());
|
||||
socialsUserInfo.setUserInfo(userInfo);
|
||||
} else {
|
||||
socialsUserInfo.setSocialUnionid(uuid);
|
||||
socialsUserInfo.setSocialName(socialName);
|
||||
}
|
||||
}
|
||||
return socialsUserInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定
|
||||
*
|
||||
* @return ignore
|
||||
*/
|
||||
@GetMapping("/callback")
|
||||
@ResponseBody
|
||||
@NoDataSourceBind
|
||||
public JSONObject binding(@RequestParam("source") String source,
|
||||
@RequestParam(value = "userId", required = false) String userId,
|
||||
@RequestParam(value = "tenantId", required = false) String tenantId,
|
||||
@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "state", required = false) String state) {
|
||||
log.info("进入callback:" + source + " callback params:");
|
||||
//获取第三方请求
|
||||
AuthCallbackNew callback = setAuthCallback(code, state);
|
||||
//租户开启时-切换租户库
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
boolean b = setTenantData(tenantId, new UserInfo());
|
||||
if (!b) {
|
||||
return resultJson(201, "查询租户信息错误!");
|
||||
}
|
||||
|
||||
}
|
||||
//获取第三方请求
|
||||
AuthRequest authRequest = authSocialsUtil.getAuthRequest(source, userId, false, null, null);
|
||||
AuthResponse<AuthUser> res = authRequest.login(callback);
|
||||
log.info(JSONObject.toJSONString(res));
|
||||
if (res.ok()) {
|
||||
String uuid = getSocialUuid(res);
|
||||
List<SocialsUserEntity> userIfnoBySocialIdAndType = socialsUserService.getUserIfnoBySocialIdAndType(uuid, source);
|
||||
if (CollectionUtil.isNotEmpty(userIfnoBySocialIdAndType)) {
|
||||
UserEntity info = userService.getInfo(userIfnoBySocialIdAndType.get(0).getUserId());
|
||||
return resultJson(201, "当前账户已被" + info.getRealName() + "/" + info.getAccount() + "绑定,不能重复绑定");
|
||||
}
|
||||
SocialsUserEntity socialsUserEntity = new SocialsUserEntity();
|
||||
socialsUserEntity.setUserId(userId);
|
||||
socialsUserEntity.setSocialType(source);
|
||||
socialsUserEntity.setSocialName(res.getData().getUsername());
|
||||
socialsUserEntity.setSocialId(uuid);
|
||||
socialsUserEntity.setCreatorTime(new Date());
|
||||
boolean save = socialsUserService.save(socialsUserEntity);
|
||||
|
||||
//租户开启时-添加租户库绑定数据
|
||||
if (configValueUtil.isMultiTenancy() && save) {
|
||||
JSONObject params = (JSONObject) JSONObject.toJSON(socialsUserEntity);
|
||||
UserEntity info = userService.getInfo(userId);
|
||||
params.put("tenantId", tenantId);
|
||||
params.put("account", info.getAccount());
|
||||
params.put("accountName", info.getRealName() + "/" + info.getAccount());
|
||||
JSONObject object = HttpUtil.httpRequest(configValueUtil.getMultiTenancyUrl() + "socials", "POST", params.toJSONString());
|
||||
if (object == null || "500".equals(object.get("code").toString()) || "400".equals(object.getString("code"))) {
|
||||
return resultJson(201, "用户租户绑定错误!");
|
||||
}
|
||||
}
|
||||
return resultJson(200, "绑定成功!");
|
||||
|
||||
}
|
||||
return resultJson(201, "第三方回调失败!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置第三方code state参数
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/8
|
||||
*/
|
||||
private AuthCallbackNew setAuthCallback(String code, String state) {
|
||||
AuthCallbackNew callback = new AuthCallbackNew();
|
||||
callback.setAuthCode(code);
|
||||
callback.setAuth_code(code);
|
||||
callback.setAuthorization_code(code);
|
||||
callback.setCode(code);
|
||||
callback.setState(state);
|
||||
return callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回json
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/9/8
|
||||
*/
|
||||
private JSONObject resultJson(int code, String message) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", code);
|
||||
jsonObject.put("message", message);
|
||||
return jsonObject;
|
||||
}
|
||||
private String getSocialUuid(AuthResponse<AuthUser> res) {
|
||||
String uuid = res.getData().getUuid();
|
||||
if (res.getData().getToken() != null && StringUtil.isNotEmpty(res.getData().getToken().getUnionId())) {
|
||||
uuid = res.getData().getToken().getUnionId();
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定
|
||||
*
|
||||
* @return ignore
|
||||
*/
|
||||
@GetMapping("/loginbind")
|
||||
@ResponseBody
|
||||
@NoDataSourceBind
|
||||
public void loginAutoBinding(@RequestParam("socialType") String socialType,
|
||||
@RequestParam("socialUnionid") String socialUnionid,
|
||||
@RequestParam("socialName") String socialName,
|
||||
@RequestParam("userId") String userId,
|
||||
@RequestParam(value = "tenantId", required = false) String tenantId) {
|
||||
//查询租户绑定
|
||||
if ("wechat_applets".equals(socialType)) {
|
||||
socialType = "wechat_open";
|
||||
}
|
||||
//租户开启时-切换租户库
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
setTenantData(tenantId, new UserInfo());
|
||||
}
|
||||
List<SocialsUserEntity> list = socialsUserService.getListByUserIdAndSource(userId, socialType);
|
||||
if(CollectionUtil.isNotEmpty(list)){//账号已绑定该第三方其他账号,则不绑定
|
||||
return;
|
||||
}
|
||||
SocialsUserEntity socialsUserEntity = new SocialsUserEntity();
|
||||
socialsUserEntity.setUserId(userId);
|
||||
socialsUserEntity.setSocialType(socialType);
|
||||
socialsUserEntity.setSocialName(socialName);
|
||||
socialsUserEntity.setSocialId(socialUnionid);
|
||||
socialsUserEntity.setCreatorTime(new Date());
|
||||
boolean save = socialsUserService.save(socialsUserEntity);
|
||||
//租户开启时-添加租户库绑定数据
|
||||
if (configValueUtil.isMultiTenancy() && save) {
|
||||
JSONObject params = (JSONObject) JSONObject.toJSON(socialsUserEntity);
|
||||
UserEntity info = userService.getInfo(userId);
|
||||
params.put("tenantId", tenantId);
|
||||
params.put("account", info.getAccount());
|
||||
params.put("accountName", info.getRealName() + "/" + info.getAccount());
|
||||
JSONObject object = HttpUtil.httpRequest(configValueUtil.getMultiTenancyUrl() + "socials", "POST", params.toJSONString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,104 @@
|
||||
package com.yunzhupaas.permission.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.annotation.UserPermission;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.permission.model.userrelation.UserRelationForm;
|
||||
import com.yunzhupaas.permission.model.userrelation.UserRelationIdsVO;
|
||||
import com.yunzhupaas.permission.service.UserRelationService;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户关系
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "用户关系", description = "UserRelation")
|
||||
@RestController
|
||||
@RequestMapping("/api/permission/UserRelation")
|
||||
public class UserRelationController extends SuperController<UserRelationService, UserRelationEntity> {
|
||||
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param objectId 对象主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取岗位/角色/门户成员列表ids")
|
||||
@Parameters({
|
||||
@Parameter(name = "objectId", description = "对象主键", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.authorize", "permission.position", "permission.role"}, mode = SaMode.OR)
|
||||
@GetMapping("/{objectId}")
|
||||
public ActionResult<UserRelationIdsVO> listTree(@PathVariable("objectId") String objectId) {
|
||||
List<UserRelationEntity> data = userRelationService.getListByObjectId(objectId);
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (UserRelationEntity entity : data) {
|
||||
ids.add(entity.getUserId());
|
||||
}
|
||||
UserRelationIdsVO vo = new UserRelationIdsVO();
|
||||
vo.setIds(ids);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param objectId 对象主键
|
||||
* @param userRelationForm 页面数据
|
||||
* @return
|
||||
*/
|
||||
@UserPermission
|
||||
@Operation(summary = "添加岗位或角色成员")
|
||||
@Parameters({
|
||||
@Parameter(name = "objectId", description = "对象主键", required = true),
|
||||
@Parameter(name = "userRelationForm", description = "页面数据", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"permission.authorize", "permission.position", "permission.role"}, mode = SaMode.OR)
|
||||
@PostMapping("/{objectId}")
|
||||
public ActionResult save(@PathVariable("objectId") String objectId, @RequestBody UserRelationForm userRelationForm) {
|
||||
List<String> userIds = new ArrayList<>();
|
||||
// 得到禁用的id
|
||||
List<UserRelationEntity> listByObjectId = userRelationService.getListByObjectId(objectId, userRelationForm.getObjectType());
|
||||
List<String> collect = listByObjectId.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
|
||||
//删除的用户
|
||||
List<String> collect1 = collect.stream().filter(t -> !userRelationForm.getUserIds().contains(t)).collect(Collectors.toList());
|
||||
//添加的用户
|
||||
List<String> collect2 = userRelationForm.getUserIds().stream().filter(t -> !collect.contains(t)).collect(Collectors.toList());
|
||||
userIds.addAll(collect1);
|
||||
userIds.addAll(collect2);
|
||||
Set<String> set = new HashSet<>(userRelationForm.getUserIds());
|
||||
set.addAll(userService.getUserList(collect).stream().map(UserEntity::getId).collect(Collectors.toList()));
|
||||
List<String> list = new ArrayList<>(set);
|
||||
userRelationForm.setUserIds(list);
|
||||
userRelationService.saveObjectId(objectId,userRelationForm);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
31
yunzhupaas-permission/yunzhupaas-permission-entity/pom.xml
Normal file
31
yunzhupaas-permission/yunzhupaas-permission-entity/pom.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-permission</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-permission-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-all</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.dynamic-sql</groupId>
|
||||
<artifactId>mybatis-dynamic-sql</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.yunzhupaas.permission.constant;
|
||||
|
||||
import com.yunzhupaas.model.ExcelColumnAttr;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class OrgColumnMap {
|
||||
|
||||
String excelName = "组织信息";
|
||||
/**
|
||||
* 全部字段
|
||||
*/
|
||||
private Map<String, String> allKeyMap = new LinkedHashMap() {{
|
||||
put("parentId", "所属组织");
|
||||
put("fullName", "名称");
|
||||
put("enCode", "编码");
|
||||
}};
|
||||
/**
|
||||
* 组织map
|
||||
*/
|
||||
private Map<String, String> orgMap = new LinkedHashMap() {{
|
||||
put("category", "类型");
|
||||
put("parentId", "上级公司");
|
||||
put("fullName", "公司名称");
|
||||
put("enCode", "公司编码");
|
||||
put("shortName", "公司简称");
|
||||
put("enterpriseNature", "公司性质");
|
||||
put("industry", "所属行业");
|
||||
put("foundedTime", "成立时间");
|
||||
put("telePhone", "公司电话");
|
||||
put("fax", "公司传真");
|
||||
put("webSite", "公司主页");
|
||||
put("address", "公司地址");
|
||||
put("managerName", "公司法人");
|
||||
put("managerTelePhone", "联系电话");
|
||||
put("managerMobilePhone", "联系手机");
|
||||
put("manageEmail", "联系邮箱");
|
||||
put("bankName", "开户银行");
|
||||
put("bankAccount", "银行账户");
|
||||
put("businessscope", "经营范围");
|
||||
put("managerId", "部门主管");
|
||||
put("sortCode", "排序");
|
||||
put("description", "说明");
|
||||
}};
|
||||
/**
|
||||
* 部门map
|
||||
*/
|
||||
private Map<String, String> depMap = new LinkedHashMap() {{
|
||||
put("category", "类型");
|
||||
put("parentId", "所属组织");
|
||||
put("fullName", "部门名称");
|
||||
put("enCode", "部门编码");
|
||||
put("managerId", "部门主管");
|
||||
put("sortCode", "排序");
|
||||
put("description", "说明");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 根据类型获取excel表头字段
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getColumnByType(Integer type) {
|
||||
Map<String, String> map = new LinkedHashMap();
|
||||
switch (type) {
|
||||
case 2:
|
||||
map = new LinkedHashMap(depMap);
|
||||
break;
|
||||
case 1:
|
||||
map = new LinkedHashMap(orgMap);
|
||||
map.remove("managerId");
|
||||
break;
|
||||
default:
|
||||
map = new LinkedHashMap(orgMap);
|
||||
map.putAll(allKeyMap);
|
||||
break;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getExcelName() {
|
||||
return excelName;
|
||||
}
|
||||
|
||||
|
||||
public List<ExcelColumnAttr> getFieldsModel(boolean isError, Integer type) {
|
||||
List<ExcelColumnAttr> models = new ArrayList<>();
|
||||
//异常原因
|
||||
if (isError) {
|
||||
ExcelColumnAttr attr = new ExcelColumnAttr().builder()
|
||||
.key("errorsInfo")
|
||||
.name("异常原因")
|
||||
.build();
|
||||
models.add(attr);
|
||||
}
|
||||
List<String> requirelist = Arrays.asList("category", "fullName", "enCode");
|
||||
// 遍历添加属性
|
||||
Map<String, String> keyMap = getColumnByType(type);
|
||||
|
||||
for (String key : keyMap.keySet()) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder()
|
||||
.key(key)
|
||||
.name(keyMap.get(key))
|
||||
.build();
|
||||
if (requirelist.contains(key)) {
|
||||
attr.setRequire(true);
|
||||
attr.setFontColor(IndexedColors.RED.getIndex());
|
||||
}
|
||||
models.add(attr);
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认值
|
||||
*/
|
||||
public List<Map<String, Object>> getDefaultList() {
|
||||
Map<String, Object> orgMapDemo = new HashMap<>();
|
||||
orgMapDemo.put("fullName", "公司名称/公司名称1");
|
||||
orgMapDemo.put("foundedTime", "yyy-MM-dd");
|
||||
Map<String, Object> depMapDemo = new HashMap<>();
|
||||
depMapDemo.put("fullName", "公司名称/公司名称1/部门名称");
|
||||
depMapDemo.put("managerId", "姓名/账号");
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
list.add(orgMapDemo);
|
||||
list.add(depMapDemo);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.yunzhupaas.permission.constant;
|
||||
|
||||
import com.yunzhupaas.model.ExcelColumnAttr;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PosColumnMap {
|
||||
|
||||
String excelName = "岗位信息";
|
||||
|
||||
Map<String, String> keyMap = new LinkedHashMap() {{
|
||||
put("organizeId", "所属组织");
|
||||
put("fullName", "岗位名称");
|
||||
put("enCode", "岗位编码");
|
||||
put("type", "岗位类型");
|
||||
put("enabledMark", "状态");
|
||||
put("sortCode", "排序");
|
||||
put("description", "说明");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 表格名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getExcelName() {
|
||||
return excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取excel表头字段
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getColumnByType(Integer type) {
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段列表
|
||||
*
|
||||
* @param isError
|
||||
* @return
|
||||
*/
|
||||
public List<ExcelColumnAttr> getFieldsModel(boolean isError) {
|
||||
List<ExcelColumnAttr> models = new ArrayList<>();
|
||||
//异常原因
|
||||
if (isError) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key("errorsInfo").name("异常原因").build();
|
||||
models.add(attr);
|
||||
}
|
||||
List<String> requireFields = Arrays.asList("organizeId", "fullName", "enCode", "type", "enabledMark");
|
||||
for (String key : keyMap.keySet()) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key(key).name(keyMap.get(key)).build();
|
||||
if (requireFields.contains(key)) {
|
||||
attr.setRequire(true);
|
||||
attr.setFontColor(IndexedColors.RED.getIndex());
|
||||
}
|
||||
models.add(attr);
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认值
|
||||
*/
|
||||
public List<Map<String, Object>> getDefaultList() {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//所属组织
|
||||
map.put("organizeId", "公司名称/公司名称1/部门名称");
|
||||
list.add(map);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.yunzhupaas.permission.constant;
|
||||
|
||||
import com.yunzhupaas.model.ExcelColumnAttr;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RoleColumnMap {
|
||||
|
||||
String excelName = "角色信息";
|
||||
|
||||
Map<String, String> keyMap = new LinkedHashMap() {{
|
||||
put("fullName", "角色名称");
|
||||
put("enCode", "角色编码");
|
||||
put("globalMark", "角色类型");
|
||||
put("organizeId", "所属组织");
|
||||
put("enabledMark", "状态");
|
||||
put("sortCode", "排序");
|
||||
put("description", "说明");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 表格名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getExcelName() {
|
||||
return excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取excel表头字段
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getColumnByType(Integer type) {
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段列表
|
||||
*
|
||||
* @param isError
|
||||
* @return
|
||||
*/
|
||||
public List<ExcelColumnAttr> getFieldsModel(boolean isError) {
|
||||
List<ExcelColumnAttr> models = new ArrayList<>();
|
||||
//异常原因
|
||||
if (isError) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key("errorsInfo").name("异常原因").build();
|
||||
models.add(attr);
|
||||
}
|
||||
List<String> requireFields = Arrays.asList("fullName", "enCode", "globalMark", "enabledMark");
|
||||
for (String key : keyMap.keySet()) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key(key).name(keyMap.get(key)).build();
|
||||
if (requireFields.contains(key)) {
|
||||
attr.setRequire(true);
|
||||
attr.setFontColor(IndexedColors.RED.getIndex());
|
||||
}
|
||||
models.add(attr);
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认值
|
||||
*/
|
||||
public List<Map<String, Object>> getDefaultList() {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("organizeId", "公司名称/公司名称1/部门名称");
|
||||
list.add(map);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.yunzhupaas.permission.constant;
|
||||
|
||||
import com.yunzhupaas.model.ExcelColumnAttr;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class UserColumnMap {
|
||||
|
||||
String excelName = "用户信息";
|
||||
|
||||
Map<String, String> keyMap = new LinkedHashMap() {{
|
||||
put("account", "账户");
|
||||
put("realName", "姓名");
|
||||
put("gender", "性别");
|
||||
put("email", "电子邮箱");
|
||||
put("organizeId", "所属组织");
|
||||
put("managerId", "直属主管");
|
||||
put("positionId", "岗位");
|
||||
put("ranks", "职级");
|
||||
put("roleId", "角色");
|
||||
put("nation", "民族");
|
||||
put("nativePlace", "籍贯");
|
||||
put("entryDate", "入职时间");
|
||||
put("certificatesType", "证件类型");
|
||||
put("certificatesNumber", "证件号码");
|
||||
put("education", "文化程度");
|
||||
put("birthday", "出生年月");
|
||||
put("telePhone", "办公电话");
|
||||
put("landline", "办公座机");
|
||||
put("mobilePhone", "手机号码");
|
||||
put("urgentContacts", "紧急联系");
|
||||
put("urgentTelePhone", "紧急电话");
|
||||
put("postalAddress", "通讯地址");
|
||||
|
||||
put("enabledMark", "状态");
|
||||
put("sortCode", "排序");
|
||||
put("description", "说明");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 表格名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getExcelName() {
|
||||
return excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取excel表头字段
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getColumnByType(Integer type) {
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段列表
|
||||
*
|
||||
* @param isError
|
||||
* @return
|
||||
*/
|
||||
public List<ExcelColumnAttr> getFieldsModel(boolean isError) {
|
||||
List<ExcelColumnAttr> models = new ArrayList<>();
|
||||
//异常原因
|
||||
if (isError) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key("errorsInfo").name("异常原因").build();
|
||||
models.add(attr);
|
||||
}
|
||||
List<String> requireFields = Arrays.asList("account", "realName", "gender", "organizeId", "enabledMark");
|
||||
for (String key : keyMap.keySet()) {
|
||||
ExcelColumnAttr attr = ExcelColumnAttr.builder().key(key).name(keyMap.get(key)).build();
|
||||
if (requireFields.contains(key)) {
|
||||
attr.setRequire(true);
|
||||
attr.setFontColor(IndexedColors.RED.getIndex());
|
||||
}
|
||||
models.add(attr);
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认值
|
||||
*/
|
||||
public List<Map<String, Object>> getDefaultList() {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("organizeId", "公司名称/公司名称1/部门名称,公司名称/公司名称1/部门名称1");
|
||||
map.put("managerId", "姓名/账号");
|
||||
map.put("positionId", "岗位名称/岗位编码,岗位名称1/岗位编码1");
|
||||
map.put("roleId", "角色名称/角色编码,角色名称1/角色编码1");
|
||||
map.put("entryDate", "yyyy-MM-dd");
|
||||
map.put("birthday", "yyyy-MM-dd");
|
||||
list.add(map);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 操作权限
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright YUNZHUPAAS信息技AuthorizeController术有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_authorize")
|
||||
public class AuthorizeEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* 项目类型
|
||||
*/
|
||||
@TableField("f_item_type")
|
||||
private String itemType;
|
||||
|
||||
/**
|
||||
* 项目主键
|
||||
*/
|
||||
@TableField("f_item_id")
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 对象类型
|
||||
*/
|
||||
@TableField("f_object_type")
|
||||
private String objectType;
|
||||
|
||||
/**
|
||||
* 对象主键
|
||||
*/
|
||||
@TableField("f_object_id")
|
||||
private String objectId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 模块列表权限
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/15 9:20
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_columns_purview")
|
||||
public class ColumnsPurviewEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/**
|
||||
* 列表字段数组
|
||||
*/
|
||||
@TableField("f_field_list")
|
||||
private String fieldList;
|
||||
/**
|
||||
* 模块ID
|
||||
*/
|
||||
@TableField("f_module_id")
|
||||
private String moduleId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 分组管理
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/10 17:53
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_group")
|
||||
public class GroupEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField("f_en_code")
|
||||
private String enCode;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("f_category")
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* 机构分级管理员
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_organize_administrator")
|
||||
public class OrganizeAdministratorEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@TableField("F_USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 机构主键
|
||||
*/
|
||||
@TableField("F_ORGANIZE_ID")
|
||||
private String organizeId;
|
||||
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
@TableField("F_ORGANIZE_TYPE")
|
||||
private String organizeType;
|
||||
|
||||
/**
|
||||
* 本层添加
|
||||
*/
|
||||
@TableField("F_THIS_LAYER_ADD")
|
||||
private Integer thisLayerAdd;
|
||||
|
||||
/**
|
||||
* 本层编辑
|
||||
*/
|
||||
@TableField("F_THIS_LAYER_EDIT")
|
||||
private Integer thisLayerEdit;
|
||||
|
||||
/**
|
||||
* 本层删除
|
||||
*/
|
||||
@TableField("F_THIS_LAYER_DELETE")
|
||||
private Integer thisLayerDelete;
|
||||
|
||||
/**
|
||||
* 子层添加
|
||||
*/
|
||||
@TableField("F_SUB_LAYER_ADD")
|
||||
private Integer subLayerAdd;
|
||||
|
||||
/**
|
||||
* 子层编辑
|
||||
*/
|
||||
@TableField("F_SUB_LAYER_EDIT")
|
||||
private Integer subLayerEdit;
|
||||
|
||||
/**
|
||||
* 子层删除
|
||||
*/
|
||||
@TableField("F_SUB_LAYER_DELETE")
|
||||
private Integer subLayerDelete;
|
||||
|
||||
/**
|
||||
* 本层查看
|
||||
*/
|
||||
@TableField("F_THIS_LAYER_SELECT")
|
||||
private Integer thisLayerSelect;
|
||||
|
||||
/**
|
||||
* 子层查看
|
||||
*/
|
||||
@TableField("F_SUB_LAYER_SELECT")
|
||||
private Integer subLayerSelect;
|
||||
|
||||
/**
|
||||
* 管理组
|
||||
*/
|
||||
@TableField("F_MANAGER_GROUP")
|
||||
private String managerGroup;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织机构
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_organize")
|
||||
public class OrganizeEntity extends PermissionEntityBase{
|
||||
/**
|
||||
* 机构上级
|
||||
*/
|
||||
@TableField("F_PARENT_ID")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 机构分类
|
||||
*/
|
||||
@TableField("F_CATEGORY")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 机构编号
|
||||
*/
|
||||
@TableField("F_EN_CODE")
|
||||
private String enCode;
|
||||
|
||||
/**
|
||||
* 机构名称
|
||||
*/
|
||||
@TableField("F_FULL_NAME")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 机构主管
|
||||
*/
|
||||
@TableField("F_MANAGER_ID")
|
||||
private String managerId;
|
||||
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
@TableField("F_PROPERTY_JSON")
|
||||
private String propertyJson;
|
||||
|
||||
/**
|
||||
* 父级组织
|
||||
*/
|
||||
@TableField("F_ORGANIZE_ID_TREE")
|
||||
private String organizeIdTree;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织关系
|
||||
* </p>
|
||||
*
|
||||
* @author
|
||||
* @since 2022-01-19
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_organize_relation")
|
||||
@Schema(description = "OrganizeRelation对象", name = "组织关系")
|
||||
public class OrganizeRelationEntity extends SuperExtendEntity<String> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 组织主键
|
||||
*/
|
||||
@TableField("F_ORGANIZE_ID")
|
||||
private String organizeId;
|
||||
|
||||
/**
|
||||
* 对象类型(角色:role)
|
||||
*/
|
||||
@TableField("F_OBJECT_TYPE")
|
||||
private String objectType;
|
||||
|
||||
/**
|
||||
* 对象主键
|
||||
*/
|
||||
@TableField("F_OBJECT_ID")
|
||||
private String objectId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 类功能
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/1/27
|
||||
*/
|
||||
@Data
|
||||
public class PermissionEntityBase extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField("f_en_code")
|
||||
private String enCode;
|
||||
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
@TableField("f_property_json")
|
||||
private String propertyJson;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("base_permission_group")
|
||||
public class PermissionGroupEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField("F_en_code")
|
||||
private String enCode;
|
||||
|
||||
/**
|
||||
* 权限成员
|
||||
*/
|
||||
@TableField("F_permission_member")
|
||||
private String permissionMember;
|
||||
|
||||
/**
|
||||
* 权限类型 1.自定义 0.全部
|
||||
*/
|
||||
@TableField("F_type")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 岗位信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_position")
|
||||
public class PositionEntity extends PermissionEntityBase{
|
||||
|
||||
/**
|
||||
* 岗位类型
|
||||
*/
|
||||
@TableField("F_TYPE")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 机构主键
|
||||
*/
|
||||
@TableField("F_ORGANIZE_ID")
|
||||
private String organizeId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_role")
|
||||
public class RoleEntity extends PermissionEntityBase{
|
||||
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
@TableField("F_TYPE")
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 全局标识
|
||||
*/
|
||||
@TableField("F_GLOBAL_MARK")
|
||||
private Integer globalMark;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 个人签名
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/28
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_sign_img")
|
||||
public class SignEntity extends SuperEntity<String> {
|
||||
|
||||
/**
|
||||
* 签名图片
|
||||
*/
|
||||
@TableField("F_SIGN_IMG")
|
||||
private String signImg;
|
||||
|
||||
/**
|
||||
* 是否默认
|
||||
*/
|
||||
@TableField("F_IS_DEFAULT")
|
||||
private Integer isDefault;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 流程设计
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.2
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/7/14 9:28:32
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_socials_users")
|
||||
public class SocialsUserEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("F_USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 第三方类型
|
||||
*/
|
||||
@TableField("F_SOCIAL_TYPE")
|
||||
private String socialType;
|
||||
|
||||
/**
|
||||
* 第三方账号id
|
||||
*/
|
||||
@TableField("F_SOCIAL_ID")
|
||||
private String socialId;
|
||||
|
||||
/**
|
||||
* 第三方账号
|
||||
*/
|
||||
@TableField("F_SOCIAL_NAME")
|
||||
private String socialName;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_user")
|
||||
public class UserEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
/**
|
||||
* 账户
|
||||
*/
|
||||
@TableField("F_ACCOUNT")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@TableField("F_REAL_NAME")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 快速查询
|
||||
*/
|
||||
@TableField("F_QUICK_QUERY")
|
||||
private String quickQuery;
|
||||
|
||||
/**
|
||||
* 呢称
|
||||
*/
|
||||
@TableField("F_NICK_NAME")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@TableField("F_HEAD_ICON")
|
||||
private String headIcon;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@TableField("F_GENDER")
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@TableField("F_BIRTHDAY")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
@TableField("F_MOBILE_PHONE")
|
||||
private String mobilePhone;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
@TableField("F_TELE_PHONE")
|
||||
private String telePhone;
|
||||
|
||||
/**
|
||||
* 有效标志(0-禁用,1-启用)
|
||||
*/
|
||||
@TableField("F_ENABLED_MARK")
|
||||
private Integer enabledMark;
|
||||
|
||||
/**
|
||||
* F_Landline
|
||||
*/
|
||||
@TableField("F_LANDLINE")
|
||||
private String landline;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@TableField("F_EMAIL")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
@TableField("F_NATION")
|
||||
private String nation;
|
||||
|
||||
/**
|
||||
* 籍贯
|
||||
*/
|
||||
@TableField("F_NATIVE_PLACE")
|
||||
private String nativePlace;
|
||||
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
@TableField(value = "F_ENTRY_DATE")
|
||||
private Date entryDate;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
*/
|
||||
@TableField("F_CERTIFICATES_TYPE")
|
||||
private String certificatesType;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
*/
|
||||
@TableField("F_CERTIFICATES_NUMBER")
|
||||
private String certificatesNumber;
|
||||
|
||||
/**
|
||||
* 文化程度
|
||||
*/
|
||||
@TableField("F_EDUCATION")
|
||||
private String education;
|
||||
|
||||
/**
|
||||
* F_UrgentContacts
|
||||
*/
|
||||
@TableField("F_URGENT_CONTACTS")
|
||||
private String urgentContacts;
|
||||
|
||||
/**
|
||||
* 紧急电话
|
||||
*/
|
||||
@TableField("F_URGENT_TELE_PHONE")
|
||||
private String urgentTelePhone;
|
||||
|
||||
/**
|
||||
* 通讯地址
|
||||
*/
|
||||
@TableField("F_POSTAL_ADDRESS")
|
||||
private String postalAddress;
|
||||
|
||||
/**
|
||||
* 自我介绍
|
||||
*/
|
||||
@TableField("F_SIGNATURE")
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@TableField("F_PASSWORD")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 秘钥
|
||||
*/
|
||||
@TableField("F_SECRETKEY")
|
||||
private String secretkey;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("F_CREATOR_TIME")
|
||||
private Date creatorTime;
|
||||
|
||||
/**
|
||||
* 首次登录时间
|
||||
*/
|
||||
@TableField("F_FIRST_LOG_TIME")
|
||||
private Date firstLogTime;
|
||||
|
||||
/**
|
||||
* 首次登录IP
|
||||
*/
|
||||
@TableField("F_FIRST_LOG_IP")
|
||||
private String firstLogIp;
|
||||
|
||||
/**
|
||||
* 前次登录时间
|
||||
*/
|
||||
@TableField("F_PREV_LOG_TIME")
|
||||
private Date prevLogTime;
|
||||
|
||||
/**
|
||||
* 前次登录IP
|
||||
*/
|
||||
@TableField("F_PREV_LOG_IP")
|
||||
private String prevLogIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
@TableField("F_LAST_LOG_TIME")
|
||||
private Date lastLogTime;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@TableField("F_LAST_LOG_IP")
|
||||
private String lastLogIp;
|
||||
|
||||
/**
|
||||
* 登录成功次数
|
||||
*/
|
||||
@TableField("F_LOG_SUCCESS_COUNT")
|
||||
private Integer logSuccessCount;
|
||||
|
||||
/**
|
||||
* 登录错误次数
|
||||
*/
|
||||
@TableField("F_LOG_ERROR_COUNT")
|
||||
private Integer logErrorCount;
|
||||
|
||||
/**
|
||||
* 最后修改密码时间
|
||||
*/
|
||||
@TableField("F_CHANGE_PASSWORD_DATE")
|
||||
private Date changePasswordDate;
|
||||
|
||||
/**
|
||||
* 系统语言
|
||||
*/
|
||||
@TableField("F_LANGUAGE")
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* 系统样式
|
||||
*/
|
||||
@TableField("F_THEME")
|
||||
private String theme;
|
||||
|
||||
/**
|
||||
* 常用菜单
|
||||
*/
|
||||
@TableField("F_COMMON_MENU")
|
||||
private String commonMenu;
|
||||
|
||||
/**
|
||||
* 是否管理员
|
||||
*/
|
||||
@TableField("F_IS_ADMINISTRATOR")
|
||||
private Integer isAdministrator;
|
||||
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
@TableField("F_PROPERTY_JSON")
|
||||
private String propertyJson;
|
||||
|
||||
/**
|
||||
* 主管主键
|
||||
*/
|
||||
@TableField("F_MANAGER_ID")
|
||||
private String managerId;
|
||||
|
||||
/**
|
||||
* 组织主键
|
||||
*/
|
||||
@TableField("F_ORGANIZE_ID")
|
||||
private String organizeId;
|
||||
|
||||
/**
|
||||
* 岗位主键
|
||||
*/
|
||||
@TableField("F_POSITION_ID")
|
||||
private String positionId;
|
||||
|
||||
/**
|
||||
* 角色主键
|
||||
*/
|
||||
@TableField("F_ROLE_ID")
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 门户主键
|
||||
*/
|
||||
@TableField("F_PORTAL_ID")
|
||||
private String portalId;
|
||||
|
||||
/**
|
||||
* 是否锁定
|
||||
*/
|
||||
@TableField("F_LOCK_MARK")
|
||||
private Integer lockMark;
|
||||
|
||||
/**
|
||||
* 解锁时间
|
||||
*/
|
||||
@TableField(value = "F_UNLOCK_TIME",updateStrategy = FieldStrategy.IGNORED)
|
||||
private Date unlockTime;
|
||||
|
||||
/**
|
||||
* 分组id
|
||||
*/
|
||||
@TableField("F_GROUP_ID")
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
* 系统id
|
||||
*/
|
||||
@TableField("F_SYSTEM_ID")
|
||||
private String systemId;
|
||||
|
||||
/**
|
||||
* App系统id
|
||||
*/
|
||||
@TableField("F_APP_SYSTEM_ID")
|
||||
private String appSystemId;
|
||||
|
||||
/**
|
||||
* 钉钉工号
|
||||
*/
|
||||
@TableField("F_DING_JOB_NUMBER")
|
||||
private String dingJobNumber;
|
||||
|
||||
/**
|
||||
* 交接状态
|
||||
*/
|
||||
@TableField("f_handover_mark")
|
||||
private Integer handoverMark;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@TableField("f_rank")
|
||||
private String ranks;
|
||||
|
||||
/**
|
||||
* 身份
|
||||
*/
|
||||
@TableField("F_STANDING")
|
||||
private Integer standing;
|
||||
|
||||
/**
|
||||
* 身份
|
||||
*/
|
||||
@TableField("F_APP_STANDING")
|
||||
private Integer appStanding;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "base_user_old_password")
|
||||
public class UserOldPasswordEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* userid
|
||||
*/
|
||||
@TableField("F_USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 账户
|
||||
*/
|
||||
@TableField("F_ACCOUNT")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 旧密码
|
||||
*/
|
||||
@TableField("F_OLD_PASSWORD")
|
||||
private String oldPassword;
|
||||
|
||||
/**
|
||||
* 秘钥
|
||||
*/
|
||||
@TableField("F_SECRETKEY")
|
||||
private String secretkey;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yunzhupaas.permission.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户关系
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_user_relation")
|
||||
public class UserRelationEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@TableField("F_USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 对象类型
|
||||
*/
|
||||
@TableField("F_OBJECT_TYPE")
|
||||
private String objectType;
|
||||
|
||||
/**
|
||||
* 对象主键
|
||||
*/
|
||||
@TableField("F_OBJECT_ID")
|
||||
private String objectId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.yunzhupaas.constant.DataInterfaceVarConst;
|
||||
import com.yunzhupaas.util.visiual.YunzhupaasKeyConsts;
|
||||
|
||||
/**
|
||||
* 数据权限过滤条件字段
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.2
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024/10/9
|
||||
*/
|
||||
public enum AuthorizeConditionEnum {
|
||||
/**
|
||||
* 表单主键
|
||||
*/
|
||||
FORMID(DataInterfaceVarConst.FORM_ID, "表单主键"),
|
||||
/**
|
||||
* 当前用户
|
||||
*/
|
||||
USER(DataInterfaceVarConst.USER, "当前用户"),
|
||||
/**
|
||||
* 当前用户及下属
|
||||
*/
|
||||
USERANDUNDER(DataInterfaceVarConst.USERANDSUB, "当前用户及下属"),
|
||||
/**
|
||||
* 当前组织
|
||||
*/
|
||||
ORGANIZE(DataInterfaceVarConst.ORG, "当前组织"),
|
||||
/**
|
||||
* 当前组织及子组织
|
||||
*/
|
||||
ORGANIZEANDUNDER(DataInterfaceVarConst.ORGANDSUB, "当前组织及子组织"),
|
||||
/**
|
||||
* 当前分管组织
|
||||
*/
|
||||
BRANCHMANAGEORG(DataInterfaceVarConst.CHARORG, "当前分管组织"),
|
||||
/**
|
||||
* 当前岗位
|
||||
*/
|
||||
POSITIONID(DataInterfaceVarConst.POSITIONID, "当前岗位"),
|
||||
/**
|
||||
* 当前部门
|
||||
*/
|
||||
DEPID(DataInterfaceVarConst.DEPID, "当前部门"),
|
||||
/**
|
||||
* 当前部门及下级部门
|
||||
*/
|
||||
DEPANDSUBORDINATES(DataInterfaceVarConst.DEPANDSUBORDINATES, "当前部门及下级部门"),
|
||||
/**
|
||||
* 当前时间
|
||||
*/
|
||||
CURRENTTIME(DataInterfaceVarConst.CURRENTTIME, "当前时间"),
|
||||
/**
|
||||
* 任意文本
|
||||
*/
|
||||
TEXT(YunzhupaasKeyConsts.COM_INPUT, "任意文本"),
|
||||
DATATIME(YunzhupaasKeyConsts.DATE, "日期选择"),
|
||||
INPUTNUMBER(YunzhupaasKeyConsts.NUM_INPUT, "数字输入"),
|
||||
COMSELECT(YunzhupaasKeyConsts.COMSELECT, "组织选择"),
|
||||
DEPSELECT(YunzhupaasKeyConsts.DEPSELECT, "部门选择"),
|
||||
POSSELECT(YunzhupaasKeyConsts.POSSELECT, "岗位选择"),
|
||||
ROLESELECT(YunzhupaasKeyConsts.ROLESELECT, "角色选择"),
|
||||
GROUPSELECT(YunzhupaasKeyConsts.GROUPSELECT, "分组选择"),
|
||||
USERSELECT(YunzhupaasKeyConsts.USERSELECT, "用户选择"),
|
||||
|
||||
;
|
||||
|
||||
private String condition;
|
||||
private String message;
|
||||
|
||||
AuthorizeConditionEnum(String condition, String message) {
|
||||
this.condition = condition;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static AuthorizeConditionEnum getByMessage(String condition) {
|
||||
for (AuthorizeConditionEnum status : AuthorizeConditionEnum.values()) {
|
||||
if (status.getCondition().equals(condition)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthorizeConditionModel<T>{
|
||||
private QueryWrapper<T> obj;
|
||||
private String moduleId;
|
||||
private String tableName;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据权限
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:04
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeDataModel extends SumTree {
|
||||
private String id;
|
||||
private String fullName;
|
||||
private String icon;
|
||||
private Boolean showcheck;
|
||||
private Integer checkstate;
|
||||
private String title;
|
||||
private String moduleId;
|
||||
private String type;
|
||||
private Date creatorTime;
|
||||
private String category;
|
||||
private boolean disabled;
|
||||
private Long sortCode=9999L;
|
||||
private String systemId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:26
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AuthorizeDataReturnModel {
|
||||
private String id;
|
||||
private String fullName;
|
||||
private String icon;
|
||||
private String type;
|
||||
private Long sortCode=999L;
|
||||
private String category;
|
||||
private boolean disabled;
|
||||
private Long creatorTime;
|
||||
private List<AuthorizeDataReturnModel> children;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeDataReturnVO {
|
||||
@Schema(description = "权限模型集合")
|
||||
List<AuthorizeDataReturnModel> list;
|
||||
@Schema(description = "id集合")
|
||||
List<String> ids;
|
||||
//all字段里面不包括菜单id
|
||||
@Schema(description = "所有的id")
|
||||
List<String> all;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeDataUpForm {
|
||||
@Schema(description = "对象类型")
|
||||
private String objectType;
|
||||
|
||||
@Schema(description = "按钮id")
|
||||
private String[] button;
|
||||
@Schema(description = "列表id")
|
||||
private String[] column;
|
||||
@Schema(description = "菜单id")
|
||||
private String[] module;
|
||||
@Schema(description = "数据权限方案id")
|
||||
private String[] resource;
|
||||
@Schema(description = "表单id")
|
||||
private String[] form;
|
||||
|
||||
|
||||
@Schema(description = "系统id")
|
||||
private String[] systemIds;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeDataVO {
|
||||
private AuthorizeDataReturnVO module;
|
||||
private AuthorizeDataReturnVO button;
|
||||
private AuthorizeDataReturnVO column;
|
||||
private AuthorizeDataReturnVO resource;
|
||||
private AuthorizeDataReturnVO form;
|
||||
private AuthorizeDataReturnVO system;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeDataValuesVO {
|
||||
List<AuthorizeDataReturnModel> list;
|
||||
List<String> ids;
|
||||
List<String> all;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeItemObjIdsVO {
|
||||
@Schema(description = "id集合")
|
||||
private List<String> ids;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:27
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeModel extends SumTree {
|
||||
private String id;
|
||||
private String fullName;
|
||||
private String icon;
|
||||
|
||||
private Date creatorTime;
|
||||
private long sortCode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import com.yunzhupaas.base.model.base.SystemBaeModel;
|
||||
import com.yunzhupaas.base.model.button.ButtonModel;
|
||||
import com.yunzhupaas.base.model.column.ColumnModel;
|
||||
import com.yunzhupaas.base.model.form.ModuleFormModel;
|
||||
import com.yunzhupaas.base.model.module.ModuleModel;
|
||||
import com.yunzhupaas.base.model.resource.ResourceModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:29
|
||||
*/
|
||||
@Data
|
||||
public class AuthorizeVO {
|
||||
// 菜单
|
||||
// private List<MenuModel> menuList;
|
||||
|
||||
/**
|
||||
* 功能
|
||||
*/
|
||||
private List<ModuleModel> moduleList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
private List<ButtonModel> buttonList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 视图
|
||||
*/
|
||||
private List<ColumnModel> columnList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 资源
|
||||
*/
|
||||
private List<ResourceModel> resourceList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 表单
|
||||
*/
|
||||
private List<ModuleFormModel> formsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 系统
|
||||
*/
|
||||
private List<SystemBaeModel> systemList = new ArrayList<>();
|
||||
|
||||
public AuthorizeVO(List<ModuleModel> moduleList, List<ButtonModel> buttonList, List<ColumnModel> columnList, List<ResourceModel> resourceList, List<ModuleFormModel> formsList, List<SystemBaeModel> systemList) {
|
||||
// this.menuList = menuList;
|
||||
this.moduleList = moduleList;
|
||||
this.buttonList = buttonList;
|
||||
this.columnList = columnList;
|
||||
this.resourceList = resourceList;
|
||||
this.formsList = formsList;
|
||||
this.systemList = systemList;
|
||||
}
|
||||
|
||||
public AuthorizeVO() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class ConditionModel {
|
||||
private String logic;
|
||||
private List<ConditionItemModel> groups;
|
||||
|
||||
/**
|
||||
* 数据权限条件字段
|
||||
*/
|
||||
@Data
|
||||
public class ConditionItemModel{
|
||||
private String id;
|
||||
private String field;
|
||||
private String type;
|
||||
private String op;
|
||||
private String value;
|
||||
private String fieldRule;
|
||||
private String bindTable;
|
||||
private String conditionText;
|
||||
private String childTableKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class DataValuesQuery {
|
||||
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
@Schema(description = "菜单id集合")
|
||||
private String moduleIds;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import lombok.Data;
|
||||
import org.mybatis.dynamic.sql.BasicColumn;
|
||||
import org.mybatis.dynamic.sql.SqlColumn;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* dynamicSql模型
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.4.4
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2022/9/27
|
||||
*/
|
||||
@Data
|
||||
public class OnlineDynamicSqlModel {
|
||||
private List<BasicColumn> columns;
|
||||
private SqlTable sqlTable;
|
||||
private String tableName;
|
||||
private boolean isMain;
|
||||
private String foreign;
|
||||
private String relationKey;
|
||||
|
||||
public OnlineDynamicSqlModel(){
|
||||
|
||||
}
|
||||
|
||||
public OnlineDynamicSqlModel(SqlTable sqlTable, List<BasicColumn> sqlColumns) {
|
||||
this.sqlTable = sqlTable;
|
||||
this.columns = sqlColumns;
|
||||
this.isMain = true;
|
||||
}
|
||||
|
||||
public OnlineDynamicSqlModel(SqlTable sqlTable, List<BasicColumn> sqlColumns,String foreign,String relationKey, boolean b) {
|
||||
this.sqlTable = sqlTable;
|
||||
this.columns = sqlColumns;
|
||||
this.foreign = foreign;
|
||||
this.relationKey = relationKey;
|
||||
this.isMain = b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class ResourceVO {
|
||||
@Schema(description = "资源主键")
|
||||
private String id;
|
||||
@Schema(description = "资源名称")
|
||||
private String fullName;
|
||||
@Schema(description = "资源编码")
|
||||
private String enCode;
|
||||
@Schema(description = "条件规则")
|
||||
private String conditionJson;
|
||||
@Schema(description = "规则描述")
|
||||
private String conditionText;
|
||||
@Schema(description = "功能主键")
|
||||
private String moduleId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunzhupaas.permission.model.authorize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class SaveBatchForm {
|
||||
@Schema(description = "角色id集合")
|
||||
private String[] roleIds;
|
||||
@Schema(description = "岗位id集合")
|
||||
private String[] positionIds;
|
||||
@Schema(description = "用户id集合")
|
||||
private String[] userIds;
|
||||
@Schema(description = "菜单id集合")
|
||||
private String[] module;
|
||||
@Schema(description = "按钮id集合")
|
||||
private String[] button;
|
||||
@Schema(description = "列表id集合")
|
||||
private String[] column;
|
||||
@Schema(description = "数据权限方案id集合")
|
||||
private String[] resource;
|
||||
@Schema(description = "表单id集合")
|
||||
private String[] form;
|
||||
|
||||
@Schema(description = "系统id集合")
|
||||
private String[] systemIds;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.permission.model.check;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CheckResult {
|
||||
|
||||
private boolean pass = true;
|
||||
|
||||
private String errorMsg;
|
||||
|
||||
private Object value;
|
||||
|
||||
public CheckResult(boolean pass, String errorMsg, Object value) {
|
||||
this.pass = pass;
|
||||
this.errorMsg = errorMsg;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.permission.model.columnspurview;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 列表权限修改模型
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/15 9:59
|
||||
*/
|
||||
@Data
|
||||
public class ColumnsPurviewUpForm implements Serializable {
|
||||
@Schema(description = "列表字段数组")
|
||||
private String fieldList;
|
||||
@Schema(description = "模块ID")
|
||||
@NotBlank(message = "操作模块不能为空")
|
||||
private String moduleId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.permission.model.organize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class OrganizeByAuthModel extends OrganizeModel {
|
||||
|
||||
@Schema(description = "是否可选")
|
||||
private Boolean disabled = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yunzhupaas.permission.model.organize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yunzhupaas.base.Page;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/6/8 14:05
|
||||
*/
|
||||
@Data
|
||||
public class OrganizeConditionModel extends Page implements Serializable {
|
||||
|
||||
@Schema(description = "部门id集合")
|
||||
private List<String> departIds;
|
||||
|
||||
private Map<String, String> orgIdNameMaps;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.permission.model.organize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class OrganizeCrForm {
|
||||
|
||||
@NotBlank(message = "公司上级不能为空")
|
||||
private String parentId;
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String fullName;
|
||||
@NotBlank(message = "公司编码不能为空")
|
||||
private String enCode;
|
||||
private String description;
|
||||
@NotNull(message = "公司状态不能为空")
|
||||
private Integer enabledMark;
|
||||
private OrganizeCrModel propertyJson;
|
||||
@Schema(description = "排序")
|
||||
private Long sortCode;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user