twoduty/src/main/resources/mybatis/mapper/indexGeneral/indexGeneral-mapper.xml
2021-04-16 14:59:42 +08:00

365 lines
13 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.tenlion.twoduty.dao.indexgeneral.IIndexGeneralDao">
<resultMap id="indexGeneralDTO" type="com.tenlion.twoduty.pojo.dtos.indexgeneral.IndexGeneralDTO">
<result column="index_general_id" property="indexGeneralId"/>
<result column="duty_index_lib_id" property="dutyIndexLibId"/>
<result column="duty_index_lib_name" property="dutyIndexLibName"/>
<result column="index_general_title" property="indexGeneralTitle"/>
<result column="index_general_content" property="indexGeneralContent"/>
<result column="index_general_file" property="indexGeneralFile"/>
<result column="index_general_image" property="indexGeneralImage"/>
<result column="audit_status" property="auditStatus"/>
<result column="creator_name" property="creatorName"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<resultMap id="indexGeneralBO" type="com.tenlion.twoduty.pojo.bos.indexgeneral.IndexGeneralBO">
<result column="index_general_id" property="indexGeneralId"/>
<result column="duty_index_lib_id" property="dutyIndexLibId"/>
<result column="index_general_title" property="indexGeneralTitle"/>
<result column="index_general_content" property="indexGeneralContent"/>
<result column="index_general_file" property="indexGeneralFile"/>
<result column="index_general_image" property="indexGeneralImage"/>
<result column="audit_status" property="auditStatus"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="modifier" property="modifier"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="indexGeneralPO" type="com.tenlion.twoduty.pojo.pos.indexgeneral.IndexGeneralPO">
<result column="index_general_id" property="indexGeneralId"/>
<result column="duty_index_lib_id" property="dutyIndexLibId"/>
<result column="index_general_title" property="indexGeneralTitle"/>
<result column="index_general_content" property="indexGeneralContent"/>
<result column="index_general_file" property="indexGeneralFile"/>
<result column="index_general_image" property="indexGeneralImage"/>
<result column="audit_status" property="auditStatus"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="modifier" property="modifier"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增 -->
<insert id="save" parameterType="map">
INSERT INTO duty_index_general(
index_general_id,
duty_index_lib_id,
index_general_title,
index_general_content,
index_general_file,
index_general_image,
audit_status,
gmt_create,
creator,
gmt_modified,
modifier,
is_delete
) VALUES(
#{indexGeneralId},
#{dutyIndexLibId},
#{indexGeneralTitle},
#{indexGeneralContent},
#{indexGeneralFile},
#{indexGeneralImage},
#{auditStatus},
#{gmtCreate},
#{creator},
#{gmtModified},
#{modifier},
#{isDelete}
)
</insert>
<!-- 删除 -->
<update id="remove" parameterType="map">
UPDATE
duty_index_general
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
index_general_id IN
<foreach collection="indexGeneralIds" index="index" open="(" separator="," close=")">
#{indexGeneralIds[${index}]}
</foreach>
</update>
<!-- 删除(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
duty_index_general
WHERE
index_general_id IN
<foreach collection="indexGeneralIds" index="index" open="(" separator="," close=")">
#{indexGeneralIds[${index}]}
</foreach>
</update>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE
duty_index_general
SET
<if test="indexGeneralTitle != null and indexGeneralTitle != ''">
index_general_title = #{indexGeneralTitle},
</if>
<if test="indexGeneralContent != null and indexGeneralContent != ''">
index_general_content = #{indexGeneralContent},
</if>
<if test="indexGeneralFile != null and indexGeneralFile != ''">
index_general_file = #{indexGeneralFile},
</if>
<if test="indexGeneralImage != null and indexGeneralImage != ''">
index_general_image = #{indexGeneralImage},
</if>
<if test="auditStatus != null and auditStatus != ''">
audit_status = #{auditStatus},
</if>
<if test="gmtModified != null and gmtModified != ''">
gmt_modified = #{gmtModified},
</if>
<if test="modifier != null and modifier != ''">
modifier = #{modifier}
</if>
WHERE
index_general_id = #{indexGeneralId}
</update>
<!-- 详情 -->
<select id="get" parameterType="map" resultMap="indexGeneralDTO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.index_general_id,
t1.gmt_create,
t1.creator,
t2.index_lib_name duty_index_lib_name
FROM
duty_index_general t1
LEFT JOIN duty_index_lib t2
ON t1.duty_index_lib_id = t2.index_lib_id
WHERE
t1.is_delete = 0
<if test="indexGeneralId != null and indexGeneralId != ''">
AND
t1.index_general_id = #{indexGeneralId}
</if>
</select>
<!-- 详情 -->
<select id="getBO" parameterType="map" resultMap="indexGeneralBO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
duty_index_general t1
WHERE
t1.is_delete = 0
<if test="indexGeneralId != null and indexGeneralId != ''">
AND
t1.index_general_id = #{indexGeneralId}
</if>
</select>
<!-- 详情 -->
<select id="getPO" parameterType="map" resultMap="indexGeneralPO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
duty_index_general t1
WHERE
t1.is_delete = 0
<if test="indexGeneralId != null and indexGeneralId != ''">
AND
t1.index_general_id = #{indexGeneralId}
</if>
</select>
<!-- 列表 -->
<select id="list" parameterType="map" resultMap="indexGeneralDTO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.gmt_create,
t1.creator,
t2.index_lib_name duty_index_lib_name
FROM
duty_index_general t1
LEFT JOIN duty_index_lib t2
ON t1.duty_index_lib_id = t2.index_lib_id
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.index_general_title LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="indexGeneralIds != null and indexGeneralIds.size > 0">
AND
t1.index_general_id IN
<foreach collection="indexGeneralIds" index="index" open="(" separator="," close=")">
#{indexGeneralIds[${index}]}
</foreach>
</if>
<if test="indexLibId != null and indexLibId != ''">
AND t1.duty_index_lib_id = #{indexLibId}
</if>
<if test="auditStatus != null and auditStatus != ''">
AND t1.audit_status = #{auditStatus}
</if>
<if test="creator != '1'.toString()">
AND t1.creator = #{creator}
</if>
<!--<if test="data_authority != null and data_authority == 'self'">-->
<!--AND t1.creator = #{data_creator}-->
<!--</if>-->
<!--<if test="data_authority != null and (data_authority == 'department' or data_authority == 'custom')">-->
<!--AND t1.creator IN-->
<!--<foreach collection="data_creators" index="index" open="(" separator="," close=")">-->
<!--#{data_creators[${index}]}-->
<!--</foreach>-->
<!--</if>-->
ORDER BY t1.gmt_create DESC
</select>
<!-- 列表 -->
<select id="listBO" parameterType="map" resultMap="indexGeneralBO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
duty_index_general t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="indexGeneralIds != null and indexGeneralIds.size > 0">
AND
t1.index_general_id IN
<foreach collection="indexGeneralIds" index="index" open="(" separator="," close=")">
#{indexGeneralIds[${index}]}
</foreach>
</if>
</select>
<!-- 列表 -->
<select id="listPO" parameterType="map" resultMap="indexGeneralPO">
SELECT
t1.index_general_id,
t1.duty_index_lib_id,
t1.index_general_title,
t1.index_general_content,
t1.index_general_file,
t1.index_general_image,
t1.audit_status,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
duty_index_general t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="indexGeneralIds != null and indexGeneralIds.size > 0">
AND
t1.index_general_id IN
<foreach collection="indexGeneralIds" index="index" open="(" separator="," close=")">
#{indexGeneralIds[${index}]}
</foreach>
</if>
</select>
<!-- 统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
duty_index_general t1
WHERE
t1.is_delete = 0
</select>
</mapper>