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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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.McsGameDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.McsGame" id="McsGameMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="coupons" column="coupons" jdbcType="INTEGER"/>
        <result property="surplusCoupons" column="surplus_coupons" jdbcType="INTEGER"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="awardType" column="award_type" jdbcType="INTEGER"/>
        <result property="allocation" column="allocation" jdbcType="INTEGER"/>
        <result property="coins" column="coins" jdbcType="INTEGER"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="lat" column="lat" jdbcType="VARCHAR"/>
        <result property="lon" column="lon" jdbcType="VARCHAR"/>
        <result property="expireAt" column="expire_at" jdbcType="TIMESTAMP"/>
        <result property="cover" column="cover" jdbcType="VARCHAR"/>
        <result property="otherImages" column="other_images" jdbcType="VARCHAR"/>
        <result property="introduction" column="introduction" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="isPopular" column="is_popular" jdbcType="VARCHAR"/>
        <result property="publishAt" column="publish_at" jdbcType="TIMESTAMP"/>
        <result property="isDel" column="is_del" jdbcType="VARCHAR"/>
        <result property="merchantId" column="merchant_id" jdbcType="INTEGER"/>
        <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_game(name, coupons, surplus_coupons, type, award_type, allocation, coins, address,
        lat, lon, expire_at, cover, other_images, introduction, status, publish_at, is_del, merchant_id, created_at,
        created_by, updated_at, updated_by)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.coupons}, #{entity.surplusCoupons}, #{entity.type}, #{entity.awardType},
            #{entity.allocation}, #{entity.coins}, #{entity.address}, #{entity.lat}, #{entity.lon}, #{entity.expireAt},
            #{entity.cover}, #{entity.otherImages}, #{entity.introduction}, #{entity.status}, #{entity.publishAt},
            #{entity.isDel}, #{entity.merchantId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
            #{entity.updatedBy})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.mcs_game(name, coupons, surplus_coupons, type, award_type, allocation, coins, address,
        lat, lon, expire_at, cover, other_images, introduction, status, publish_at, is_del, merchant_id, created_at,
        created_by, updated_at, updated_by)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.coupons}, #{entity.surplusCoupons}, #{entity.type}, #{entity.awardType},
            #{entity.allocation}, #{entity.coins}, #{entity.address}, #{entity.lat}, #{entity.lon}, #{entity.expireAt},
            #{entity.cover}, #{entity.otherImages}, #{entity.introduction}, #{entity.status}, #{entity.publishAt},
            #{entity.isDel}, #{entity.merchantId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
            #{entity.updatedBy})
        </foreach>
        on duplicate key update
        name = values(name) , coupons = values(coupons) , surplus_coupons = values(surplus_coupons) , type =
        values(type) , award_type = values(award_type) , allocation = values(allocation) , coins = values(coins) ,
        address = values(address) , lat = values(lat) , lon = values(lon) , expire_at = values(expire_at) , cover =
        values(cover) , other_images = values(other_images) , introduction = values(introduction) , status =
        values(status) , publish_at = values(publish_at) , is_del = values(is_del) , merchant_id = values(merchant_id) ,
        created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by
        = values(updated_by)
    </insert>
    <select id="pageMcsGame"
            resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsGameVO">
        SELECT t1.id, t1.`name`, t1.`type`, t1.coupons, t1.surplus_coupons,
        t1.publish_at, t1.`status`, t1.merchant_id, t2.`name` AS merchantName
        FROM mcs_game t1
        LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
        WHERE t1.is_del = 0 AND t1.`status` = 2
        <if test="pageMcsGameDTO.type != null">
            AND t1.`type` = #{pageMcsGameDTO.type}
        </if>
        <if test="pageMcsGameDTO.status != null">
            AND t1.`status` = #{pageMcsGameDTO.status}
        </if>
        <if test="pageMcsGameDTO.keyword != null and pageMcsGameDTO.keyword != &quot;&quot;">
            AND t1.`name` LIKE CONCAT(#{pageMcsGameDTO.keyword}, '%')
        </if>
        ORDER BY t1.created_at DESC
        UNION ALL
        SELECT t1.id, t1.`name`, t1.`type`, t1.coupons, t1.surplus_coupons,
        t1.publish_at, t1.`status`, t1.merchant_id, t2.`name` AS merchantName
        FROM mcs_game t1
        LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
        WHERE t1.is_del = 0  AND t1.`status` != 2
        <if test="pageMcsGameDTO.type != null">
            AND t1.`type` = #{pageMcsGameDTO.type}
        </if>
        <if test="pageMcsGameDTO.status != null">
            AND t1.`status` = #{pageMcsGameDTO.status}
        </if>
        <if test="pageMcsGameDTO.keyword != null and pageMcsGameDTO.keyword != &quot;&quot;">
            AND t1.`name` LIKE CONCAT(#{pageMcsGameDTO.keyword}, '%')
        </if>
        ORDER BY t1.created_at DESC
    </select>
 
</mapper>