xing
2023-02-23 c75e6f4696634d626c5569794c6349593853223a
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?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.yssh.dao.DictRecordMapper">
 
    <resultMap type="com.yssh.entity.DictRecord" id="DictRecordResult">
        <result property="id"    column="id"    />
        <result property="tableName"    column="table_name"    />
        <result property="other"    column="other"    />
        <result property="remarks"    column="remarks"    />
        <result property="status"    column="status"    />
<!--        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />-->
        <result property="resOne"    column="res_one"    />
        <result property="resTwo"    column="res_two"    />
        <result property="resThree"    column="res_three"    />
        <result property="resFour"    column="res_four"    />
    </resultMap>
 
    <sql id="selectDictRecordVo">
        select id, table_name, other, remarks, status, res_one, res_two, res_three, res_four from yssh_dict_record
    </sql>
 
    <select id="selectDictRecordList" parameterType="com.yssh.entity.DictRecord" resultMap="DictRecordResult">
        <include refid="selectDictRecordVo"/>
        <where>
            <if test="tableName != null  and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
            <if test="other != null  and other != ''"> and other = #{other}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="resOne != null  and resOne != ''"> and res_one = #{resOne}</if>
            <if test="resTwo != null  and resTwo != ''"> and res_two = #{resTwo}</if>
            <if test="resThree != null  and resThree != ''"> and res_three = #{resThree}</if>
            <if test="resFour != null  and resFour != ''"> and res_four = #{resFour}</if>
        </where>
    </select>
 
  <!--  <select id="selectDictRecordById" parameterType="Long" resultMap="DictRecordResult">
        <include refid="selectDictRecordVo"/>
        where id = #{id}
    </select>-->
 
    <insert id="insertDictRecord" parameterType="com.yssh.entity.DictRecord" useGeneratedKeys="true" keyProperty="id">
        insert into yssh_dict_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tableName != null and tableName != ''">table_name,</if>
            <if test="other != null">other,</if>
            <if test="remarks != null">remarks,</if>
            <if test="status != null">status,</if>
            <if test="resOne != null">res_one,</if>
            <if test="resTwo != null">res_two,</if>
            <if test="resThree != null">res_three,</if>
            <if test="resFour != null">res_four,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tableName != null and tableName != ''">#{tableName},</if>
            <if test="other != null">#{other},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="status != null">#{status},</if>
            <if test="resOne != null">#{resOne},</if>
            <if test="resTwo != null">#{resTwo},</if>
            <if test="resThree != null">#{resThree},</if>
            <if test="resFour != null">#{resFour},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>
 
    <!--<update id="updateDictRecord" parameterType="com.yssh.entity.DictRecord">
        update yssh_dict_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="tableName != null and tableName != ''">table_name = #{tableName},</if>
            <if test="other != null">other = #{other},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="resOne != null">res_one = #{resOne},</if>
            <if test="resTwo != null">res_two = #{resTwo},</if>
            <if test="resThree != null">res_three = #{resThree},</if>
            <if test="resFour != null">res_four = #{resFour},</if>
        </trim>
        where id = #{id}
    </update>-->
 
    <delete id="deleteDictRecordById" parameterType="Long">
        delete from yssh_dict_record where id = #{id}
    </delete>
 
    <delete id="deleteDictRecordByIds" parameterType="String">
        delete from yssh_dict_record where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <!--创建表的 SQL 语句-->
    <update id="createDictRecoTable" parameterType="java.lang.String">
        CREATE TABLE IF NOT EXISTS `${tableName}` (
            `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'ID',
            `table_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '表名称',
            `other` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '表其他内容',
            `remarks` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
            `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '0' COMMENT '状态',
            `create_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '创建时间',
            `create_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
            `update_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
            `update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
            `res_one` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留一',
            `res_two` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留二',
            `res_three` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留三',
            `res_four` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '预留四',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '字典记录表' ROW_FORMAT = Dynamic;
    </update>
 
    <select id="selectDictRecordList2dByTime" parameterType="com.yssh.entity.DictRecord" resultMap="DictRecordResult">
        <include refid="selectDictRecordVo"/>
        where res_one ='2' and res_two BETWEEN ${startTime} AND ${endOfTime}
    </select>
 
    <select id="selectDictRecordList3dByTime" parameterType="com.yssh.entity.DictRecord" resultMap="DictRecordResult">
        <include refid="selectDictRecordVo"/>
        where res_one ='3' and res_two BETWEEN ${startTime} AND ${endOfTime}
    </select>
 
</mapper>