|
|
@@ -2,6 +2,14 @@
|
|
|
<!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">
|
|
|
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ t.cp_id
|
|
|
+ , t.cp_code, t.cp_name, t.svc_code, t.opening_date, t.grade_code, t.end_date, t.max_staff_num, t.cur_staff_num, t.flg_valid,
|
|
|
+ t.remarks, t.op_create_time, t.op_create_user_id, t.op_update_time, t.op_update_user_id, t.op_app_code, t.op_timestamp, t.op_db_user,
|
|
|
+ t.owner,t.cp_manager,t.cp_phone,t.cp_size,t.shop_size,t.feedback
|
|
|
+ </sql>
|
|
|
+
|
|
|
<resultMap type="com.dk.oauth.entity.CompanyResponse" id="ResultMap">
|
|
|
<result column="cp_id" property="cpId"/>
|
|
|
<result column="cp_code" property="cpCode"/>
|
|
|
@@ -11,6 +19,35 @@
|
|
|
<result column="svc_port" property="svcPort"/>
|
|
|
</resultMap>
|
|
|
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <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"/>
|
|
|
+ <result column="cp_manager" property="cpManager"/>
|
|
|
+ <result column="cp_phone" property="cpPhone"/>
|
|
|
+ <result column="cp_size" property="cpSize"/>
|
|
|
+ <result column="shop_size" property="shopSize"/>
|
|
|
+ <result column="feedback" property="feedback"/>
|
|
|
+ <result column="gradeName" property="gradeName"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
<!--获取企业信息-->
|
|
|
<select id="getByCpId" resultMap="ResultMap">
|
|
|
SELECT
|
|
|
@@ -27,4 +64,179 @@
|
|
|
where tac.cp_id = #{cpId} and (tac.end_date is null or tac.end_date > now()) and tac.flg_valid
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="cpCode != null and cpCode != ''">
|
|
|
+ AND t.cp_code = #{cpCode}
|
|
|
+ </if>
|
|
|
+ <if test="cpName != null and cpName != ''">
|
|
|
+ AND t.cp_name = #{cpName}
|
|
|
+ </if>
|
|
|
+ <if test="svcCode != null and svcCode != ''">
|
|
|
+ AND t.svc_code = #{svcCode}
|
|
|
+ </if>
|
|
|
+ <if test="openingDate != null">
|
|
|
+ AND t.opening_date = #{openingDate}
|
|
|
+ </if>
|
|
|
+ <if test="gradeCode != null and gradeCode != ''">
|
|
|
+ AND t.grade_code = #{gradeCode}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null">
|
|
|
+ AND t.end_date = #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="maxStaffNum != null">
|
|
|
+ AND t.max_staff_num = #{maxStaffNum}
|
|
|
+ </if>
|
|
|
+ <if test="curStaffNum != null">
|
|
|
+ AND t.cur_staff_num = #{curStaffNum}
|
|
|
+ </if>
|
|
|
+ <if test="flgValid != null">
|
|
|
+ AND t.flg_valid = #{flgValid}
|
|
|
+ </if>
|
|
|
+ <if test="remarks != null and remarks != ''">
|
|
|
+ AND t.remarks = #{remarks}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateTime != null">
|
|
|
+ AND t.op_create_time = #{opCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opCreateUserId != null and opCreateUserId != ''">
|
|
|
+ AND t.op_create_user_id = #{opCreateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateTime != null">
|
|
|
+ AND t.op_update_time = #{opUpdateTime}
|
|
|
+ </if>
|
|
|
+ <if test="opUpdateUserId != null and opUpdateUserId != ''">
|
|
|
+ AND t.op_update_user_id = #{opUpdateUserId}
|
|
|
+ </if>
|
|
|
+ <if test="opAppCode != null and opAppCode != ''">
|
|
|
+ AND t.op_app_code = #{opAppCode}
|
|
|
+ </if>
|
|
|
+ <if test="opTimestamp != null">
|
|
|
+ AND t.op_timestamp = #{opTimestamp}
|
|
|
+ </if>
|
|
|
+ <if test="opDbUser != null and opDbUser != ''">
|
|
|
+ AND t.op_db_user = #{opDbUser}
|
|
|
+ </if>
|
|
|
+ <if test="owner != null and owner != ''">
|
|
|
+ AND t.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 t
|
|
|
+ where cp_id = #{cpId}
|
|
|
+ and (end_date is null or end_date > now())
|
|
|
+ and flg_valid
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键查询表t_mst_staff的一行数据 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ ,g.grade_name gradeName
|
|
|
+ FROM dkic_a.t_a_company t
|
|
|
+ left join sys.t_grade g on t.grade_code = g.grade_code
|
|
|
+ WHERE t.cp_id = #{cpId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insert">
|
|
|
+ insert into dkic_a.t_a_company
|
|
|
+ (cp_name,
|
|
|
+ svc_code,
|
|
|
+ grade_code,
|
|
|
+ max_staff_num,
|
|
|
+ cur_staff_num,
|
|
|
+ owner,
|
|
|
+ cp_manager,
|
|
|
+ cp_phone,
|
|
|
+ cp_size,
|
|
|
+ shop_size,
|
|
|
+ feedback)
|
|
|
+ values (#{cpName},
|
|
|
+ dkic_a.f_allot_service(#{gradeCode}) ,
|
|
|
+ #{gradeCode} ,
|
|
|
+ #{maxStaffNum},
|
|
|
+ #{curStaffNum},
|
|
|
+ #{owner}::uuid,
|
|
|
+ #{cpManager},
|
|
|
+ #{cpPhone},
|
|
|
+ #{cpSize},
|
|
|
+ #{shopSize},
|
|
|
+ #{feedback}
|
|
|
+ )
|
|
|
+
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <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 dkic_a.t_a_company t
|
|
|
+
|
|
|
+ <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 dkic_a.t_a_company t
|
|
|
+ <include refid="Condition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into dkic_a.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>
|
|
|
+
|