101captain
2022-01-05 7d4d5f6000f09cf7e1b5e94e7873208b00315c61
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
<?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.McsMerchantDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.McsMerchant" id="McsMerchantMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
        <result property="account" column="account" jdbcType="VARCHAR"/>
        <result property="logo" column="logo" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="INTEGER"/>
        <result property="level" column="level" jdbcType="INTEGER"/>
        <result property="publishLimit" column="publish_limit" jdbcType="INTEGER"/>
        <result property="expireAt" column="expire_at" jdbcType="TIMESTAMP"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="lat" column="lat" jdbcType="VARCHAR"/>
        <result property="lon" column="lon" jdbcType="VARCHAR"/>
        <result property="introduction" column="introduction" jdbcType="VARCHAR"/>
        <result property="isDel" column="is_del" jdbcType="VARCHAR"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="createdBy" column="created_by" jdbcType="INTEGER"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
        <result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.mcs_merchant(name, phone, account, logo, user_id, level, publish_limit, expire_at,
        address, lat, lon, introduction, is_del, created_at, created_by, updated_at, updated_by)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.phone}, #{entity.account}, #{entity.logo}, #{entity.userId}, #{entity.level},
            #{entity.publishLimit}, #{entity.expireAt}, #{entity.address}, #{entity.lat}, #{entity.lon},
            #{entity.introduction}, #{entity.isDel}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
            #{entity.updatedBy})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.mcs_merchant(name, phone, account, logo, user_id, level, publish_limit, expire_at,
        address, lat, lon, introduction, is_del, created_at, created_by, updated_at, updated_by)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.phone}, #{entity.account}, #{entity.logo}, #{entity.userId}, #{entity.level},
            #{entity.publishLimit}, #{entity.expireAt}, #{entity.address}, #{entity.lat}, #{entity.lon},
            #{entity.introduction}, #{entity.isDel}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
            #{entity.updatedBy})
        </foreach>
        on duplicate key update
        name = values(name) , phone = values(phone) , account = values(account) , logo = values(logo) , user_id =
        values(user_id) , level = values(level) , publish_limit = values(publish_limit) , expire_at = values(expire_at)
        , address = values(address) , lat = values(lat) , lon = values(lon) , introduction = values(introduction) ,
        is_del = values(is_del) , created_at = values(created_at) , created_by = values(created_by) , updated_at =
        values(updated_at) , updated_by = values(updated_by)
    </insert>
    <select id="getMcsMerchantById"
            resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsMerchantVO">
        SELECT t1.id, t1.`name`, t1.phone, t1.account, t1.`level`, t1.expire_at, t2.`status` AS accountStatus
        FROM mcs_merchant t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.id = #{merchantId} AND t1.is_del = 0
    </select>
    <select id="pageMcsMerchant"
            resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsMerchantVO">
        SELECT t1.id, t1.`name`, t1.phone, t1.account, t1.`level`, t1.expire_at, t2.`status` AS accountStatus
        FROM mcs_merchant t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.is_del = 0
        <if test="pageMcsMerchantDTO.accountStatus != null">
            AND t2.`status` = #{pageMcsMerchantDTO.accountStatus}
        </if>
        <if test="pageMcsMerchantDTO.level != null">
            AND t1.`level` = #{pageMcsMerchantDTO.level}
        </if>
        <if test="pageMcsMerchantDTO.keyword != null and pageMcsMerchantDTO.keyword != &quot;&quot;">
            AND (
            t1.`name` LIKE CONCAT(#{pageMcsMerchantDTO.keyword}, '%')
            OR t1.phone LIKE CONCAT(#{pageMcsMerchantDTO.keyword}, '%')
            )
        </if>
        ORDER BY t1.created_at DESC
    </select>
 
</mapper>