admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
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
<?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.yeshi.fanli.dao.mybatis.clazz.GoodsSubClassLabelMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel">
        <id column="scl_id" property="id" jdbcType="BIGINT" />
        <result column="scl_name" property="name" jdbcType="VARCHAR" />
        <result column="scl_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="scl_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
        <result column="scl_update_time" property="updateTime"
            jdbcType="TIMESTAMP" />
        <association property="goodsClass" column="scl_class_id"
            select="com.yeshi.fanli.dao.mybatis.GoodsClassMapper.selectByPrimaryKey"></association>
 
    </resultMap>
    
    
    <resultMap id="SubMapResultVO" type="com.yeshi.fanli.vo.goods.GoodsSubClassLabelVO">
        <id column="scl_id" property="id" jdbcType="BIGINT" />
        <result column="scl_name" property="name" jdbcType="VARCHAR" />
        <result column="scl_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="scl_create_time" property="createTime"    jdbcType="TIMESTAMP" />
        <result column="scl_update_time" property="updateTime"    jdbcType="TIMESTAMP" />
        
        <association property="goodsClass" column="scl_class_id" javaType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
            <id column="scl_class_id" property="id" jdbcType="BIGINT" />    
        </association>
        
        <collection property="listSub" column="sub_id" 
            resultMap="com.yeshi.fanli.dao.mybatis.GoodsSubClassMapper.SimpleResultMap"/>
    </resultMap>
    
    
    <sql id="Base_Column_List">scl_id,scl_name,scl_order_by,scl_class_id,scl_create_time,scl_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_sub_class_label where scl_id = #{id,jdbcType=BIGINT}
    </select>
 
 
    <select id="selectByClassIdAndName" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_sub_class_label where scl_name = #{name} and
        scl_class_id=#{classId}
    </select>
 
 
    <select id="listByClassId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_sub_class_label
        <if test="classId!=null">
             where
        scl_class_id=#{classId}
        </if>
        order by scl_order_by
    </select>
 
    <select id="listSubMapByClassId" resultMap="SubMapResultVO">
        SELECT t.*,b.* FROM yeshi_ec_sub_class_label t
        LEFT JOIN yeshi_ec_sub_class_label_map p ON t.`scl_id` = p.`sclm_label_id`
        LEFT JOIN yeshi_ec_sub_class b ON b.`sub_id` = p.`sclm_sub_class_id`
        WHERE t.`scl_class_id` = #{classId} AND b.`sub_state` = 1
        <if test="month != null">
         AND (
          (sub_month is null)
          or
          FIND_IN_SET(#{month},sub_month)
          )
        </if>
        
        
        ORDER BY t.`scl_order_by`,p.`sclm_order_by`
    </select>
 
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_sub_class_label where scl_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_sub_class_label
        (scl_id,scl_name,scl_order_by,scl_class_id,scl_create_time,scl_update_time)
        values
        (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{orderBy,jdbcType=INTEGER},#{goodsClass.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_sub_class_label
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">scl_id,</if>
            <if test="name != null">scl_name,</if>
            <if test="orderBy != null">scl_order_by,</if>
            <if test="goodsClass != null">scl_class_id,</if>
            <if test="createTime != null">scl_create_time,</if>
            <if test="updateTime != null">scl_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="goodsClass != null">#{goodsClass.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel">update
        yeshi_ec_sub_class_label set scl_name =
        #{name,jdbcType=VARCHAR},scl_order_by =
        #{orderBy,jdbcType=INTEGER},scl_class_id =
        #{goodsClass.id,jdbcType=BIGINT},scl_create_time =
        #{createTime,jdbcType=TIMESTAMP},scl_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where scl_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel">
        update yeshi_ec_sub_class_label
        <set>
            <if test="name != null">scl_name=#{name,jdbcType=VARCHAR},</if>
            <if test="orderBy != null">scl_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="goodsClass != null">scl_class_id=#{goodsClass.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">scl_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">scl_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where scl_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>