You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
know_sub/know_sub_model/src/main/resources/mapper/KnowledgeMapper.xml

109 lines
5.0 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.supervision.knowsub.mapper.KnowledgeMapper">
<resultMap id="BaseResultMap" type="com.supervision.knowsub.model.Knowledge">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="excerpt" column="excerpt" jdbcType="VARCHAR"/>
<result property="contentId" column="content_id" jdbcType="VARCHAR"/>
<result property="infoId" column="info_id" jdbcType="VARCHAR"/>
<result property="baseId" column="base_id" jdbcType="VARCHAR"/>
<result property="publishDeptId" column="publish_dept_id" jdbcType="VARCHAR"/>
<result property="knowledgeFrom" column="knowledge_from" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="submitDeptId" column="submitted_dept" jdbcType="VARCHAR"/>
<result property="draftBelongUserId" column="draft_belong_user_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,title,excerpt,content_id,info_id,
base_id,publish_dept_id,knowledge_from,
status,submit_dept_id,create_user_id,
create_time,update_user_id,update_time
</sql>
<select id="queryKnowledgePage" resultType="com.supervision.knowsub.vo.knowledge.KnowledgePageResVO">
select
t1.*,
t1.create_time as submitDate,
t2.policy_type as policyType,
t2.timeliness as timeliness,
t2.publish_date as publishDate
from ks_knowledge t1 left join ks_knowledge_info t2 on t1.info_id = t2.id
<if test="status != null and status != 1">
left join (select distinct knowledge_id as submitKnowledgeId
from ks_knowledge_submit_record
where submit_user_id = #{userId}) t3
on t3.submitKnowledgeId = t1.id
</if>
where 1 = 1
<choose>
<when test="status == null">
-- 如果为空,是查全部通过的,不分人(驳回的删除和撤回,其实也属于正常上线的)
and ( status = 2 or status = 16 or status = 17 )
</when>
<when test="status == 1">
-- 如果是1,只查自己的草稿
and ( draft_belong_user_id = #{userId} and (status = 1 or status = 15))
</when>
<when test="status == 3">
-- 如果为3,则查16驳回(删除) 17驳回(撤回)
and ( status in (16,17) and t3.submitKnowledgeId is not null)
</when>
<when test="status == 9">
and ( status in (10,11,12) and t3.submitKnowledgeId is not null)
</when>
<otherwise>
and ( status = #{status} and t3.submitKnowledgeId is not null )
</otherwise>
</choose>
<if test="title != null and title != ''">
and title like concat('%',#{title},'%')
</if>
<if test="publishDeptId != null and publishDeptId != ''">
and publish_dept_id = #{publishDeptId}
</if>
<if test="baseId != null and baseId != ''">
and base_id = #{baseId}
</if>
<if test="submitDeptId != null and submitDeptId != ''">
and submit_dept_id = #{submitDeptId}
</if>
<if test="publishDateBegin != null ">
and t2.publish_date <![CDATA[ >= ]]> #{publishDateBegin}
</if>
<if test="publishDateEnd != null ">
and t2.publish_date <![CDATA[ <= ]]> #{publishDateEnd}
</if>
<if test="submitDateBegin != null ">
and t1.create_time <![CDATA[ >= ]]> #{submitDateBegin}
</if>
<if test="submitDateEnd != null ">
and t1.create_time <![CDATA[ <= ]]> #{submitDateEnd}
</if>
order by create_time desc
</select>
<select id="queryKnowledgeInvalidList" resultType="com.supervision.knowsub.dto.knowledge.CheckInvalidDTO">
select t1.id as knowledgeId,
t1.title as title,
t1.status as status,
t2.timeliness as timeliness,
t2.auto_lose_effect as autoLoseEffect,
t2.exec_time_begin as execTimeBegin,
t2.exec_time_end as execTimeEnd
from ks_knowledge t1
left join ks_knowledge_info t2 on t1.info_id = t2.id
where status = 2
and t2.timeliness = 2
and auto_lose_effect = 1
</select>
</mapper>