同步框架更新

This commit is contained in:
yaoyn
2025-02-15 17:05:09 +08:00
parent 29b5c68564
commit 9b7d27a2b4
141 changed files with 585 additions and 133 deletions

View File

@ -52,11 +52,13 @@
<groupId>com.cloud.govern</groupId>
<artifactId>service-invoke-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.xjrsoft</groupId>
<artifactId>xjrsoft-service-system-api</artifactId>
<version>${xjrsoft.framework.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -1,5 +1,6 @@
package com.xjrsoft.organization.client;
import com.alibaba.fastjson.JSON;
import com.xjrsoft.common.core.constant.GlobalConstant;
import com.xjrsoft.common.redis.service.RedisUtil;
import com.xjrsoft.organization.entity.Department;
@ -65,8 +66,8 @@ public class DepartmentClient implements IDepartmentClient {
}
@Override
public List<Department> queryPathFromRoot(List<Department> list) {
@PostMapping(value = GlobalConstant.CLIENT_API_PRE + GlobalConstant.MODULE_ORGANIZATION_NAME + "/queryPathFromRootFeign")
public List<Department> queryPathFromRoot(@RequestBody List<Department> list) {
return departmentService.queryPathFromRoot(list);
}
}

View File

@ -123,9 +123,9 @@ public class UserController {
SaSession tokenSession = StpUtil.getTokenSession();
User user = tokenSession.get(GlobalConstant.LOGIN_USER_INFO_KEY, new User());
UserInfoVo currentInfo = userService.getCurrentInfo(user);
// currentInfo.setTenantId(SecureUtil.getCurrentTenantId());
// currentInfo.setTenantCode(SecureUtil.getCurrentTenantCode());
// currentInfo.setTenantName(SecureUtil.getCurrentTenantName());
/*currentInfo.setTenantId(SecureUtil.getCurrentTenantId());
currentInfo.setTenantCode(SecureUtil.getCurrentTenantCode());
currentInfo.setTenantName(SecureUtil.getCurrentTenantName());*/
return R.ok(currentInfo);
}

View File

@ -0,0 +1,53 @@
package com.xjrsoft.organization.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.organization.entity.Department;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* <p>
* 机构 Mapper 接口
* </p>
*
* @author tzx
* @since 2022-03-02
*/
@Mapper
public interface DepartmentMapper extends MPJBaseMapper<Department> {
@Deprecated
@Select("WITH RECURSIVE parent_path AS ( SELECT id, parent_id FROM xjr_department WHERE id = #{id} UNION ALL SELECT c.id, c.parent_id FROM xjr_department c INNER JOIN parent_path pp ON c.id = pp.parent_id WHERE delete_mark = 0 ) SELECT parent_id FROM parent_path")
List<String> findDeptPIds(@Param("id")String id);
/**
* 查询指定节点的所有父节点id
* 传参:
* queryType=parent
* startIds=Long[]{指定节点}
* @param params
* @return
*/
List<String> findParentIds(@Param("params") Map<String,Object> params);
/**
* 查询部门路径
* 传参:
* queryType=parent
* startIds=Long[]{指定节点开始}
* stopParentIds=Long[]{查询到该节点为止}
* isQueryIdPath是否返回id默认返回部门名称
* isQueryOrderDesc是否由指定节点到根节点的顺序默认是从根节点到指定节点的顺序
* pathSeparator路径分隔符默认是/
* @param params
* @return 部门id,部门路径的map
*/
@MapKey("flag")
Map<Long,Map>queryDeptPath(@Param("params") Map<String,Object> params);
}

View File

@ -0,0 +1,18 @@
package com.xjrsoft.organization.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.organization.entity.Post;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 岗位 Mapper 接口
* </p>
*
* @author tzx
* @since 2022-03-02
*/
@Mapper
public interface PostMapper extends MPJBaseMapper<Post> {
}

View File

@ -0,0 +1,18 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.organization.entity.Role;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 角色 Mapper 接口
* </p>
*
* @author tzx
* @since 2022-03-02
*/
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
}

View File

@ -0,0 +1,14 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.organization.entity.SyncOrgAndUserFromDataCenter;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SyncOrgAndUserFromDataCenterMapper extends MPJBaseMapper<SyncOrgAndUserFromDataCenter> {
@InterceptorIgnore(blockAttack = "true")
@Delete("delete from xjr_sync_datacenter_org_user")
Integer emptyAllData()throws Exception;
}

View File

@ -0,0 +1,18 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.organization.entity.UserChargeDept;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 用户负责部门表 Mapper 接口
* </p>
*
* @author hnyyzy
* @since 2023-12-20
*/
@Mapper
public interface UserChargeDeptMapper extends BaseMapper<UserChargeDept> {
}

View File

@ -0,0 +1,9 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.organization.entity.UserDeptRelation;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserDeptRelationMapper extends BaseMapper<UserDeptRelation> {
}

View File

@ -0,0 +1,25 @@
package com.xjrsoft.organization.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.organization.entity.User;
import org.apache.ibatis.annotations.Mapper;
import com.xjrsoft.organization.entity.Department;
import com.xjrsoft.organization.vo.UserRoleVo;
import java.util.List;
/**
* <p>
* 用户 Mapper 接口
* </p>
*
* @author tzx
* @since 2022-03-02
*/
@Mapper
public interface UserMapper extends MPJBaseMapper<User> {
List<Department> queryDepartmentsOfUser(Long id);
List<UserRoleVo> queryRolesOfUser(Long id);
}

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xjrsoft.module.organization.mapper.UserMapper">
<resultMap id="userVoResultMap" type="com.xjrsoft.module.organization.vo.UserVo">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="user_name" jdbcType="VARCHAR" property="enCode" />
<result column="name" jdbcType="VARCHAR" property="account" />
<result column="code" jdbcType="VARCHAR" property="password" />
<result column="nick_name" jdbcType="VARCHAR" property="secretkey" />
<result column="password" jdbcType="VARCHAR" property="realName" />
<result column="gender" jdbcType="VARCHAR" property="nickName" />
<result column="mobile" jdbcType="VARCHAR" property="headIcon" />
<result column="avatar" jdbcType="VARCHAR" property="quickQuery" />
<result column="email" jdbcType="VARCHAR" property="simpleSpelling" />
<result column="address" jdbcType="INTEGER" property="gender" />
<result column="F_Birthday" jdbcType="TIMESTAMP" property="birthday" />
<result column="F_Mobile" jdbcType="VARCHAR" property="mobile" />
<result column="F_Telephone" jdbcType="VARCHAR" property="telephone" />
<result column="F_Email" jdbcType="VARCHAR" property="email" />
<result column="F_OICQ" jdbcType="VARCHAR" property="oicq" />
<result column="F_WeChat" jdbcType="VARCHAR" property="weChat" />
<result column="F_MSN" jdbcType="VARCHAR" property="msn" />
<result column="F_CompanyId" jdbcType="VARCHAR" property="companyId" />
<result column="F_SecurityLevel" jdbcType="INTEGER" property="securityLevel" />
<result column="F_OpenId" jdbcType="INTEGER" property="openId" />
<result column="F_Question" jdbcType="VARCHAR" property="question" />
<result column="F_AnswerQuestion" jdbcType="VARCHAR" property="answerQuestion" />
<result column="F_CheckOnLine" jdbcType="INTEGER" property="checkOnLine" />
<result column="F_AllowStartTime" jdbcType="TIMESTAMP" property="allowStartTime" />
<result column="F_AllowEndTime" jdbcType="TIMESTAMP" property="allowEndTime" />
<result column="F_LockStartDate" jdbcType="TIMESTAMP" property="lockStartDate" />
<result column="F_LockEndDate" jdbcType="TIMESTAMP" property="lockEndDate" />
<result column="F_SortCode" jdbcType="INTEGER" property="sortCode" />
<result column="F_DeleteMark" jdbcType="INTEGER" property="deleteMark" />
<result column="F_EnabledMark" jdbcType="INTEGER" property="enabledMark" />
<result column="F_Description" jdbcType="VARCHAR" property="description" />
<result column="f_titletechpost" jdbcType="VARCHAR" property="titleTechPost" />
<!-- <result column="F_CreateDate" jdbcType="TIMESTAMP" property="createDate" />-->
<result column="F_CreateUserId" jdbcType="VARCHAR" property="createUserId" />
<!-- <result column="F_CreateUserName" jdbcType="VARCHAR" property="createUserName" />-->
<!-- <result column="F_ModifyDate" jdbcType="TIMESTAMP" property="modifyDate" />-->
<!-- <result column="F_ModifyUserId" jdbcType="VARCHAR" property="modifyUserId" />-->
<!-- <result column="F_ModifyUserName" jdbcType="VARCHAR" property="modifyUserName" />-->
<result column="F_Token" jdbcType="VARCHAR" property="token" />
<collection property="departmentSimpleVoList" column="F_UserId" select="getDepartmentSimpleVo"
javaType="ArrayList" ofType="com.xjrsoft.module.base.vo.DepartmentSimpleVo" >
</collection>
</resultMap>
<resultMap id="departmentResultMap" type="com.xjrsoft.module.organization.entity.Department">
<id column="F_DepartmentId" jdbcType="VARCHAR" property="id" />
<result column="F_CompanyId" jdbcType="VARCHAR" property="name" />
<result column="F_ParentId" jdbcType="VARCHAR" property="parentId" />
<result column="F_EnCode" jdbcType="VARCHAR" property="code" />
<!--<result column="F_FullName" jdbcType="VARCHAR" property="fullName" />
<result column="F_ShortName" jdbcType="VARCHAR" property="shortName" />
<result column="F_Nature" jdbcType="VARCHAR" property="nature" />
<result column="F_Manager" jdbcType="VARCHAR" property="manager" />
<result column="F_OuterPhone" jdbcType="VARCHAR" property="outerPhone" />
<result column="F_InnerPhone" jdbcType="VARCHAR" property="innerPhone" />
<result column="F_Email" jdbcType="VARCHAR" property="email" />
<result column="F_Fax" jdbcType="VARCHAR" property="fax" />
<result column="F_SortCode" jdbcType="INTEGER" property="sortCode" />
<result column="F_DeleteMark" jdbcType="INTEGER" property="deleteMark" />
<result column="F_EnabledMark" jdbcType="INTEGER" property="enabledMark" />
<result column="F_CreateDate" jdbcType="TIMESTAMP" property="createDate" />
<result column="F_CreateUserId" jdbcType="VARCHAR" property="createUserId" />
<result column="F_CreateUserName" jdbcType="VARCHAR" property="createUserName" />
<result column="F_ModifyDate" jdbcType="TIMESTAMP" property="modifyDate" />
<result column="F_ModifyUserId" jdbcType="VARCHAR" property="modifyUserId" />
<result column="F_ModifyUserName" jdbcType="VARCHAR" property="modifyUserName" />
<result column="F_DingTalkId" jdbcType="VARCHAR" property="dingTalkId" />-->
</resultMap>
<resultMap id="roleBaseResultMap" type="com.xjrsoft.module.organization.entity.Role">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="sort_code" jdbcType="VARCHAR" property="sortCode" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<!--<result column="F_FullName" jdbcType="VARCHAR" property="fullName" />
<result column="F_ShortName" jdbcType="VARCHAR" property="shortName" />
<result column="F_Nature" jdbcType="VARCHAR" property="nature" />
<result column="F_Manager" jdbcType="VARCHAR" property="manager" />
<result column="F_OuterPhone" jdbcType="VARCHAR" property="outerPhone" />
<result column="F_InnerPhone" jdbcType="VARCHAR" property="innerPhone" />
<result column="F_Email" jdbcType="VARCHAR" property="email" />
<result column="F_Fax" jdbcType="VARCHAR" property="fax" />
<result column="F_SortCode" jdbcType="INTEGER" property="sortCode" />
<result column="F_DeleteMark" jdbcType="INTEGER" property="deleteMark" />
<result column="F_EnabledMark" jdbcType="INTEGER" property="enabledMark" />
<result column="F_CreateDate" jdbcType="TIMESTAMP" property="createDate" />
<result column="F_CreateUserId" jdbcType="VARCHAR" property="createUserId" />
<result column="F_CreateUserName" jdbcType="VARCHAR" property="createUserName" />
<result column="F_ModifyDate" jdbcType="TIMESTAMP" property="modifyDate" />
<result column="F_ModifyUserId" jdbcType="VARCHAR" property="modifyUserId" />
<result column="F_ModifyUserName" jdbcType="VARCHAR" property="modifyUserName" />
<result column="F_DingTalkId" jdbcType="VARCHAR" property="dingTalkId" />-->
</resultMap>
<select id="queryRolesOfUser" resultMap="roleBaseResultMap">
select
xbr.*
from
xjr_base_role xbr
left join xjr_base_userrelation xbu on
xbr.F_RoleId = xbu.F_ObjectId
and xbu.F_Category = 1
where
xbu.F_UserId = #{param1}
and xbr.F_DeleteMark = 0
and xbr.F_EnabledMark = 1
</select>
<select id="queryDepartmentsOfUser" resultMap="departmentResultMap">
select
xbd.id,xbd.name,xbd.code,xbd.parent_id
from
xjr_department xbd
left join xjr_user_dept_relation xbu on
xbd.id = xbu.dept_id
where
xbu.user_id = #{param1}
and xbd.delete_mark = 0
and xbd.enabled_mark = 1
order by xbd.sort_code
</select>
<select id="queryWithLogicDel" parameterType="map" resultType="com.xjrsoft.module.organization.entity.User">
select *
FROM xjr_user
WHERE
<if test="params.ids != null and params.ids.length>0 ">
id in
<foreach item="item" collection="params.ids" index="i" open="(" separator="," close=")">
#{params.ids[${i}]}
</foreach>
</if>
</select>
</mapper>

View File

@ -0,0 +1,9 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.organization.entity.UserPostRelation;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserPostRelationMapper extends BaseMapper<UserPostRelation> {
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.organization.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.organization.entity.UserRoleRelation;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 用户关联角色表 Mapper 接口
* </p>
*
* @author tzx
* @since 2022-03-02
*/
@Mapper
public interface UserRoleRelationMapper extends BaseMapper<UserRoleRelation> {
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xjrsoft.organization.mapper.DepartmentMapper">
<sql id="DEPT_TREE">
WITH RECURSIVE DEPT_TREE AS (
SELECT id,name,parent_id,code,sort_code,enabled_mark,department_type,equal_dept_id,company_lvl,id as start_id,1 as lvl
FROM xjr_department
WHERE
<if test="params.startIds != null and params.startIds.length>0 ">
id in
<foreach item="item" collection="params.startIds" index="i" open="(" separator="," close=")">
#{params.startIds[${i}]}
</foreach>
</if>
<if test="params.startParentIds != null and params.startParentIds.length>0 ">
parent_id in
<foreach item="item" collection="params.startParentIds" index="i" open="(" separator="," close=")">
#{params.startParentIds[${i}]}
</foreach>
</if>
<if test="params.startChildIds != null and params.startChildIds.length>0 ">
id in (
select a.parent_id from xjr_department a where a.id in
<foreach item="item" collection="params.startChildIds" index="i" open="(" separator="," close=")">
#{params.startChildIds[${i}]}
</foreach>
)
</if>
UNION ALL
SELECT c.id,c.name,c.parent_id,c.code,c.sort_code,c.enabled_mark,c.department_type,c.equal_dept_id,c.company_lvl,t.start_id,t.lvl+1 as lvl
FROM xjr_department c
inner JOIN DEPT_TREE t ON
<if test="params.queryType != null and params.queryType == 'parent'.toString()">
c.id = t.parent_id
</if>
<if test="params.queryType != null and params.queryType == 'children'.toString()">
c.parent_id = t.id
</if>
<if test="params.enabled != null">
and c.enabled_mark = #{params.enabled}
</if>
<if test="params.stopIds != null and params.stopIds.length>0 ">
and c.id not in
<foreach item="item" collection="params.stopIds" index="i" open="(" separator="," close=")">
#{params.stopIds[${i}]}
</foreach>
</if>
<if test="params.stopParentIds != null and params.stopParentIds.length>0 ">
and t.id not in
<foreach item="item" collection="params.stopParentIds" index="i" open="(" separator="," close=")">
#{params.stopParentIds[${i}]}
</foreach>
</if>
<if test="params.stopDeptTypes != null and params.stopDeptTypes.length>0 ">
and c.department_type not in
<foreach item="item" collection="params.stopDeptTypes" index="i" open="(" separator="," close=")">
#{item}
</foreach>
</if>
)
</sql>
<select id="queryDeepOrgs" parameterType="map" resultType="com.xjrsoft.organization.entity.Department">
<include refid="DEPT_TREE"/>
SELECT * FROM DEPT_TREE
<where>
<if test="params.includeDeptTypes != null and params.includeDeptTypes.length>0">
department_type in
<foreach item="item" collection="params.includeDeptTypes" index="i" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="params.excludeDeptTypes != null and params.excludeDeptTypes.length>0">
and department_type not in
<foreach item="item" collection="params.excludeDeptTypes" index="i" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="queryDeptPath" parameterType="map" resultType="Map">
<include refid="DEPT_TREE"/>
select start_id as flag,group_concat(
<choose>
<when test="params.isQueryIdPath != null and params.isQueryIdPath == 'Y'.toString()">id </when>
<otherwise>name </otherwise>
</choose>
order by lvl
<choose>
<when test="params.isQueryOrderDesc != null and params.isQueryOrderDesc == 'Y'.toString()"/>
<otherwise>desc </otherwise>
</choose>
SEPARATOR
<choose>
<when test="params.pathSeparator != null">#{params.pathSeparator} </when>
<otherwise>'/' </otherwise>
</choose>
) as path from DEPT_TREE
group by start_id
</select>
<!--获取公司通过组织ids-->
<select id="queryCompanies" parameterType="map" resultType="com.xjrsoft.organization.entity.Department">
<include refid="DEPT_TREE"/>
select * from (
select row_number() over(partition by start_id order by lvl) as row_number,* from DEPT_TREE where department_type not in(0)
) where row_number = 1
</select>
<select id="queryWithLogicDel" parameterType="map" resultType="com.xjrsoft.organization.entity.Department">
select *
FROM xjr_department
WHERE
<if test="params.ids != null and params.ids.length>0 ">
id in
<foreach item="item" collection="params.ids" index="i" open="(" separator="," close=")">
#{params.ids[${i}]}
</foreach>
</if>
</select>
</mapper>