wuyouming666
2023-11-27 1eeafb1d1b85887bec13d693d4658fbe0770a512
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
<?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.example.springboot.mapper.CategoryMapper">
    <delete id="categoryDeleteByIds">
        delete
        from `category` where id in
        <foreach collection="ids" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </delete>
    <update id="categoryUpdateById">
        update `category`
        <set>
            <if test="category.name != null and category.name != ''">
                `name` = #{category.name}
            </if>
            <if test="category.state != null">
                , state = #{category.state}
            </if>
        </set>
        where id = #{id}
    </update>
    <insert id="categoryInsert">
        insert into `category`(`name`, `state`)
        values (#{category.name}, #{category.state})
    </insert>
    <select id="findAllExceptSelf" resultType="com.example.springboot.entity.Category">
        select id, `name`, parent, `state`, create_time
        from category
        <where>
            <if test="id != null">
                id != #{id}
            </if>
        </where>
    </select>
    <select id="selectByPath" resultType="com.example.springboot.entity.Category">
        select id          id,
               `name`      name,
               creator     creator,
               `level`     level,
               create_time createTime
        from category
        <where>
            <if test="path != null and path != ''">
                category.`path` like concat('', #{path}, '%')
            </if>
        </where>
    </select>
</mapper>