kimi
2020-03-31 74472c9d22dddcb41383794caf0011043b20f817
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
<?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.highdatas.mdm.mapper.MasterModifiedMapper">
 
 
    <select id="selectByTableMasterId" resultType="java.util.Map" statementType="STATEMENT" >
        select * from master_modified where table_name = ${tableName} and master_id =  ${masterId}
    </select>
 
 
    <insert id="insertUserByTableNameUserId" statementType="STATEMENT" >
      INSERT INTO master_modified (id, table_name, master_id, ${userId}) SELECT UUID_SHORT() as id, ${tableName} as table_name, a.id  as master_id, ${fieldStr} as ${userId} from
      (
      SELECT temp.id from maintain_detail LEFT JOIN
        ${recordTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId}
      ) a
    </insert>
 
    <insert id="insertJsonByTableNameUserId" statementType="STATEMENT" >
      INSERT INTO master_modified (id, table_name, master_id, pre_record ) SELECT UUID_SHORT() as id, ${tableName} as table_name, a.id  as master_id, ${jsonStr} as pre_record from
      (
      SELECT temp.id from maintain_detail LEFT JOIN
        ${recordTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId}
      ) a
    </insert>
 
 
    <select id="selectByMaintainId" resultType="java.util.Map" statementType="STATEMENT" >
      SELECT * from master_modified
        WHERE EXISTS
        (
        select id from
        (SELECT std_id as id from maintain_detail LEFT JOIN
        ${recoedTableName} temp on temp.id = maintain_detail.pre_merge_id
         WHERE maintain_detail.parent_id = ${maintainId})
        a
        where  a.id = master_modified.master_id)
    </select>
 
</mapper>