172 lines
3.9 KiB
XML
172 lines
3.9 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.hx.slj.modules.sys.dao.PolicyDao">
|
|
|
|
<sql id="policyColumns">
|
|
a.id AS "id",
|
|
a.title AS "title",
|
|
a.issuer AS "issuer",
|
|
a.issue_date AS "issueDate",
|
|
a.type AS "type",
|
|
a.content AS "content",
|
|
a.create_by AS "createBy.id",
|
|
a.create_date AS "createDate",
|
|
a.update_by AS "updateBy.id",
|
|
a.update_date AS "updateDate",
|
|
a.remarks AS "remarks",
|
|
a.del_flag AS "delFlag",
|
|
a.files AS "files"
|
|
</sql>
|
|
|
|
<sql id="policyJoins">
|
|
</sql>
|
|
<resultMap type="java.util.Map" id="conResultMap" >
|
|
<result property="content" column="content" jdbcType="BLOB" typeHandler="org.apache.ibatis.type.BlobTypeHandler"/>
|
|
</resultMap>
|
|
|
|
<select id="findContent" parameterType="string" resultMap="conResultMap" >
|
|
SELECT a.content FROM sys_policy a WHERE a.id = #{id}
|
|
</select>
|
|
|
|
|
|
<select id="findPolicyByType" resultType="Policy">
|
|
select
|
|
*
|
|
from
|
|
sys_policy a
|
|
where
|
|
a.`TYPE` = #{type}
|
|
AND
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
order by
|
|
a.ISSUE_DATE desc
|
|
limit 0,1
|
|
|
|
</select>
|
|
|
|
<select id="get" resultType="Policy" >
|
|
SELECT
|
|
<include refid="policyColumns"/>
|
|
FROM sys_policy a
|
|
<include refid="policyJoins"/>
|
|
WHERE a.id = #{id}
|
|
</select>
|
|
|
|
<select id="findList" resultType="Policy" >
|
|
SELECT
|
|
<include refid="policyColumns"/>
|
|
FROM sys_policy a
|
|
<include refid="policyJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
<if test="title != null and title != ''">
|
|
AND a.title LIKE
|
|
<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
|
|
<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
|
|
<if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
|
|
</if>
|
|
<if test="issuer != null and issuer != ''">
|
|
AND a.issuer = #{issuer}
|
|
</if>
|
|
<if test="issueDate != null and issueDate != ''">
|
|
AND a.issue_date = #{issueDate}
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
AND a.type = #{type}
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.update_date DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="findAllList" resultType="Policy" >
|
|
SELECT
|
|
<include refid="policyColumns"/>
|
|
FROM sys_policy a
|
|
<include refid="policyJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.update_date DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<insert id="insert">
|
|
INSERT INTO sys_policy(
|
|
id,
|
|
title,
|
|
issuer,
|
|
issue_date,
|
|
type,
|
|
content,
|
|
create_by,
|
|
create_date,
|
|
update_by,
|
|
update_date,
|
|
remarks,
|
|
del_flag,
|
|
files
|
|
) VALUES (
|
|
#{id},
|
|
#{title},
|
|
#{issuer},
|
|
#{issueDate},
|
|
#{type},
|
|
#{content,typeHandler=org.apache.ibatis.type.BlobTypeHandler},
|
|
#{createBy.id},
|
|
#{createDate},
|
|
#{updateBy.id},
|
|
#{updateDate},
|
|
#{remarks},
|
|
#{delFlag},
|
|
#{files}
|
|
)
|
|
</insert>
|
|
|
|
<update id="update">
|
|
UPDATE sys_policy SET
|
|
title = #{title},
|
|
issuer = #{issuer},
|
|
issue_date = #{issueDate},
|
|
type = #{type},
|
|
content = #{content},
|
|
update_by = #{updateBy.id},
|
|
update_date = #{updateDate},
|
|
remarks = #{remarks},
|
|
files = #{files}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
|
|
<!--物理删除-->
|
|
<update id="delete">
|
|
DELETE FROM sys_policy
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!--逻辑删除-->
|
|
<update id="deleteByLogic">
|
|
UPDATE sys_policy SET
|
|
del_flag = #{DEL_FLAG_DELETE}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
|
|
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
|
|
<select id="findUniqueByProperty" resultType="Policy" statementType="STATEMENT">
|
|
select * FROM sys_policy where ${propertyName} = '${value}'
|
|
</select>
|
|
|
|
</mapper> |