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

80 lines
3.7 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"/>
12 months ago
<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="submittedDeptId" 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
12 months ago
,title,excerpt,content_id,info_id,
base_id,publish_dept_id,knowledge_from,
status,submitted_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.*
from ks_knowledge t1 left join ks_knowledge_info t2 on t1.info_id = t2.id
12 months ago
<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>
12 months ago
where 1 = 1
<choose>
<when test="status == null">
-- 如果为空,是查全部通过的,不分人
12 months ago
and ( status = 2)
</when>
<when test="status == 1">
-- 如果是1,只查自己的草稿
and ( draft_belong_user_id = #{userId} and status = 1)
</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="submittedDeptId != null and submittedDeptId != ''">
and submitted_dept_id = #{submittedDeptId}
</if>
<if test="publishDateBegin != null and publishDateBegin != ''">
and create_time <![CDATA[ >= ]]> #{publishDateBegin}
</if>
<if test="publishDateEnd != null and publishDateEnd != ''">
and create_time <![CDATA[ <= ]]> #{publishDateEnd}
</if>
12 months ago
order by create_time desc
</select>
</mapper>