123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <?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="cn.cslg.pas.mapper.ScratchWordsMapper">
- <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
- <select id="querySW" resultMap="querySWResultMap">
- select * from scratch_words
- <where>
- patent_no = #{patentNo}
- and(
- <if test="projectId != null and reportId != null and createId != null and tenantId != null">
- -- 所有地方可见/公开
- (range_type = "false" and permission_type = 1 and tenant_id = #{tenantId})
- -- 所有地方可见/私有
- or(range_type = "false" and permission_type = 0 and create_id = #{createId})
- -- 只在来源出可见/公开
- or(range_type = "true" and create_from = 2 and range_id = #{reportId} and permission_type = 1 and
- tenant_id = #{tenantId})
- or(range_type = "true" and create_from = 1 and range_id = #{projectId} and permission_type = 1 and
- tenant_id = #{tenantId})
- or(create_from = 0 and permission_type = 1 and tenant_id = #{tenantId})
- -- 只在来源出可见/私有
- or(range_type = "true" and create_from = 2 and range_id = #{reportId} and permission_type = 0 and
- create_id = #{createId})
- or(range_type = "true" and create_from = 1 and range_id = #{projectId} and permission_type = 0 and
- create_id = #{createId})
- or(create_from = 0 and permission_type = 0 and create_id = #{createId})
- </if>
- )
- </where>
- </select>
- <resultMap id="querySWResultMap" type="cn.cslg.pas.common.model.vo.ScratchWordsVO">
- <id column="id" property="id"/>
- <result column="create_id" property="createId"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="patent_no" property="patentNo"/>
- <result column="position" property="position"/>
- <result column="text" property="text"/>
- <result column="scratch_field" property="scratchField"/>
- <result column="scratch_type" property="scratchType"/>
- <result column="color" property="color"/>
- <result column="remark" property="remark"/>
- <result column="create_from" property="createFrom"/>
- <result column="range_id" property="rangeId"/>
- <result column="permission_type" property="permissionType"/>
- <result column="range_type" property="rangeType"/>
- </resultMap>
- <select id="selectByConditions" resultMap="querySWResultMap">
- SELECT id, create_id, tenant_id, patent_no, create_from, range_id, permission_type, range_type
- FROM scratch_words
- WHERE patent_no = #{patentNo}
- <!-- 如果公开范围为 F,公开类型为 1,公司名为 tenantId,则拼接该条件 -->
- <if test="rangeType == 'F' and permissionType == 1 and tenantId != null">
- AND range_type = 'F' AND permission_type = 1 AND tenant_id = #{tenantId}
- </if>
- <!-- 如果公开范围为 F,公开类型为 0,创建人为 createId,则拼接该条件 -->
- <if test="rangeType == 'F' and permissionType == 0 and createId != null">
- AND range_type = 'F' AND permission_type = 0 AND create_id = #{createId}
- </if>
- <!-- 如果公开范围为 T,创建来源为 2,抽象id为 reportId,公开类型为 1,公司名为 tenantId,则拼接该条件 -->
- <if test="rangeType == 'T' and createFrom == 2 and rangeId == 'reportId' and permissionType == 1 and tenantId != null">
- AND range_type = 'T' AND create_from = 2 AND range_id = 'reportId' AND permission_type = 1 AND tenant_id =
- #{tenantId}
- </if>
- <!-- 如果公开范围为 T,创建来源为 2,抽象id为 reportId,公开类型为 0,创建人为 createId,则拼接该条件 -->
- <if test="rangeType == 'T' and createFrom == 2 and rangeId == 'reportId' and permissionType == 0 and createId != null">
- AND range_type = 'T' AND create_from = 2 AND range_id = 'reportId' AND permission_type = 0 AND create_id =
- #{createId}
- </if>
- </select>
- <select id="queryScratchWords" resultMap="queryScratchWordsResultMap">
- select * from scratch_words
- <where>
- <if test="true">
- 1 = 1
- and(
- -- 所有地方可见/公开
- (range_type = "false" and permission_type = 1 and tenant_id = #{tenantId})
- -- 所有地方可见/私有
- or(range_type = "false" and permission_type = 0 and create_id = #{personId})
- -- 只在来源出可见/公开
- or(range_type = "true" and create_from = 2 and range_id in (
- <foreach collection="reportIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 1 and
- tenant_id = #{tenantId})
- or(range_type = "true" and create_from = 1 and range_id in (
- <foreach collection="projectIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 1 and
- tenant_id = #{tenantId})
- or(create_from = 0 and permission_type = 1 and tenant_id = #{tenantId})
- -- 只在来源出可见/私有
- or(range_type = "true" and create_from = 2 and range_id in (
- <foreach collection="reportIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 0 and
- create_id = #{personId})
- or(range_type = "true" and create_from = 1 and range_id in (
- <foreach collection="projectIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 0 and
- create_id = #{personId})
- or(create_from = 0 and permission_type = 0 and create_id = #{personId})
- )
- </if>
- <if test="search != null and search.size > 0">
- <foreach collection="search" item="searchItem">
- <if test="searchItem.value == 'remark'">
- and remark like '%${searchItem.content}%'
- </if>
- <if test="searchItem.value == 'patentNo'">
- and patent_no like '%${searchItem.content}%'
- </if>
- <if test="searchItem.value == 'date'">
- and create_time like '%${searchItem.content}%'
- </if>
- </foreach>
- </if>
- <if test="createIds != null and createIds.size > 0">
- and create_id in (
- <foreach collection="createIds" item="createId" separator=",">
- #{createId}
- </foreach>
- )
- </if>
- </where>
- order by create_time desc
- </select>
- <resultMap id="queryScratchWordsResultMap" type="cn.cslg.pas.common.model.vo.ScratchWordVO">
- <id column="id" property="id"/>
- <result column="create_id" property="createId"/>
- <result column="remark" property="remark"/>
- <result column="patent_no" property="patentNo"/>
- <result column="name" property="name"/>
- <result column="create_time" property="date"/>
- <result column="scratch_field" property="scratchField"/>
- <result column="text" property="text"/>
- <result column="color" property="color"/>
- <result column="scratch_type" property="scratchType"/>
- <result column="create_from" property="createFrom"/>
- <result column="range_id" property="rangeId"/>
- <result column="permission_type" property="permissionType"/>
- <result column="range_type" property="rangeType"/>
- </resultMap>
- <select id="queryGroupScratchs" resultMap="queryGroupScratchsResultMap">
- select create_id,
- patent_no,
- DATE_FORMAT(create_time, '%Y-%m-%d') as YmD
- from scratch_words
- <where>
- <if test="true">
- 1 = 1
- and(
- -- 所有地方可见/公开
- (range_type = "false" and permission_type = 1 and tenant_id = #{tenantId})
- -- 所有地方可见/私有
- or(range_type = "false" and permission_type = 0 and create_id = #{personId})
- -- 只在来源出可见/公开
- or(range_type = "true" and create_from = 2 and range_id in (
- <foreach collection="reportIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 1 and
- tenant_id = #{tenantId})
- or(range_type = "true" and create_from = 1 and range_id in (
- <foreach collection="projectIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 1 and
- tenant_id = #{tenantId})
- or(create_from = 0 and permission_type = 1 and tenant_id = #{tenantId})
- -- 只在来源出可见/私有
- or(range_type = "true" and create_from = 2 and range_id in (
- <foreach collection="reportIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 0 and
- create_id = #{personId})
- or(range_type = "true" and create_from = 1 and range_id in (
- <foreach collection="projectIds" item="n" separator=",">
- #{n}
- </foreach>)
- and permission_type = 0 and
- create_id = #{personId})
- or(create_from = 0 and permission_type = 0 and create_id = #{personId})
- )
- </if>
- <if test="search != null and search.size > 0">
- <foreach collection="search" item="searchItem">
- <if test="searchItem.value == 'remark'">
- and remark like '%${searchItem.content}%'
- </if>
- <if test="searchItem.value == 'patentNo'">
- and patent_no like '%${searchItem.content}%'
- </if>
- <if test="searchItem.value == 'date'">
- and create_time like '%${searchItem.content}%'
- </if>
- </foreach>
- </if>
- <if test="createIds != null and createIds.size > 0">
- and create_id in (
- <foreach collection="createIds" item="createId" separator=",">
- #{createId}
- </foreach>
- )
- </if>
- </where>
- group by
- <if test="grouping != null and grouping == 'name'">
- create_id
- </if>
- <if test="grouping != null and grouping == 'patentNo'">
- patent_no
- </if>
- <if test="grouping != null and grouping == 'date'">
- YmD
- </if>
- order by create_time desc
- </select>
- <resultMap id="queryGroupScratchsResultMap" type="cn.cslg.pas.domain.GroupName">
- <result column="create_id" property="createId"/>
- <result column="patent_no" property="patentNo"/>
- <result column="YmD" property="date"/>
- </resultMap>
- </mapper>
|