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
<?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_cost_from_template -->
<mapper namespace="com.changhong.epc.admin.mapper.centen.cost.CostFromTemplateMapper">
    <resultMap id="costFromTemplateMapperResultMap" type="com.changhong.epc.bean.admin.CostFromTemplate">
        <id property="id" column="id"/>
        <result property="ctId" column="ct_id"/><!-- 费用类型id -->
        <result property="fId" column="f_id"/><!-- 表单id -->
        <result property="fName" column="f_name"/>
        <result property="type" column="type"/><!-- 预算:YS 申请:SQ 报销:BX -->
    </resultMap>
   
       <!-- <resultMap type="com.changhong.epc.bean.tenant.cost.extend.CostFromMappingExtend" id="CostFromResult">
              <id property="id" column="id"/>
              <result property="fId" column="f_id"/>
              <result property="fName" column="f_name"/>
              <result property="type" column="type"/>
              <result property="ctId" column="ct_id"/>
              <association property="costType" javaType="com.changhong.epc.bean.tenant.cost.CostType">
                  <id property="id" column="bId"/>
                  <result property="nodeName" column="node_name"/>
                  <result property="parentId" column="parent_id"/>
              </association>
          </resultMap> -->
  
         <select id="selectByctId" resultMap="costFromTemplateMapperResultMap">
             SELECT
                id,f_name,f_id
            FROM
                epc_cost_from_template
            WHERE
                ct_id = #{cost.ctId} and type = #{cost.type}
         </select>
         
         <update id="updateCost" parameterType="com.changhong.epc.bean.admin.CostFromTemplate">
             UPDATE epc_cost_from_template
            SET 
            <if test="fName !=null">
                f_name = #{fName},
            </if>
            <if test="fId !=null">
                f_id = #{fId} 
            </if>    
            WHERE
                ct_id = #{ctId} and type = #{type}    
         </update>
         
         <select id="selectCostType" resultMap="costFromTemplateMapperResultMap"
             parameterType="com.changhong.epc.bean.admin.CostFromTemplate">
             SELECT
                a.id,
                a.f_id,
                a.f_name,
                a.type,
                a.ct_id,
                b.id bId,
                b.node_name,
                b.parent_id
            FROM
                epc_cost_from_template a
            LEFT JOIN epc_cost_type_{rule} b ON a.ct_id = b.id
            <trim prefix="where" >
                <if test="fId !=null">
                    a.f_id = #{fId}
                </if>
           </trim>
            LIMIT 1         
         </select>
         
         <update id="deleteForm">
             UPDATE epc_cost_from_template SET
                data_start = 99
                where ct_id = #{id}
         
         
         </update>
          <delete id="deleteCostNull">
             delete from epc_cost_from_template
             where ct_id = #{id}
         </delete>
   
   
</mapper>