mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.panzhihua.service_community.dao.ConvenientGoodsCategoryDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientGoodsCategoryDO">
        <id column="id" property="id"/>
        <id column="name" property="name"/>
        <id column="icon" property="icon"/>
        <id column="remark" property="remark"/>
        <id column="weight" property="weight"/>
        <id column="is_del" property="isDel"/>
        <id column="created_at" property="createdAt"/>
        <id column="created_by" property="createdBy"/>
        <id column="updated_at" property="updatedAt"/>
        <id column="updated_by" property="updatedBy"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
    id,`name`,icon,remark,weight,is_del,created_at,created_by,updated_at,updated_by
    </sql>
 
    <select id="pageGoodsCategory"
            resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientGoodsCategoryVO">
        SELECT
        <include refid="Base_Column_List"/>
        FROM com_convenient_goods_categories
        WHERE is_del = 0
        <if test="pageConvenientGoodsCategoryDTO.name != null and pageConvenientGoodsCategoryDTO.name.trim() != &quot;&quot;">
            AND `name` LIKE concat('%', #{pageConvenientGoodsCategoryDTO.name}, '%' )
        </if>
        <if test="pageConvenientGoodsCategoryDTO.areaCode != null and pageConvenientGoodsCategoryDTO.areaCode.trim() != &quot;&quot;">
            AND area_code = #{pageConvenientGoodsCategoryDTO.areaCode}
        </if>
        ORDER BY weight DESC
    </select>
    <delete id="deleteGoodsCategoryRelation">
        DELETE FROM com_convenient_goods_scope WHERE goods_id = #{goodsId}
    </delete>
    <select id="selectCategoryScopeByGoodsId" resultType="java.lang.String">
        SELECT GROUP_CONCAT(`goods_category_name`) serviceScope FROM com_convenient_goods_scope WHERE goods_id = #{goodsId}
    </select>
    <select id="selectCategoryIdsForGoods" resultType="java.lang.Long">
        SELECT goods_category_id FROM com_convenient_goods_scope WHERE goods_id = #{goodsId}
    </select>
    <select id="checkCategoryIsUsing" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM com_convenient_goods_scope WHERE goods_category_id = #{categoryId}
    </select>
    <insert id="createGoodsCategoryRelation">
        INSERT INTO com_convenient_goods_scope (id,goods_id, goods_category_id, goods_category_name, created_by, created_at)
        VALUES (#{id},#{goodsId}, #{goodsCategoryId}, #{goodsCategoryName}, #{createdBy}, NOW())
    </insert>
 
</mapper>