yanghui
2022-10-24 10df7e29b51d6a2efacc83d870856f57d97a9b66
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
<?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.ComActDpcDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActDpc" id="ComActDpcMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
        <result property="nation" column="nation" jdbcType="VARCHAR"/>
        <result property="sex" column="sex" jdbcType="INTEGER"/>
        <result property="area" column="area" jdbcType="VARCHAR"/>
        <result property="belong" column="belong" jdbcType="VARCHAR"/>
        <result property="category" column="category" jdbcType="VARCHAR"/>
        <result property="position" column="position" jdbcType="VARCHAR"/>
        <result property="photo" column="photo" jdbcType="VARCHAR"/>
        <result property="isDel" column="is_del" jdbcType="VARCHAR"/>
        <result property="createdBy" column="created_by" jdbcType="INTEGER"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_act_dpc(name, phone, nation, sex, area, belong, category, position, photo, is_del,
        created_by, created_at, updated_by, updated_at, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.phone}, #{entity.nation}, #{entity.sex}, #{entity.area}, #{entity.belong},
            #{entity.category}, #{entity.position}, #{entity.photo}, #{entity.isDel}, #{entity.createdBy},
            #{entity.createdAt}, #{entity.updatedBy}, #{entity.updatedAt}, #{entity.communityId})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_act_dpc(name, phone, nation, sex, area, belong, category, position, photo, is_del,
        created_by, created_at, updated_by, updated_at, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.phone}, #{entity.nation}, #{entity.sex}, #{entity.area}, #{entity.belong},
            #{entity.category}, #{entity.position}, #{entity.photo}, #{entity.isDel}, #{entity.createdBy},
            #{entity.createdAt}, #{entity.updatedBy}, #{entity.updatedAt}, #{entity.communityId})
        </foreach>
        on duplicate key update
        name = values(name) , phone = values(phone) , nation = values(nation) , sex = values(sex) , area = values(area)
        , belong = values(belong) , category = values(category) , position = values(position) , photo = values(photo) ,
        is_del = values(is_del) , created_by = values(created_by) , created_at = values(created_at) , updated_by =
        values(updated_by) , updated_at = values(updated_at) , community_id = values(community_id)
    </insert>
    <select id="detailDpc" resultType="com.panzhihua.common.model.vos.community.ComActDpcVO">
        SELECT * FROM com_act_dpc WHERE id = #{id}
    </select>
    <select id="pageDpc" resultType="com.panzhihua.common.model.vos.community.ComActDpcVO">
        SELECT * FROM com_act_dpc
        WHERE community_id = #{pageDpcDTO.communityId} AND is_del = 0
        <if test="pageDpcDTO.keyword != null and pageDpcDTO.keyword != &quot;&quot;">
            AND (`name` LIKE CONCAT(#{pageDpcDTO.keyword}, '%')
            OR phone LIKE CONCAT(#{pageDpcDTO.keyword}, '%'))
        </if>
        ORDER BY created_at DESC
    </select>
    <select id="selectUser" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
        SELECT user_id, `name`, phone
        FROM sys_user WHERE `type` = 1 AND phone = #{phone}
    </select>
 
</mapper>