<?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" >
|
<!-- Table:epc_app_stander_def_{rule} -->
|
<mapper namespace="com.changhong.epc.tenant.mapper.tenant.norm.MasterDefineMapper">
|
|
<resultMap id="BaseResultMap" type="com.changhong.epc.bean.tenant.master.extend.MasterDefineExtend" >
|
<id column="id" property="Id" jdbcType="INTEGER" />
|
<result column="CODE" property="code" jdbcType="VARCHAR" />
|
<result column="Name" property="name" jdbcType="VARCHAR" />
|
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
<result column="TYPE" property="type" jdbcType="VARCHAR" />
|
<result column="ELECODE" property="eleCode" jdbcType="VARCHAR" />
|
<result column="ELEVALUE" property="eleValue" jdbcType="VARCHAR" />
|
<result column="DEL_FLAG" property="delFlag" jdbcType="INTEGER" />
|
<result column="Def1" property="def1" jdbcType="VARCHAR" />
|
<result column="Def2" property="def2" jdbcType="VARCHAR" />
|
<result column="Def3" property="def3" jdbcType="VARCHAR" />
|
<result column="Def4" property="def4" jdbcType="VARCHAR" />
|
<result column="Def5" property="def5" jdbcType="VARCHAR" />
|
<result column="ins_p" property="insP" jdbcType="INTEGER" />
|
<result column="ins_t" property="insT" jdbcType="TIMESTAMP" />
|
<result column="upd_p" property="updP" jdbcType="INTEGER" />
|
<result column="upd_t" property="updT" jdbcType="TIMESTAMP" />
|
</resultMap>
|
|
<resultMap id="MasterEleResult" type="com.changhong.epc.bean.tenant.master.extend.MasterDefinesExtend" >
|
<id property="id" column="id"/>
|
<result property="code" column="CODE"/>
|
<result property="name" column="NAME"/>
|
<collection property="eleList" ofType="com.changhong.epc.bean.tenant.master.MasterElement" javaType="list">
|
<id property="id" column="bId"/>
|
<result property="defineCode" column="define_code"/>
|
<result property="code" column="bCode"/>
|
<result property="name" column="bName"/>
|
<result property="alias" column="alias"/>
|
</collection>
|
</resultMap>
|
|
<select id="selectIdByCode" resultType="java.lang.Integer" parameterType="java.lang.String" >
|
|
select
|
id
|
from epc_master_define_{rule}
|
where code = #{code}
|
|
and data_start = 0
|
</select>
|
|
<select id="selectByQuery" resultMap="BaseResultMap" >
|
select
|
distinct
|
code , name, DESCRIPTION, type
|
,(select meCode.code from epc_master_element_{rule} meCode where meCode.define_code = md.code and meCode.DEL_FLAG = 1 and meCode.ALIAS = 'code') ELECODE
|
,(select meCode.code from epc_master_element_{rule} meCode where meCode.define_code = md.code and meCode.DEL_FLAG = 1 and meCode.ALIAS = 'value') ELEVALUE
|
from epc_master_define_{rule} md
|
<where>
|
<if test="type != null">
|
and type = #{type}
|
</if>
|
and del_flag = 0
|
</where>
|
</select>
|
|
<sql id="selectField">
|
ID,CODE,NAME,DESCRIPTION,TYPE,DEL_FLAG,INS_P,INS_T,UPD_P,UPD_T,TENANT_ID,DATA_START
|
</sql>
|
|
|
<select id="selectEle" resultMap="MasterEleResult" parameterType="com.changhong.epc.bean.tenant.master.MasterDefine">
|
SELECT
|
a.id ,
|
a. CODE ,
|
a. NAME ,
|
b.define_code ,
|
b.id bId,
|
b. CODE bCode,
|
b. NAME bName,
|
b.ALIAS alias
|
FROM
|
epc_master_define_{rule} a
|
LEFT JOIN epc_master_element_{rule} b ON a. CODE = b.define_code
|
<trim prefix="WHERE" prefixOverrides="AND | OR">
|
<if test="name != null">
|
a.NAME = #{name}
|
</if>
|
<if test="id != null">
|
and a.id = #{id}
|
</if>
|
<if test="code != null">
|
and a.CODE = #{code}
|
</if>
|
|
</trim>
|
|
</select>
|
|
<select id="selectName" resultMap="MasterEleResult" >
|
SELECT
|
a.id,
|
a. CODE ,
|
a. NAME ,
|
b.define_code,
|
b.id bId,
|
b. CODE bCode,
|
b. NAME bName
|
FROM
|
epc_master_define_{rule} a
|
LEFT JOIN epc_master_element_{rule} b ON a. CODE = b.define_code
|
<trim prefix="WHERE" >
|
<if test="master.name != null">
|
a.NAME = #{master.name}
|
</if>
|
</trim>
|
</select>
|
|
<delete id="deleteAll">
|
delete from epc_master_define_{rule}
|
|
</delete>
|
|
<select id="queryMaster" resultType="java.lang.Integer">
|
SELECT
|
COUNT(*)
|
FROM
|
epc_master_define_{rule}
|
WHERE
|
DEL_FLAG = 0
|
AND CODE = #{code}
|
</select>
|
|
<insert id="addMasterValue">
|
insert into ${tableName}
|
<foreach collection="map" index="key" item="val" separator="," open="(" close=")">
|
${key}
|
</foreach>
|
values
|
<foreach collection="map" index="key" item="val" separator="," open="(" close=")">
|
#{val}
|
</foreach>
|
</insert>
|
|
<resultMap id="selectDefAndMapResultMap" type="com.changhong.epc.bean.tenant.master.extend.MasterDefinesExtend">
|
<id column="mdCode" property="code"/>
|
<result column="mdName" property="name"/>
|
<result column="type" property="defType"/>
|
<result column="table_name" property="defMapTableName"/>
|
<result column="mapType" property="defMapType"/>
|
<collection property="eleList" ofType="com.changhong.epc.bean.tenant.master.MasterElement">
|
<id column="meCode" property="code"/>
|
<result column="meName" property="name"/>
|
<result column="mdCode" property="defineCode"/>
|
<result column="meAlias" property="alias"/>
|
<result column="table_field" property="defMapTalbeField"/>
|
</collection>
|
</resultMap>
|
|
<select id="selectDefAndMap" parameterType="com.changhong.epc.bean.tenant.master.MasterDefine" resultMap="selectDefAndMapResultMap">
|
select
|
td.code mdCode
|
, td.name mdName
|
, 0 type
|
, tdm.table_name
|
, tdm.type mapType
|
, te.`CODE` meCode
|
, te.`NAME` meName
|
, te.ALIAS meAlias
|
, tem.table_field
|
from epc_master_define_{rule} td
|
left join epc_center.epc_master_default_mapping tdm on td.`CODE` = tdm.md_code
|
left join epc_master_element_{rule} te on td.`CODE` = te.DEFINE_CODE
|
left join epc_center.epc_master_element_mapping tem on tdm.id = tem.m_id and te.code = tem.me_code
|
<where>
|
<if test="code != null">
|
td.code = #{code}
|
</if>
|
</where>
|
UNION ALL
|
select
|
td.code mdCode
|
, td.name mdName
|
, 1 type
|
, tdm.table_name
|
, tdm.type mapType
|
, te.`CODE` meCode
|
, te.`NAME` meName
|
, te.ALIAS meAlias
|
, tem.table_field
|
from epc_center.epc_master_define td
|
left join epc_center.epc_master_default_mapping tdm on td.`CODE` = tdm.md_code
|
left join epc_center.epc_master_element te on td.`CODE` = te.DEFINE_CODE
|
left join epc_center.epc_master_element_mapping tem on tdm.id = tem.m_id and te.code = tem.me_code
|
<where>
|
<if test="code != null">
|
td.code = #{code}
|
</if>
|
</where>
|
</select>
|
|
</mapper>
|