<?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">
|
<!--
|
* @title: 法律原始文本表
|
* @description: 自定义sql,请自行实现业务逻辑
|
* @company: hugeinfo
|
* @author: huangh
|
* @time:2024-12-13 10:52:00
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.knowledge.dao.mapper.LawOriginalInfoMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.knowledge.domain.po.LawOriginalInfo">
|
<result property="lawOriginalInfoId" column="law_original_info_id"/>
|
<result property="title" column="title"/>
|
<result property="authority" column="authority"/>
|
<result property="authorityName" column="authority_name"/>
|
<result property="lawNature" column="law_nature"/>
|
<result property="lawNatureName" column="law_nature_name"/>
|
<result property="validity" column="validity"/>
|
<result property="validityName" column="validity_name"/>
|
<result property="publishTime" column="publish_time"/>
|
<result property="implementationTime" column="implementation_time"/>
|
<result property="provisionText" column="provision_text"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="note" column="note"/>
|
<result property="deleteStatus" column="delete_status"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>law_original_info</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
law_original_info_id,title,authority,authority_name,law_nature,law_nature_name,validity,validity_name,publish_time,implementation_time,provision_text,create_time,update_time,note,delete_status
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.title != null">title = #{entity.title},</if>
|
<if test="entity.authority != null">authority = #{entity.authority},</if>
|
<if test="entity.authorityName != null">authority_name = #{entity.authorityName},</if>
|
<if test="entity.lawNature != null">law_nature = #{entity.lawNature},</if>
|
<if test="entity.lawNatureName != null">law_nature_name = #{entity.lawNatureName},</if>
|
<if test="entity.validity != null">validity = #{entity.validity},</if>
|
<if test="entity.validityName != null">validity_name = #{entity.validityName},</if>
|
<if test="entity.publishTime != null">publish_time = #{entity.publishTime},</if>
|
<if test="entity.implementationTime != null">implementation_time = #{entity.implementationTime},</if>
|
<if test="entity.provisionText != null">provision_text = #{entity.provisionText},</if>
|
<if test="entity.note != null">note = #{entity.note},</if>
|
<if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus}</if>
|
</sql>
|
<!-- 条件 -->
|
<sql id="where-part">
|
<if test="terms != null">
|
<where>
|
<if test="terms.title != null and terms.title !=''">
|
and title = #{terms.title}
|
</if>
|
<if test="terms.authority != null and terms.authority !=''">
|
and authority = #{terms.authority}
|
</if>
|
<if test="terms.authorityName != null and terms.authorityName !=''">
|
and authority_name = #{terms.authorityName}
|
</if>
|
<if test="terms.lawNature != null and terms.lawNature !=''">
|
and law_nature = #{terms.lawNature}
|
</if>
|
<if test="terms.lawNatureName != null and terms.lawNatureName !=''">
|
and law_nature_name = #{terms.lawNatureName}
|
</if>
|
<if test="terms.validity != null and terms.validity !=''">
|
and validity = #{terms.validity}
|
</if>
|
<if test="terms.validityName != null and terms.validityName !=''">
|
and validity_name = #{terms.validityName}
|
</if>
|
<if test="terms.createTime != null and terms.createTime !=''">
|
and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
|
</if>
|
<if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
|
and (DATE_FORMAT(create_time,'%Y-%m-%d') >= #{terms.createStart}
|
and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{terms.createEnd})
|
</if>
|
<if test="terms.updateTime != null and terms.updateTime !=''">
|
and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
|
</if>
|
<if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
|
and (DATE_FORMAT(update_time,'%Y-%m-%d') >= #{terms.updateStart}
|
and DATE_FORMAT(update_time,'%Y-%m-%d') <= #{terms.updateEnd})
|
</if>
|
<if test="terms.deleteStatus == null or terms.deleteStatus ==''">
|
and delete_status = '1'
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.keywordTitle != null and terms.keywordTitle !=''">
|
and title like concat('%',#{keywordTitle},'%')
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 更新对象 -->
|
<update id="updateLawOriginalInfo">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
law_original_info_id = #{entity.lawOriginalInfoId}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateLawOriginalInfoTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteLawOriginalInfo">
|
delete from
|
<include refid="table-name" />
|
where law_original_info_id = #{id}
|
</delete>
|
<!-- 根据条件查询 -->
|
<select id="listTerms" resultMap="dataResult">
|
select
|
<include refid="column-part"/>
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
|
|
<!-- 结果集 -->
|
<resultMap id="lawCpwsDTOResult" type="cn.huge.module.knowledge.domain.dto.LawCpwsDTO">
|
<result property="lawOriginalInfoId" column="law_original_info_id"/>
|
</resultMap>
|
<!-- 字段 -->
|
<sql id="column-part-lawCpwsDTO">
|
law_original_info_id
|
</sql>
|
<!-- 辅助裁判文书法律依据-根据法律名称查询具体法律信息 -->
|
<select id="getLawByTitle" resultMap="lawCpwsDTOResult">
|
select
|
<include refid="column-part-lawCpwsDTO"/>
|
from
|
<include refid="table-name" />
|
where title = #{terms.title}
|
<!-- <include refid="where-part"/>-->
|
<!-- and validity ='1'-->
|
ORDER BY publish_time DESC
|
limit 1
|
</select>
|
<!-- 根据条件统计 -->
|
<select id="countTerms" resultType="java.lang.Long">
|
select
|
COUNT(1)
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件分页查询 -->
|
<select id="pageTerms" resultMap="dataResult">
|
SELECT
|
<include refid="column-part"/>
|
FROM
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
isnull(${s.property}), ${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by isnull(create_time), create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
</mapper>
|