PostDischargePatientManage/postdischarge-manage/src/main/resources/mapper/manage/wechattemplate/WechatTemplateMapper.xml

405 lines
15 KiB
XML
Raw Normal View History

<?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.xinelu.manage.mapper.wechattemplate.WechatTemplateMapper">
<resultMap type="WechatTemplate" id="WechatTemplateResult">
<result property="id" column="id"/>
<result property="departmentId" column="department_id"/>
<result property="departmentName" column="department_name"/>
<result property="diseaseTypeId" column="disease_type_id"/>
<result property="diseaseTypeName" column="disease_type_name"/>
<result property="templateId" column="template_id"/>
<result property="templateContent" column="template_content"/>
<result property="templateSource" column="template_source"/>
<result property="templateSort" column="template_sort"/>
<result property="templateRemark" column="template_remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectWechatTemplateVo">
select id,
department_id,
department_name,
disease_type_id,
disease_type_name,
template_id,
template_content,
template_source,
template_sort,
template_remark,
create_by,
create_time,
update_by,
update_time
from wechat_template
</sql>
<select id="selectWechatTemplateList" parameterType="WechatTemplate" resultMap="WechatTemplateResult">
<include refid="selectWechatTemplateVo"/>
<where>
<if test="departmentId != null ">
and department_id =
#{departmentId}
</if>
<if test="departmentName != null and departmentName != ''">
and department_name like concat('%',
#{departmentName},
'%'
)
</if>
<if test="diseaseTypeId != null ">
and disease_type_id =
#{diseaseTypeId}
</if>
<if test="diseaseTypeName != null and diseaseTypeName != ''">
and disease_type_name like concat('%',
#{diseaseTypeName},
'%'
)
</if>
<if test="templateId != null and templateId != ''">
and template_id =
#{templateId}
</if>
<if test="templateContent != null and templateContent != ''">
and template_content =
#{templateContent}
</if>
<if test="templateSource != null and templateSource != ''">
and template_source =
#{templateSource}
</if>
<if test="templateSort != null ">
and template_sort =
#{templateSort}
</if>
<if test="templateRemark != null and templateRemark != ''">
and template_remark =
#{templateRemark}
</if>
</where>
</select>
<select id="selectWechatTemplateById" parameterType="Long"
resultMap="WechatTemplateResult">
<include refid="selectWechatTemplateVo"/>
where id = #{id}
</select>
<select id="selectWechatTemplateDtoList" resultType="com.xinelu.manage.dto.wechattemplate.WechatTemplateDTO">
select wt.id ,
wt.department_id,
wt.department_name ,
wt.disease_type_id ,
wt.disease_type_name,
wt.wechat_template_name,
wt.template_id,
wt.template_content,
wt.template_source,
wt.template_sort,
wt.template_remark,
wtst.suit_task_type_id AS suitTaskTypeId,
wtst.suit_task_type_name AS suitTaskTypeName,
wt.create_by,
wt.create_time,
wt.update_by,
wt.update_time
from wechat_template wt
left join wechat_template_suit_task wtst on wt.id = wtst.wechat_template_id
<where>
<if test="departmentId != null ">
and wt.department_id =
#{departmentId}
</if>
<if test="departmentName != null and departmentName != ''">
and wt.department_name like concat('%',
#{departmentName},
'%'
)
</if>
<if test="diseaseTypeId != null ">
and wt.disease_type_id =
#{diseaseTypeId}
</if>
<if test="diseaseTypeName != null and diseaseTypeName != ''">
and wt.disease_type_name like concat('%',
#{diseaseTypeName},
'%'
)
</if>
<if test="wechatTemplateName != null and wechatTemplateName != ''">
and wt.wechat_template_name like concat('%',
#{wechatTemplateName},
'%'
)
</if>
<if test="templateId != null and templateId != ''">
and wt.template_id =
#{templateId}
</if>
<if test="templateContent != null and templateContent != ''">
and wt.template_content =
#{templateContent}
</if>
<if test="templateSource != null and templateSource != ''">
and wt.template_source =
#{templateSource}
</if>
<if test="templateSort != null ">
and wt.template_sort =
#{templateSort}
</if>
<if test="templateRemark != null and templateRemark != ''">
and wt.template_remark =
#{templateRemark}
</if>
<if test="suitTaskTypeName != null and suitTaskTypeName != ''">
and wtst.suit_task_type_name=
#{suitTaskTypeName}
</if>
</where>
</select>
<select id="selectWechatTemplateDtoById" resultType="com.xinelu.manage.dto.wechattemplate.WechatTemplateDTO">
select wt.id,
wt.department_id,
wt.department_name,
wt.disease_type_id,
wt.disease_type_name,
wt.wechat_template_name,
wt.template_id,
wt.template_content,
wt.template_source,
wt.template_sort,
wt.template_remark,
wtst.suit_task_type_id AS suitTaskTypeId,
wtst.suit_task_type_name AS suitTaskTypeName,
wt.create_by,
wt.create_time,
wt.update_by,
wt.update_time
from wechat_template wt
left join wechat_template_suit_task wtst on wt.id = wtst.wechat_template_id
where wt.id = #{id}
</select>
<select id="countByWechatTemplateDto" resultType="java.lang.Integer">
select count(*)
from wechat_template wt
left join wechat_template_suit_task wtst on wt.id = wtst.wechat_template_id
<where>
wt.department_id = #{departmentId}
and wt.department_name = #{departmentName}
and wt.wechat_template_name = #{wechatTemplateName}
and wt.template_source = #{templateSource}
and wtst.suit_task_type_name= #{suitTaskTypeName}
<if test="diseaseTypeId != null ">
and wt.disease_type_id =
#{diseaseTypeId}
</if>
<if test="diseaseTypeName != null and diseaseTypeName != ''">
and wt.disease_type_name =
#{diseaseTypeName}
</if>
</where>
</select>
<insert id="insertWechatTemplate" parameterType="WechatTemplate" useGeneratedKeys="true"
keyProperty="id">
insert into wechat_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="departmentId != null">department_id,
</if>
<if test="departmentName != null">department_name,
</if>
<if test="diseaseTypeId != null">disease_type_id,
</if>
<if test="diseaseTypeName != null">disease_type_name,
</if>
<if test="wechatTemplateName != null">wechat_template_name,
</if>
<if test="templateId != null">template_id,
</if>
<if test="templateContent != null">template_content,
</if>
<if test="templateSource != null">template_source,
</if>
<if test="templateSort != null">template_sort,
</if>
<if test="templateRemark != null">template_remark,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="departmentId != null">#{departmentId},
</if>
<if test="departmentName != null">#{departmentName},
</if>
<if test="diseaseTypeId != null">#{diseaseTypeId},
</if>
<if test="diseaseTypeName != null">#{diseaseTypeName},
</if>
<if test="templateId != null">#{templateId},
</if>
<if test="wechatTemplateName != null">wechat_template_name,
</if>
<if test="templateContent != null">#{templateContent},
</if>
<if test="templateSource != null">#{templateSource},
</if>
<if test="templateSort != null">#{templateSort},
</if>
<if test="templateRemark != null">#{templateRemark},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
</trim>
</insert>
<insert id="insertWechatTemplateSuitTask">
insert into wechat_template_suit_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="wechatTemplateId != null">wechat_template_id,
</if>
<if test="suitTaskTypeId != null">suit_task_type_id,
</if>
<if test="suitTaskTypeName != null">suit_task_type_name,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="wechatTemplateId != null">#{wechatTemplateId},
</if>
<if test="suitTaskTypeId != null">#{suitTaskTypeId},
</if>
<if test="suitTaskTypeName != null">#{suitTaskTypeName},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
</trim>
</insert>
<update id="updateWechatTemplate" parameterType="WechatTemplate">
update wechat_template
<trim prefix="SET" suffixOverrides=",">
<if test="departmentId != null">department_id =
#{departmentId},
</if>
<if test="departmentName != null">department_name =
#{departmentName},
</if>
<if test="diseaseTypeId != null">disease_type_id =
#{diseaseTypeId},
</if>
<if test="diseaseTypeName != null">disease_type_name =
#{diseaseTypeName},
</if>
<if test="wechatTemplateName != null">wechat_template_name =
#{wechatTemplateName},
</if>
<if test="templateId != null">template_id =
#{templateId},
</if>
<if test="templateContent != null">template_content =
#{templateContent},
</if>
<if test="templateSource != null">template_source =
#{templateSource},
</if>
<if test="templateSort != null">template_sort =
#{templateSort},
</if>
<if test="templateRemark != null">template_remark =
#{templateRemark},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
</trim>
where id = #{id}
</update>
<update id="updateWechatTemplateSuitTask">
update wechat_template_suit_task
<trim prefix="SET" suffixOverrides=",">
<if test="suitTaskTypeId != null">suit_task_type_id =
#{suitTaskTypeId},
</if>
<if test="suitTaskTypeName != null"> suit_task_type_name=
#{suitTaskTypeName},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
</trim>
where wechat_template_id =#{wechatTemplateId}
</update>
<delete id="deleteWechatTemplateById" parameterType="Long">
delete
from wechat_template
where id = #{id}
</delete>
<delete id="deleteWechatTemplateByIds" parameterType="String">
delete from wechat_template where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteWechatTemplateSuitTaskByIds">
delete
from wechat_template_suit_task
where wechat_template_id in
<foreach item="wechatTemplateId" collection="array" open="(" separator="," close=")">
#{wechatTemplateId}
</foreach>
</delete>
</mapper>