wzy
2021-04-01 d388e2788b7ef088d7cd40f901b0acdcec460bc3
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?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.matrix.system.hive.dao.SysVipLabelDao">
    <insert id="insert" parameterType="com.matrix.system.hive.bean.SysVipLabel" useGeneratedKeys="true"
            keyProperty="id">
        insert sys_vip_label (
            create_time,
            create_by,
            id,
            label,
            shop_id,
            company_id,
            is_all,
            user_id,
            color
        ) values (
            now(),
            #{createBy},
            #{id},
            #{label},
            #{shopId},
            #{companyId},
            #{isAll},
            #{userId},
            #{color}
        )
    </insert>
 
    <insert id="insertRelate" parameterType="com.matrix.system.hive.bean.SysVipLabel" useGeneratedKeys="true"
            keyProperty="id">
        insert sys_vip_label_relate (
            id,
            label_id,
            vip_id
        ) values (
            #{id},
            #{labelId},
            #{vipId}
        )
    </insert>
 
    <select id="selectInPage" resultType="com.matrix.system.hive.bean.SysVipLabel">
        select
            a.create_time createTime,
            a.create_by createBy,
            a.id,
            a.label,
            a.shop_id shopId,
            a.company_id companyId,
            a.is_all isAll,
            a.user_id userId,
            a.color,
            b.shop_short_name shopName
        from sys_vip_label a
        left join sys_shop_info b on a.shop_id=b.id
        where 1=1
        <if test="record!=null">
            <if test="record.label!=null  and record.label!=''">
                and a.label like CONCAT('%', CONCAT(#{record.label},'%'))
            </if>
            <if test="record.isAll!=null  and record.isAll!=0">
                and a.is_all=#{record.isAll}
            </if>
            <if test="record.userId!=null  and record.userId!=''">
                and a.user_id=#{record.userId}
            </if>
            <if test="record.companyId!=null  and record.companyId!=''">
                and a.company_id=#{record.companyId}
            </if>
        </if>
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
            <if test="pageVo.sort !=null  and pageVo.order !=null">
                order by
                ${pageVo.sort} ${pageVo.order}
            </if>
            <if test="pageVo.offset >=0  and pageVo.limit >0">
                limit
                #{pageVo.offset},#{pageVo.limit}
            </if>
        </if>
    </select>
 
    <select id="selectTotal" resultType="java.lang.Integer">
        select
            count(1)
        from sys_vip_label
        where 1=1
        <if test="record!=null">
            <if test="record.label!=null  and record.label!=''">
                and label like CONCAT('%', CONCAT(#{record.label},'%'))
            </if>
            <if test="record.isAll!=null  and record.isAll!=0">
                and is_all=#{record.isAll}
            </if>
            <if test="record.userId!=null  and record.userId!=''">
                and user_id=#{record.userId}
            </if>
            <if test="record.companyId!=null  and record.companyId!=''">
                and company_id=#{record.companyId}
            </if>
        </if>
    </select>
 
    <update id="update">
        update sys_vip_label
        <set>
            <if test="label != null and label !='' ">
                label = #{label},
            </if>
            <if test="color != null and color !='' ">
                color = #{color},
            </if>
        </set>
        WHERE ID=#{id}
    </update>
 
    <delete id="deleteById">
        delete from sys_vip_label
        where id=#{id}
    </delete>
 
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from sys_vip_label where  id in
        <foreach collection="list" index="index" item="item" open="("
                 separator="," close=")">
            #{item}
        </foreach>
    </delete>
 
 
    <select id="selectByVipId" resultType="com.matrix.system.hive.bean.SysVipLabel">
        select b.*
        from sys_vip_label_relate a
        inner join sys_vip_label b on a.label_id=b.id
        where a.vip_id=#{vipId}
    </select>
 
    <select id="selectByModel" resultType="com.matrix.system.hive.bean.SysVipLabel">
        select
            create_time createTime,
            create_by createBy,
            id,
            label,
            shop_id shopId,
            company_id companyId,
            is_all isAll,
            user_id userId,
            color
        from sys_vip_label
        where 1=1
        <if test="record!=null">
            <if test="record.label!=null  and record.label!=''">
                and label like CONCAT('%', CONCAT(#{record.label},'%'))
            </if>
            <if test="record.isAll!=null  and record.isAll!=0">
                and is_all=#{record.isAll}
            </if>
            <if test="record.userId!=null  and record.userId!=''">
                and user_id=#{record.userId}
            </if>
            <if test="record.companyId!=null  and record.companyId!=''">
                and company_id=#{record.companyId}
            </if>
        </if>
    </select>
 
    <delete id="deleteRelateByVipId">
        delete from sys_vip_label_relate
        where vip_id=#{vipId}
    </delete>
 
    <select id="selectById" resultType="com.matrix.system.hive.bean.SysVipLabel">
        select
            create_time createTime,
            create_by createBy,
            id,
            label,
            shop_id shopId,
            company_id companyId,
            is_all isAll,
            user_id userId,
            color
        from sys_vip_label
        where id=#{id}
    </select>
</mapper>