<?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.ruoyi.archives.mapper.ArchiveCategoryInfoMapper" >
<resultMap type= "ArchiveCategoryInfo" id= "ArchiveCategoryInfoResult" >
<result property= "id" column= "id" />
<result property= "parentId" column= "parent_id" />
<result property= "sort" column= "sort" />
<result property= "name" column= "name" />
<result property= "code" column= "code" />
<result property= "storageTime" column= "storage_time" />
<result property= "archiveDepartment" column= "archive_department" />
<result property= "isEnterhall" column= "is_enterhall" />
<result property= "remarks" column= "remarks" />
<result property= "delFlag" column= "del_flag" />
<result property= "createTime" column= "create_time" />
<result property= "createId" column= "create_id" />
<result property= "updateTime" column= "update_time" />
</resultMap>
<sql id= "selectArchiveCategoryInfoVo" >
select id, parent_id, sort, name, code, storage_time, archive_department, is_enterhall, remarks, del_flag, create_time,ancestors,create_id, update_time from "PUBLIC"."archive_category_info"
</sql>
<select id= "selectArchiveCategoryInfoList" parameterType= "ArchiveCategoryInfo" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
<where >
<if test= "parentId != null and parentId != ''" > and parent_id = #{parentId}</if>
<if test= "sort != null " > and sort = #{sort}</if>
<if test= "name != null and name != ''" > and name like concat('%', #{name}, '%')</if>
<if test= "code != null and code != ''" > and code = #{code}</if>
<if test= "storageTime != null and storageTime != ''" > and storage_time = #{storageTime}</if>
<if test= "archiveDepartment != null and archiveDepartment != ''" > and archive_department = #{archiveDepartment}</if>
<if test= "isEnterhall != null " > and is_enterhall = #{isEnterhall}</if>
<if test= "remarks != null and remarks != ''" > and remarks = #{remarks}</if>
<if test= "createId != null and createId != ''" > and create_id = #{createId}</if>
</where>
</select>
<select id= "selectArchiveCategoryInfoById" parameterType= "Long" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
where id = #{id}
</select>
<insert id= "insertArchiveCategoryInfo" parameterType= "ArchiveCategoryInfo" >
insert into "PUBLIC"."archive_category_info"
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "id != null" > id,</if>
<if test= "parentId != null" > parent_id,</if>
<if test= "sort != null" > sort,</if>
<if test= "name != null" > name,</if>
<if test= "code != null" > code,</if>
<if test= "storageTime != null" > storage_time,</if>
<if test= "archiveDepartment != null" > archive_department,</if>
<if test= "isEnterhall != null" > is_enterhall,</if>
<if test= "remarks != null" > remarks,</if>
<if test= "delFlag != null" > del_flag,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "ancestors!=null" > ancestors,</if>
<if test= "createId != null" > create_id,</if>
<if test= "updateTime != null" > update_time,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "id != null" > #{id},</if>
<if test= "parentId != null" > #{parentId},</if>
<if test= "sort != null" > #{sort},</if>
<if test= "name != null" > #{name},</if>
<if test= "code != null" > #{code},</if>
<if test= "storageTime != null" > #{storageTime},</if>
<if test= "archiveDepartment != null" > #{archiveDepartment},</if>
<if test= "isEnterhall != null" > #{isEnterhall},</if>
<if test= "remarks != null" > #{remarks},</if>
<if test= "delFlag != null" > #{delFlag},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "ancestors!=null" > #{ancestors},</if>
<if test= "createId != null" > #{createId},</if>
<if test= "updateTime != null" > #{updateTime},</if>
</trim>
</insert>
<update id= "updateArchiveCategoryInfo" parameterType= "ArchiveCategoryInfo" >
update "PUBLIC"."archive_category_info"
<trim prefix= "SET" suffixOverrides= "," >
<if test= "parentId != null" > parent_id = #{parentId},</if>
<if test= "sort != null" > sort = #{sort},</if>
<if test= "name != null" > name = #{name},</if>
<if test= "code != null" > code = #{code},</if>
<if test= "storageTime != null" > storage_time = #{storageTime},</if>
<if test= "archiveDepartment != null" > archive_department = #{archiveDepartment},</if>
<if test= "isEnterhall != null" > is_enterhall = #{isEnterhall},</if>
<if test= "remarks != null" > remarks = #{remarks},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "createId != null" > create_id = #{createId},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteArchiveCategoryInfoById" parameterType= "String" >
delete from "PUBLIC"."archive_category_info" where id = #{id}
</delete>
<delete id= "deleteArchiveCategoryInfoByIds" parameterType= "String" >
delete from "PUBLIC"."archive_category_info" where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<select id= "selectDeptList" parameterType= "ArchiveCategoryInfo" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
where del_flag = '0'
<if test= "parentId != null and parentId != 0" >
AND parent_id = #{parentId}
</if>
<if test= "name != null and name != ''" >
AND name like concat('%', #{name}, '%')
</if>
order by parent_id, sort
</select>
<select id= "listCategoryInfo" parameterType= "ArchiveCategoryInfo" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
where del_flag = '0' and parent_id = '1'
<if test= "name != null and name != ''" >
AND name like concat('%', #{name}, '%')
</if>
order by parent_id, sort
</select>
<select id= "getByCode" parameterType= "ArchiveCategoryInfo" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
where code=#{code} and del_flag='0' and parent_id='1'
</select>
<select id= "selectListBySon" parameterType= "Long" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
WHERE POSITION (#{id} IN ancestors) and del_flag = '0'
order by parent_id, sort
</select>
<select id= "selectByCode" parameterType= "string" resultMap= "ArchiveCategoryInfoResult" >
<include refid= "selectArchiveCategoryInfoVo" />
WHERE POSITION((SELECT id FROM "PUBLIC"."archive_category_info" WHERE CODE=#{code1}) IN ancestors) AND del_flag = '0' AND CODE=#{code2}
</select>
<select id= "selectYearGroupByCategory" resultType= "com.ruoyi.archives.domain.ArchiveRecordInfo" >
SELECT DISTINCT archive_category as archiveCategory,YEAR FROM "PUBLIC"."archive_record_info" GROUP BY archive_category,YEAR ORDER BY archive_category,YEAR
</select>
<select id= "selectFileNumGroupByCategory" resultType= "com.ruoyi.archives.domain.ArchiveRecordInfo" >
SELECT ARCHIVE_CATEGORY as archiveCategory,file_num as fileNum
FROM (
SELECT
ARCHIVE_CATEGORY,
SPLIT_PART(file_num, '-', #{index}) AS file_num
from
"PUBLIC"."archive_record_info"
where
"PUBLIC"."archive_record_info"."ARCHIVE_CATEGORY" = #{recordCategory}
)RESULT
GROUP BY RESULT.ARCHIVE_CATEGORY,RESULT.file_num
ORDER BY RESULT.file_num
</select>
</mapper>