ZhiYeJianKang/职业健康平台后端/bin/mappings/modules/sys/CatalogDao.xml
2025-02-20 15:25:59 +08:00

287 lines
6.9 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.hx.slj.modules.sys.dao.CatalogDao">
<sql id="catalogColumns">
a.id,
a.parent_id AS "parent.id",
a.parent_ids,
a.name,
a.sort,
a.FILE_TYPE,
a.ACTION_TYPE,
a.UPLOAD_ID,
a.UPLOAD_SEQ,
a.END_DATE,
a.FILE_COUNT,
a.CATEGORY,
a.up_role_EnName,
a.check_role_EnName,
a.IS_ARCHIVE,
a.IS_DISP,
a.USE_SEQ,
a.ARCHIVE_ID,
a.remarks,
a.create_by AS "createBy.id",
a.create_date,
a.update_by AS "updateBy.id",
a.update_date,
a.del_flag,
p.name AS "parent.name"
</sql>
<sql id="catalogJoins">
LEFT JOIN devtree_simp p ON p.id = a.parent_id
</sql>
<select id="get" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.id = #{id}
</select>
<select id="getMaxUploadseq" resultType="Catalog">
SELECT
max(a.UPLOAD_SEQ) as 'uploadSeq',
a.FILE_TYPE,
a.ACTION_TYPE
FROM devtree_simp a
WHERE
a.FILE_TYPE = #{fileType}
and a.ACTION_TYPE = #{actionType}
GROUP BY
a.FILE_TYPE,
a.ACTION_TYPE
</select>
<!-- <select id="getByCode" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.code = #{code}
</select> -->
<select id="findList" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
<!-- 数据范围过滤 -->
${sqlMap.dsf}
OR a.id = #{currentUser.catalog.id}
ORDER BY a.FILE_TYPE,
a.ACTION_TYPE, a.sort
</select>
<select id="findAllList" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
ORDER BY a.FILE_TYPE,
a.ACTION_TYPE, a.sort
</select>
<select id="findNextListByid" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.id=#{id} AND a.del_flag =0
OR a.parent_ids LIKE CONCAT('%', #{id}, '%')
ORDER BY a.FILE_TYPE,
a.ACTION_TYPE, a.sort
</select>
<select id="findByParentIdsLike" resultType="Catalog">
SELECT
<include refid="catalogColumns"/>
FROM devtree_simp a
<include refid="catalogJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL} AND a.parent_ids LIKE #{parentIds}
ORDER BY a.FILE_TYPE,
a.ACTION_TYPE, a.sort
</select>
<insert id="insert">
INSERT INTO devtree_simp(
id,
parent_id,
parent_ids,
name,
sort,
FILE_TYPE,
ACTION_TYPE,
UPLOAD_ID,
UPLOAD_SEQ,
END_DATE,
FILE_COUNT,
CATEGORY,
up_role_EnName,
check_role_EnName,
IS_ARCHIVE,
IS_DISP,
USE_SEQ,
ARCHIVE_ID,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{parent.id},
#{parentIds},
#{name},
#{sort},
#{fileType},
#{actionType},
#{uploadId},
#{uploadSeq},
#{endDate},
#{fileCount},
#{category},
#{upRoleEnName},
#{checkRoleEnName},
#{isArchive},
#{isDisp},
#{useSeq},
#{archiveId},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE devtree_simp SET
parent_id = #{parent.id},
parent_ids = #{parentIds},
name = #{name},
sort = #{sort},
FILE_TYPE = #{fileType},
ACTION_TYPE = #{actionType},
UPLOAD_ID = #{uploadId},
UPLOAD_SEQ = #{uploadSeq},
END_DATE = #{endDate},
FILE_COUNT = #{fileCount},
CATEGORY = #{category},
up_role_EnName = #{upRoleEnName},
check_role_EnName = #{checkRoleEnName},
IS_ARCHIVE = #{isArchive},
IS_DISP = #{isDisp},
USE_SEQ = #{useSeq},
ARCHIVE_ID = #{archiveId},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<update id="updateParentIds">
UPDATE devtree_simp SET
parent_id = #{parent.id},
parent_ids = #{parentIds}
WHERE id = #{id}
</update>
<update id="delete">
DELETE FROM devtree_simp
WHERE id = #{id} OR parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{id}||',%'</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
</update>
<update id="deleteByLogic">
UPDATE devtree_simp SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id} OR parent_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{id}||',%'</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
</update>
<resultMap id="roleResult" type="Role">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="enname" column="enname" />
<result property="roleType" column="roleType" />
<result property="dataScope" column="dataScope" />
<result property="remarks" column="remarks" />
<result property="useable" column="useable" />
<result property="office.name" column="office.name" />
<result property="sysData" column="sysData" />
<collection property="menuList" ofType="Menu">
<id property="id" column="menuList.id" />
</collection>
<collection property="officeList" ofType="Office">
<id property="id" column="officeList.id" />
</collection>
</resultMap>
<sql id="roleColumns">
a.id,
a.office_id AS "office.id",
a.name,
a.enname,
a.role_type AS roleType,
a.data_scope AS dataScope,
a.remarks,
a.create_by AS "createBy.id",
<!-- a.create_date, -->
a.update_by AS "updateBy.id",
<!-- a.update_date, -->
a.del_flag,
o.name AS "office.name",
o.code "office.code",
o.code AS "code",
a.useable AS useable,
a.is_sys AS sysData
</sql>
<select id="findPageByEnname" resultMap="roleResult">
SELECT <!-- DISTINCT -->
<include refid="roleColumns"/>,
ro.office_id AS "officeList.id"
FROM sys_role a
LEFT JOIN sys_office o ON o.id = a.office_id
LEFT JOIN sys_user_role ur ON ur.role_id = a.id
LEFT JOIN sys_user u ON u.id = ur.user_id
LEFT JOIN sys_role_office ro ON ro.role_id = a.id
WHERE a.del_flag = #{DEL_FLAG_NORMAL} AND a.useable=#{useable}
<if test="user != null and user.id != null and user.id != ''">
AND u.id = #{user.id}
</if>
<if test="user != null and user.loginName != null and user.loginName != ''">
AND u.login_name = #{user.loginName}
</if>
<if test="name != null and name != ''">
AND a.name like
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{name}, '%')</if>
</if>
<if test="enname != null and enname != ''">
AND a.enname like
<if test="dbName == 'oracle'">'%'||#{enname}||'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{enname}, '%')</if>
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
ORDER BY o.code, a.name
</select>
</mapper>