WholeProcessPlatform/backend/src/main/resources/mapper/data/SysUserDataScopeMapper.xml
2026-05-06 15:44:26 +08:00

76 lines
2.8 KiB
XML

<?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.yfd.platform.data.mapper.SysUserDataScopeMapper">
<resultMap id="BaseResultMap" type="com.yfd.platform.data.domain.SysUserDataScope">
<id column="ID" property="id"/>
<result column="USER_ID" property="userId"/>
<result column="ORG_TYPE" property="orgType"/>
<result column="ORG_ID" property="orgId"/>
<result column="PARENT_ID" property="parentId"/>
<result column="ORG_LEVEL" property="orgLevel"/>
<result column="PATH" property="path"/>
<result column="PERMISSION_TYPE" property="permissionType"/>
<result column="ROLE_CODE" property="roleCode"/>
<result column="DATA_SCOPE" property="dataScope"/>
<result column="STATUS" property="status"/>
<result column="START_TIME" property="startTime"/>
<result column="END_TIME" property="endTime"/>
<result column="CREATED_AT" property="createdAt"/>
<result column="CREATED_BY" property="createdBy"/>
<result column="UPDATED_AT" property="updatedAt"/>
<result column="UPDATED_BY" property="updatedBy"/>
<result column="REMARK" property="remark"/>
</resultMap>
<select id="selectPageList" resultMap="BaseResultMap">
SELECT * FROM SYS_USER_DATA_SCOPE
WHERE 1=1
<if test="userId != null">
AND USER_ID = #{userId}
</if>
<if test="orgType != null and orgType != ''">
AND ORG_TYPE = #{orgType}
</if>
<if test="orgId != null and orgId != ''">
AND ORG_ID = #{orgId}
</if>
<if test="status != null">
AND STATUS = #{status}
</if>
ORDER BY CREATED_AT DESC
</select>
<select id="selectByUserId" resultMap="BaseResultMap">
SELECT * FROM SYS_USER_DATA_SCOPE
WHERE USER_ID = #{userId}
ORDER BY CREATED_AT DESC
</select>
<select id="selectByOrg" resultMap="BaseResultMap">
SELECT * FROM SYS_USER_DATA_SCOPE
WHERE ORG_TYPE = #{orgType}
AND ORG_ID = #{orgId}
ORDER BY CREATED_AT DESC
</select>
<delete id="batchDelete">
DELETE FROM SYS_USER_DATA_SCOPE
WHERE ID IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectValidPermissions" resultMap="BaseResultMap">
SELECT * FROM SYS_USER_DATA_SCOPE
WHERE USER_ID = #{userId}
AND STATUS = 1
-- AND (START_TIME IS NULL OR START_TIME &lt;= SYSDATE)
-- AND (END_TIME IS NULL OR END_TIME &gt;= SYSDATE)
ORDER BY CREATED_AT DESC
</select>
</mapper>