|
|
@@ -2,18 +2,170 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.dk.oauth.mapper.CompanyMapper">
|
|
|
|
|
|
- <resultMap type="com.dk.oauth.entity.Company" id="ResultMap">
|
|
|
- <result column="cp_id" property="cpId"/>
|
|
|
+ <!-- 通用设置 -->
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ cp_id
|
|
|
+ , cp_code, cp_name, svc_code, opening_date, grade_code, end_date, max_staff_num, cur_staff_num, flg_valid, remarks, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user, owner
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.dk.oauth.entity.Company">
|
|
|
+ <id column="cp_id" property="cpId"/>
|
|
|
<result column="cp_code" property="cpCode"/>
|
|
|
<result column="cp_name" property="cpName"/>
|
|
|
<result column="svc_code" property="svcCode"/>
|
|
|
+ <result column="opening_date" property="openingDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="grade_code" property="gradeCode"/>
|
|
|
+ <result column="end_date" property="endDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="max_staff_num" property="maxStaffNum"/>
|
|
|
+ <result column="cur_staff_num" property="curStaffNum"/>
|
|
|
+ <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" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="op_app_code" property="opAppCode"/>
|
|
|
+ <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="op_db_user" property="opDbUser"/>
|
|
|
+ <result column="owner" property="owner" typeHandler="UuidTypeHandler"/>
|
|
|
</resultMap>
|
|
|
|
|
|
- <select id="getByCpId" resultMap="ResultMap">
|
|
|
- SELECT
|
|
|
- cp_id, cp_code, cp_name, svc_code
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="cpCode != null and cpCode != ''">
|
|
|
+ AND cp_code = #{cpCode}
|
|
|
+ </if>
|
|
|
+ <if test="cpName != null and cpName != ''">
|
|
|
+ AND cp_name = #{cpName}
|
|
|
+ </if>
|
|
|
+ <if test="svcCode != null and svcCode != ''">
|
|
|
+ AND svc_code = #{svcCode}
|
|
|
+ </if>
|
|
|
+ <if test="openingDate != null">
|
|
|
+ AND opening_date = #{openingDate}
|
|
|
+ </if>
|
|
|
+ <if test="gradeCode != null and gradeCode != ''">
|
|
|
+ AND grade_code = #{gradeCode}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null">
|
|
|
+ AND end_date = #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="maxStaffNum != null">
|
|
|
+ AND max_staff_num = #{maxStaffNum}
|
|
|
+ </if>
|
|
|
+ <if test="curStaffNum != null">
|
|
|
+ AND cur_staff_num = #{curStaffNum}
|
|
|
+ </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 opCreateUserId != ''">
|
|
|
+ AND op_create_user_id = #{opCreateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateTime != null">
|
|
|
+ AND op_update_time = #{opUpdateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateUserId != null and opUpdateUserId != ''">
|
|
|
+ AND op_update_user_id = #{opUpdateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opAppCode != null and opAppCode != ''">
|
|
|
+ AND op_app_code = #{opAppCode}
|
|
|
+ </if>
|
|
|
+ <if test="opTimestamp != null">
|
|
|
+ AND op_timestamp = #{opTimestamp}
|
|
|
+ </if>
|
|
|
+ <if test="opDbUser != null and opDbUser != ''">
|
|
|
+ AND op_db_user = #{opDbUser}
|
|
|
+ </if>
|
|
|
+ <if test="owner != null and owner != ''">
|
|
|
+ AND owner = #{owner}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="getByCpId" resultMap="BaseResultMap">
|
|
|
+ SELECT cp_id,
|
|
|
+ cp_code,
|
|
|
+ cp_name,
|
|
|
+ svc_code
|
|
|
FROM dkic_a.t_a_company
|
|
|
- where cp_id = #{cpId} and (end_date is null or end_date > now()) and flg_valid
|
|
|
+ where cp_id = #{cpId}
|
|
|
+ and (end_date is null or end_date > now())
|
|
|
+ and flg_valid
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <sql id="idsForeach">
|
|
|
+ <!-- 根据主键cpId批量操作 -->
|
|
|
+ WHERE cp_id in
|
|
|
+ <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表t_a_company,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_a_company
|
|
|
+ <include refid="Condition"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_a_company,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM t_a_company
|
|
|
+ <include refid="Condition"/>
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into t_a_company
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ cp_code,
|
|
|
+ cp_name,
|
|
|
+ svc_code,
|
|
|
+ opening_date,
|
|
|
+ grade_code,
|
|
|
+ end_date,
|
|
|
+ max_staff_num,
|
|
|
+ cur_staff_num,
|
|
|
+ remarks,
|
|
|
+ op_app_code,
|
|
|
+ owner,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.cpCode},
|
|
|
+ #{item.cpName},
|
|
|
+ #{item.svcCode},
|
|
|
+ #{item.openingDate},
|
|
|
+ #{item.gradeCode},
|
|
|
+ #{item.endDate},
|
|
|
+ #{item.maxStaffNum},
|
|
|
+ #{item.curStaffNum},
|
|
|
+ #{item.remarks},
|
|
|
+ #{item.opAppCode},
|
|
|
+ #{item.owner}::uuid,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
</mapper>
|
|
|
+
|