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
<?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" >
<mapper namespace="com.changhong.epc.tenant.mapper.tenant.system.TenantInfoMapper">
    
    <select id=""></select>
    
    <update id="updateTenanName">
        UPDATE epc_user_info
        SET userName = #{tenant.userName}
        WHERE
            openId = #{tenant.openId}
            and tenantId = #{tenant.tenantId}
            and companyId = #{tenant.companyId}
    </update>
 
    <select id="selectTenant" resultType="com.changhong.epc.bean.admin.TenantInfo">
        select
            id
            `tenantId`,
            `companyId`,
            `language`,
            `userName`,
            `data_start`,
            `ins_t`,
            `upd_t`,
            `ins_p`,
            `upd_p`,
            `openId`
        from
        epc_user_info 
        where openId = #{tenant.openId}
        and tenantId = #{tenant.tenantId}
        and companyId = #{tenant.companyId}
        LIMIT 1
        
    
    </select>
 
    <select id="createTable" statementType="CALLABLE">
        {call initCompany({tenantId}, {companyId})}
    </select>
 
    <select id="createView" statementType="CALLABLE">
        {call initReport({tenantId}, {companyId})}
    </select>
 
    <update id="runSql" >
        ${sql}
    </update>
 
    <update id="dropFunction">
        DROP FUNCTION IF EXISTS `getVal_{rule}`
    </update>
 
    <update id="createFunction" >
        CREATE FUNCTION `getVal_{rule}`(`mdCode` varchar(100),`inMeCode` varchar(100),`outMeCode` varchar(100),`inMvCode` varchar(100))
        RETURNS varchar(100) CHARSET utf8
        BEGIN
            DECLARE outVal varchar(100) DEFAULT '';
 
            DECLARE rowNo INTEGER DEFAULT -1;
 
            select
             ROW_NO INTO rowNo
            from epc_master_value_{rule}
            where ELE_VALUE = inMvCode
            and ELE_CODE = inMeCode
            and DEFINE_CODE = mdCode
            LIMIT 1;
 
            select
             ELE_VALUE INTO outVal
            from epc_master_value_{rule}
            where ROW_NO = rowNo
            and ELE_CODE = outMeCode
            and DEFINE_CODE = mdCode
            LIMIT 1;
 
            RETURN outVal;
        END
    </update>
 
    <update id="initSysForm" >
        update epc_system_config_{rule}
        set cvalue = #{entry.value.code}
        where ckey = #{entry.key}
    </update>
 
</mapper>