zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?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_master_element_mapping -->
<mapper namespace="com.changhong.epc.admin.mapper.centen.site.MasterElementMappingMapper">
    
    <resultMap type="com.changhong.epc.bean.admin.MasterElementMapping" id="resultMap">
        <result property="meCode" column="me_code"/>
        <result property="tableField" column="table_field"/>
    </resultMap>
    
    <select id="getField" resultMap="resultMap">
        
        SELECT
        
               <choose>
                <when test="params != null">
                (    
                    CASE
                    <foreach collection="params" item="item" index="index">
                        WHEN me_code = #{item.code}
                            THEN #{item.alias}
                    </foreach>
                    END
                ) me_code,
                
                </when>
                <otherwise>
                 me_code,
                </otherwise>
            </choose>
            table_field,
            m_id
        FROM
            epc_master_element_mapping
        WHERE
            m_id = #{id}
            <if test="params != null">
                AND me_code in
                <foreach collection="params" item="item" index="index" open="(" close=")" separator=",">
                     #{item.code}
            
             </foreach>
            </if>
        
    </select>
    
    <select id="getFieldOne" resultType="java.lang.String">
        SELECT
            table_field
        FROM
            epc_master_element_mapping
        WHERE
        m_id = #{id} and me_code = #{code}
    
    
    </select>
 
    <update id="updateMasterElementMapping" parameterType="com.changhong.epc.bean.admin.MasterElementMapping">
        update  epc_master_element_mapping
        <trim prefix="set" suffix=" where id = #{id} " suffixOverrides=",">
            <if test="mId != null">
                m_id=#{mId},
            </if>
            <if test="meCode!=null and meCode.length()>0">
                me_code=#{meCode},
            </if>
            <if test="tableField != null and tableField.length()>0">
                table_field=#{tableField},
            </if>
            <!--<if test="updT != null">
                upd_t=#{updT},
            </if>
            <if test="updP != null and updP.length()>0">
                upd_p=#{updP},
            </if>-->
 
        </trim>
 
    </update>
 
    <select id="getFieldByMid" resultMap="resultMap">
          select
          me_code,table_field
          from
              epc_master_element_mapping
          where
              m_id=#{mid}
    </select>
 
 
 
 
    
</mapper>