Blame view

src/main/resources/mybatis/system/ConfigMapper.xml 4.39 KB
1
2
3
4
<?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">
5
<mapper namespace="com.huaheng.pc.system.config.mapper.ConfigMapper">
6
7

    <resultMap type="Config" id="ConfigResult">
8
    	<id     property="id"      column="id"      />
9
10
11
12
13
14
15
16
        <result property="configName"    column="configName"    />
        <result property="configKey"     column="configKey"     />
        <result property="configValue"   column="configValue"   />
        <result property="configType"    column="configType"    />
        <result property="createBy"      column="createBy"      />
        <result property="createTime"    column="createTime"    />
        <result property="updateBy"      column="updateBy"      />
        <result property="updateTime"    column="updateTime"    />
17
18
19
    </resultMap>

    <sql id="selectConfigVo">
20
        select id, configName, configKey, configValue, configType, createBy, createTime, updateBy, updateTime, remark from sys_config
21
22
23
24
25
    </sql>

    <!-- 查询条件 -->
	<sql id="sqlwhereSearch">
		<where>
26
27
			<if test="id !=null">
				and id = #{id}
28
29
			</if>
			<if test="configKey !=null and configKey != ''">
30
				and configKey = #{configKey}
31
32
33
34
35
36
37
38
39
40
41
42
43
			</if>
		</where>
	</sql>

    <select id="selectConfig" parameterType="Config" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
        <include refid="sqlwhereSearch"/>
    </select>

    <select id="selectConfigList" parameterType="Config" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
        <where>
			<if test="configName != null and configName != ''">
44
				AND configName like concat('%', #{configName}, '%')
45
46
			</if>
			<if test="configType != null and configType != ''">
47
				AND configType = #{configType}
48
49
			</if>
			<if test="configKey != null and configKey != ''">
50
				AND configKey like concat('%', #{configKey}, '%')
51
			</if>
52
			<if test="params != null and params.beginTime != null"><!-- 开始时间检索 -->
53
				and date_format(createTime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
54
			</if>
55
			<if test="params != null and params.endTime != null"><!-- 结束时间检索 -->
56
				and date_format(createTime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
57
58
59
60
61
62
			</if>
		</where>
    </select>

    <select id="checkConfigKeyUnique" parameterType="String" resultMap="ConfigResult">
        <include refid="selectConfigVo"/>
63
        where configKey = #{configKey}
64
65
66
67
    </select>

    <insert id="insertConfig" parameterType="Config">
        insert into sys_config (
68
69
70
71
72
			<if test="configName != null and configName != '' ">configName,</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>
73
			<if test="remark != null and remark != ''">remark,</if>
74
 			createTime
75
76
77
78
79
80
81
82
83
84
85
86
87
88
        )values(
			<if test="configName != null and configName != ''">#{configName},</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>
 			sysdate()
		)
    </insert>

    <update id="updateConfig" parameterType="Config">
        update sys_config 
        <set>
89
90
91
92
93
            <if test="configName != null and configName != ''">configName = #{configName},</if>
            <if test="configKey != null and configKey != ''">configKey = #{configKey},</if>
            <if test="configValue != null and configValue != ''">configValue = #{configValue},</if>
            <if test="configType != null and configType != ''">configType = #{configType},</if>
            <if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
94
            <if test="remark != null and remark != ''">remark = #{remark},</if>
95
 			updateTime = sysdate()
96
        </set>
97
        where id = #{id}
98
99
100
    </update>

    <delete id="deleteConfigByIds" parameterType="String">
101
102
103
        delete from sys_config where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
        	#{id}
104
105
106
107
        </foreach>
    </delete>

</mapper>