广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
<?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">
<!--
 * @title: ai服务字典
 * @description: 自定义sql,请自行实现业务逻辑
 * @company: hugeinfo
 * @author: huangh
 * @time:2024年12月11日
 * @version 1.0.0
-->
<mapper namespace="cn.huge.module.knowledge.dao.mapper.DictionaryMapper">
    <!-- 结果集 -->
    <resultMap id="dataResult" type="cn.huge.module.knowledge.domain.po.Dictionary">
        <result property="code" column="code"/>
        <result property="name" column="name"/>
        <result property="value" column="value"/>
        <result property="parentCode" column="parent_code"/>
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dictionary</sql>
    <!-- 字段 -->
    <sql id="column-part">
        code,name,value,parent_code
    </sql>
    <!-- 更新实体字段 -->
    <sql id="set-part">
        <if test="entity.name != null">name = #{entity.name},</if>
        <if test="entity.value != null">value = #{entity.value},</if>
        <if test="entity.parentCode != null">parent_code = #{entity.parentCode}</if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part">
        <if test="terms != null">
            <where>
                <if test="terms.code != null and terms.code !=''">
                    and code = #{terms.code}
                </if>
                <if test="terms.name != null and terms.name !=''">
                    and name = #{terms.name}
                </if>
                <if test="terms.value != null and terms.value !=''">
                    and value = #{terms.value}
                </if>
                <if test="terms.parentCode != null and terms.parentCode !=''">
                    and parent_code = #{terms.parentCode}
                </if>
            </where>
        </if>
    </sql>
    <!-- 更新对象 -->
    <update id="updateDictionary">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <where>
            code = #{entity.code}
        </where>
    </update>
    <!-- 条件更新对象 -->
    <update id="updateDictionaryTerms">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <include refid="where-part"/>
    </update>
    <!--  根据编号物理删除  -->
    <delete id="deleteDictionary">
        delete from
        <include refid="table-name" />
        where code = #{id}
    </delete>
    <!--  根据条件查询  -->
    <select id="listTerms" resultMap="dataResult">
        select
        <include refid="column-part"/>
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件统计  -->
    <select id="countTerms" resultType="java.lang.Long">
        select
        COUNT(1)
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件分页查询  -->
    <select id="pageTerms" resultMap="dataResult">
        SELECT
        <include refid="column-part"/>
        FROM
        <include refid="table-name" />
        <include refid="where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(create_time), create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
</mapper>