mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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>
    <insert id="insertComActDpc">
        insert into com_act_dpc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="comActDpc.id != null">
                id,
            </if>
            <if test="comActDpc.name != null and comActDpc.name != ''">
                name,
            </if>
            <if test="comActDpc.phone != null and comActDpc.phone != ''">
                phone,
            </if>
            <if test="comActDpc.nation != null and comActDpc.nation != ''">
            nation,
            </if>
            <if test="comActDpc.sex != null">
                sex,
            </if>
            <if test="comActDpc.area != null and comActDpc.area != ''">
                area,
            </if>
            <if test="comActDpc.belong != null and comActDpc.belong != ''">
                belong,
            </if>
            <if test="comActDpc.category != null and comActDpc.category != ''">
                category,
            </if>
            <if test="comActDpc.position != null and comActDpc.position != ''">
                position,
            </if>
            <if test="comActDpc.photo != null and comActDpc.photo != ''">
                photo,
            </if>
            <if test="comActDpc.communityId != null">
                community_id,
            </if>
            <if test="comActDpc.createdBy != null ">
                created_by,
            </if>
            <if test="comActDpc.createdAt != null ">
                created_at,
            </if>
        </trim>
        values
        <trim prefix="("  suffix=")" suffixOverrides=",">
            <if test="comActDpc.id != null">
                #{comActDpc.id},
            </if>
            <if test="comActDpc.name != null and comActDpc.name != ''">
                #{comActDpc.name},
            </if>
            <if test="comActDpc.phone != null and comActDpc.phone != ''">
                #{comActDpc.phone},
            </if>
            <if test="comActDpc.nation != null and comActDpc.nation != ''">
              #{comActDpc.nation},
            </if>
            <if test="comActDpc.sex != null">
                #{comActDpc.sex},
            </if>
            <if test="comActDpc.area != null and comActDpc.area != ''">
                #{comActDpc.area},
            </if>
            <if test="comActDpc.belong != null and comActDpc.belong != ''">
                #{comActDpc.belong},
            </if>
            <if test="comActDpc.category != null and comActDpc.category != ''">
                #{comActDpc.category},
            </if>
            <if test="comActDpc.position != null and comActDpc.position != ''">
                #{comActDpc.position},
            </if>
            <if test="comActDpc.photo != null and comActDpc.photo != ''">
                #{comActDpc.photo},
            </if>
            <if test="comActDpc.communityId != null ">
                #{comActDpc.communityId},
            </if>
            <if test="comActDpc.createdBy != null ">
                #{comActDpc.createdBy},
            </if>
            <if test="comActDpc.createdAt != null ">
                #{comActDpc.createdAt},
            </if>
        </trim>
    </insert>
 
</mapper>