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
<?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.ComFmsTeamDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.ComFmsTeam" id="ComFmsTeamMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
        <result property="teamType" column="team_type" 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"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
        <result property="image" column="image" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_fms_team(name, phone, team_type, created_at, created_by, updated_at, updated_by, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.name}, #{entity.phone}, #{entity.teamType}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_fms_team(name, phone, team_type, created_at, created_by, updated_at, updated_by, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.phone}, #{entity.teamType}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
        </foreach>
        on duplicate key update
         name = values(name) , phone = values(phone) , team_type = values(team_type) , created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by) , community_id = values(community_id)     </insert>
    <select id="pageFmsTeamApplets" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamVO">
        SELECT id, `name`, phone, team_type, image
        FROM com_fms_team
        WHERE community_id = #{pageFmsTeamDTO.communityId}
        <if test="pageFmsTeamDTO.teamType != null">
            AND team_type = #{pageFmsTeamDTO.teamType}
        </if>
        <if test="pageFmsTeamDTO.keyword != null and pageFmsTeamDTO.keyword != &quot;&quot;">
            AND `name` LIKE CONCAT('%',#{pageFmsTeamDTO.keyword},'%')
        </if>
        ORDER BY created_at DESC
    </select>
    <select id="listFmsTeamApplets" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamVO">
        SELECT id, `name`, phone, team_type, image
        FROM com_fms_team
        WHERE community_id = #{pageFmsTeamDTO.communityId}
        <if test="pageFmsTeamDTO.teamType != null">
            AND team_type = #{pageFmsTeamDTO.teamType}
        </if>
        <if test="pageFmsTeamDTO.keyword != null and pageFmsTeamDTO.keyword != &quot;&quot;">
            AND `name` LIKE CONCAT('%',#{pageFmsTeamDTO.keyword},'%')
        </if>
        ORDER BY created_at DESC
    </select>
 
</mapper>