|
|
@@ -0,0 +1,181 @@
|
|
|
+<?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.dk.mdm.mapper.mst.TemplatePrintMapper">
|
|
|
+
|
|
|
+ <!-- 通用设置 -->
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ tm_id
|
|
|
+ , tm_name, doc_code, tm_data, display_no, cp_id, sys_id, flg_valid, remarks, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_id, op_api_id, op_timestamp, op_db_user
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.TemplatePrint">
|
|
|
+ <id column="tm_id" property="tmId"/>
|
|
|
+ <result column="tm_name" property="tmName"/>
|
|
|
+ <result column="doc_code" property="docCode"/>
|
|
|
+ <result column="tm_data" property="tmData" typeHandler="JsonTypeHandler"/>
|
|
|
+ <result column="display_no" property="displayNo"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="sys_id" property="sysId"/>
|
|
|
+ <result column="flg_valid" property="flgValid"/>
|
|
|
+ <result column="remarks" property="remarks"/>
|
|
|
+ <result column="op_create_time" property="opCreateTime"
|
|
|
+ typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_create_user_id" property="opCreateUserId"/>
|
|
|
+ <result column="op_update_time" property="opUpdateTime"
|
|
|
+ typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_update_user_id" property="opUpdateUserId"/>
|
|
|
+ <result column="op_app_id" property="opAppId"
|
|
|
+ typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_api_id" property="opApiId"
|
|
|
+ typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_timestamp" property="opTimestamp"
|
|
|
+ typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_db_user" property="opDbUser"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="tmName != null and tmName != ''">
|
|
|
+ AND position(#{tmName} in tm_name) > 0
|
|
|
+ </if>
|
|
|
+ <if test="docCode != null and docCode != ''">
|
|
|
+ AND doc_code = #{docCode}
|
|
|
+ </if>
|
|
|
+ <if test="tmData != null and tmData != ''">
|
|
|
+ AND tm_data = #{tmData}
|
|
|
+ </if>
|
|
|
+ <if test="displayNo != null">
|
|
|
+ AND display_no = #{displayNo}
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="sysId != null">
|
|
|
+ AND sys_id = #{sysId}
|
|
|
+ </if>
|
|
|
+ <if test="flgValid != null">
|
|
|
+ AND flg_valid = #{flgValid}
|
|
|
+ </if>
|
|
|
+ <if test="remarks != null and remarks != ''">
|
|
|
+ AND remarks = #{remarks}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateTime != null">
|
|
|
+ AND op_create_time = #{opCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateUserId != null">
|
|
|
+ AND op_create_user_id = #{opCreateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateTime != null">
|
|
|
+ AND op_update_time = #{opUpdateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateUserId != null">
|
|
|
+ AND op_update_user_id = #{opUpdateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opAppId != null and opAppId != ''">
|
|
|
+ AND op_app_id = #{opAppId}
|
|
|
+ </if>
|
|
|
+ <if test="opApiId != null and opApiId != ''">
|
|
|
+ AND op_api_id = #{opApiId}
|
|
|
+ </if>
|
|
|
+ <if test="opTimestamp != null">
|
|
|
+ AND op_timestamp = #{opTimestamp}
|
|
|
+ </if>
|
|
|
+ <if test="opDbUser != null and opDbUser != ''">
|
|
|
+ AND op_db_user = #{opDbUser}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="idsForeach">
|
|
|
+ <!-- 根据主键tmId批量操作 -->
|
|
|
+ WHERE tm_id in
|
|
|
+ <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表mst.t_m_template_print,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM mst.t_m_template_print
|
|
|
+ <include refid="Condition"/>
|
|
|
+ order by tm_id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表mst.t_m_template_print,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM mst.t_m_template_print
|
|
|
+ <include refid="Condition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表mst.t_m_template_print的一行数据 -->
|
|
|
+ <select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM mst.t_m_template_print
|
|
|
+ WHERE tm_id = #{tmId}
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表mst.t_m_template_print的多行数据 -->
|
|
|
+ <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM mst.t_m_template_print
|
|
|
+ <include refid="idsForeach"/>
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into mst.t_m_template_print
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ tm_name,
|
|
|
+ doc_code,
|
|
|
+ tm_data,
|
|
|
+ display_no,
|
|
|
+ cp_id,
|
|
|
+ sys_id,
|
|
|
+ remarks,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.tmName},
|
|
|
+ #{item.docCode},
|
|
|
+ #{item.tmData},
|
|
|
+ #{item.displayNo},
|
|
|
+ #{item.cpId},
|
|
|
+ #{item.sysId},
|
|
|
+ #{item.remarks},
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <select id="selectChooseTemplate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM mst.t_m_template_print
|
|
|
+ where flg_valid is true and
|
|
|
+ case WHEN (
|
|
|
+ select count(1) from mst.t_m_template_print
|
|
|
+ WHERE cp_id = #{cpId} and sys_id = #{sysId} and flg_valid is true) > 0
|
|
|
+ then
|
|
|
+ cp_id = #{cpId} and sys_id = #{sysId}
|
|
|
+ else
|
|
|
+ cp_id = 1 and sys_id = 1
|
|
|
+ end
|
|
|
+ order by display_no
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|