liusuyi
2024-08-08 57c673aa3e83677bcf5d30b4b45d06bae6609db8
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
133
134
135
136
137
138
139
<?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.ruoyi.system.mapper.SysConfigMapper">
 
    <resultMap type="SysConfig" id="SysConfigResult">
        <id property="configId" column="config_id"/>
        <result property="configName" column="config_name"/>
        <result property="configNameI18n" column="config_name_i18n"/>
        <result property="configKey" column="config_key"/>
        <result property="configValue" column="config_value"/>
        <result property="configType" column="config_type"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
 
    <sql id="selectConfigVo">
        select config_id,
               config_name,
               config_name_i18n,
               config_key,
               config_value,
               config_type,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from sys_config
    </sql>
 
    <!-- 查询条件 -->
    <sql id="sqlwhereSearch">
        <where>
            <if test="configId !=null">
                and config_id = #{configId}
            </if>
            <if test="configKey !=null and configKey != ''">
                and config_key = #{configKey}
            </if>
        </where>
    </sql>
 
    <select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
        <include refid="selectConfigVo"/>
        <include refid="sqlwhereSearch"/>
    </select>
 
    <select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
        <include refid="selectConfigVo"/>
        <where>
            <if test="configName != null and configName != ''">
                AND config_name like ('%${configName}%')
            </if>
            <if test="configType != null and configType != ''">
                AND config_type = #{configType}
            </if>
            <if test="configKey != null and configKey != ''">
                AND config_key like ('%${configKey}%')
            </if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                and create_time &gt;= to_timestamp(#{params.beginTime},'yyyy-MM-DD')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                and create_time &lt;= to_timestamp(#{params.endTime},'yyyy-MM-DD')
            </if>
        </where>
    </select>
 
    <select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
        <include refid="selectConfigVo"/>
        where config_id = #{configId}
    </select>
 
    <select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
        <include refid="selectConfigVo"/>
        where config_key = #{configKey} limit 1
    </select>
 
    <insert id="insertConfig" parameterType="SysConfig">
        insert into sys_config (
        <if test="configName != null and configName != '' ">config_name,</if>
        <if test="configNameI18n != null and configNameI18n != '' ">config_name_i18n,</if>
        <if test="configKey != null and configKey != '' ">config_key,</if>
        <if test="configValue != null and configValue != '' ">config_value,</if>
        <if test="configType != null and configType != '' ">config_type,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="remark != null and remark != ''">remark,</if>
        create_time
        )values(
        <if test="configName != null and configName != ''">#{configName},</if>
        <if test="configNameI18n != null and configNameI18n != ''">#{configNameI18n},</if>
        <if test="configKey != null and configKey != ''">#{configKey},</if>
        <if test="configValue != null and configValue != ''">#{configValue},</if>
        <if test="configType != null and configType != ''">#{configType},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        now()
        )
    </insert>
 
    <update id="updateConfig" parameterType="SysConfig">
        update sys_config
        <set>
            <if test="configName != null and configName != ''">config_name = #{configName},</if>
            <if test="configNameI18n != null and configNameI18n != ''">config_name_i18n = #{configNameI18n},</if>
            <if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
            <if test="configValue != null and configValue != ''">config_value = #{configValue},</if>
            <if test="configType != null and configType != ''">config_type = #{configType},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            update_time = now()
        </set>
        where config_id = #{configId}
    </update>
 
    <delete id="deleteConfigById" parameterType="Long">
        delete
        from sys_config
        where config_id = #{configId}
    </delete>
 
    <delete id="deleteConfigByIds" parameterType="Long">
        delete from sys_config where config_id in
        <foreach item="configId" collection="array" open="(" separator="," close=")">
            #{configId}
        </foreach>
    </delete>
 
    <select id="selectByType" parameterType="String" resultMap="SysConfigResult">
        select *
        from sys_config
        where config_key = #{sysType}
    </select>
 
</mapper>