<?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.ComFmsTeamMemberDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComFmsTeamMember" id="ComFmsTeamMemberMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="idCard" column="id_card" jdbcType="VARCHAR"/>
|
<result property="communityId" column="community_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"/>
|
<result property="cascadeIds" column="cascade_ids" jdbcType="VARCHAR"/>
|
<result property="gender" column="gender" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_team_member(name, phone, id_card, community_id, created_at, created_by, updated_at, updated_by, cascade_ids, gender)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.phone}, #{entity.idCard}, #{entity.communityId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.cascadeIds}, #{entity.gender})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_team_member(name, phone, id_card, community_id, created_at, created_by, updated_at, updated_by, cascade_ids, gender)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.phone}, #{entity.idCard}, #{entity.communityId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.cascadeIds}, #{entity.gender})
|
</foreach>
|
on duplicate key update
|
name = values(name) , phone = values(phone) , id_card = values(id_card) , community_id = values(community_id) , created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by) , cascade_ids = values(cascade_ids) , gender = values(gender) </insert>
|
|
<select id="pageFmsTeamMember"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamMemberVO">
|
SELECT t2.id, t2.`name`, t2.phone, t2.id_card, t2.gender, t2.cascade_ids, t3.team_type, t4.`name` AS teamTypeName, t3.`name` AS teamName
|
FROM com_fms_team_member_relation t1
|
INNER JOIN com_fms_team_member t2 ON t1.member_id = t2.id
|
LEFT JOIN com_fms_team t3 ON t1.team_id = t3.id
|
LEFT JOIN com_fms_team_type t4 ON t3.team_type = t4.id
|
WHERE t2.community_id = #{pageTeamMemberDTO.communityId}
|
<if test="pageTeamMemberDTO.teamType != null">
|
AND t3.team_type = #{pageTeamMemberDTO.teamType}
|
</if>
|
<if test="pageTeamMemberDTO.teamId != null">
|
AND t1.team_id = #{pageTeamMemberDTO.teamId}
|
</if>
|
<if test="pageTeamMemberDTO.gender != null">
|
AND t2.gender = #{pageTeamMemberDTO.gender}
|
</if>
|
<if test="pageTeamMemberDTO.keyword != null and pageTeamMemberDTO.keyword != """>
|
AND (t3.`name` LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%')
|
OR t2.`name` LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%')
|
OR t2.phone LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%'))
|
</if>
|
ORDER BY t2.created_at DESC
|
</select>
|
<select id="countMember" resultType="java.lang.Integer">
|
SELECT COUNT(id) FROM com_fms_team_member
|
WHERE community_id = #{communityId} AND (phone = #{phone}
|
<if test="idCard != null and idCard != """>
|
OR id_card = #{idCard}
|
</if>
|
)
|
</select>
|
<select id="statisticsFmsTeamMember"
|
resultType="com.panzhihua.common.model.vos.community.fms.TeamMemberTopStatisticsVO">
|
SELECT
|
(SELECT COUNT(id) FROM com_fms_team where community_id = #{communityId}) AS teamCount,
|
(SELECT COUNT(id) FROM com_fms_team_member where community_id = #{communityId}) AS memberCount
|
</select>
|
<select id="exportTeamMember"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamMemberExportExcelVO">
|
SELECT t4.`name` AS teamType, t3.`name` AS teamName, t2.`name` AS teamMember, t2.id_card, t2.phone,
|
CASE
|
WHEN t2.gender = 1 THEN
|
'男'
|
WHEN t2.gender = 2 THEN
|
'女'
|
ELSE '未知'
|
END gender
|
FROM com_fms_team_member_relation t1
|
INNER JOIN com_fms_team_member t2 ON t1.member_id = t2.id
|
LEFT JOIN com_fms_team t3 ON t1.team_id = t3.id
|
LEFT JOIN com_fms_team_type t4 ON t3.team_type = t4.id
|
WHERE t2.community_id = #{pageTeamMemberDTO.communityId}
|
<if test="pageTeamMemberDTO.teamType != null">
|
AND t3.team_type = #{pageTeamMemberDTO.teamType}
|
</if>
|
<if test="pageTeamMemberDTO.teamId != null">
|
AND t1.team_id = #{pageTeamMemberDTO.teamId}
|
</if>
|
<if test="pageTeamMemberDTO.gender != null">
|
AND t2.gender = #{pageTeamMemberDTO.gender}
|
</if>
|
<if test="pageTeamMemberDTO.keyword != null and pageTeamMemberDTO.keyword != """>
|
AND (t3.`name` LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%')
|
OR t2.`name` LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%')
|
OR t2.phone LIKE CONCAT('%',#{pageTeamMemberDTO.keyword},'%'))
|
</if>
|
ORDER BY t2.created_at DESC
|
</select>
|
<select id="selectListByCommunityId"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamMemberVO">
|
SELECT t2.id, t1.team_id, t2.`name`
|
FROM com_fms_team_member_relation t1
|
INNER JOIN com_fms_team_member t2 ON t1.member_id = t2.id
|
WHERE t2.community_id = #{communityId}
|
</select>
|
<select id="selectVOListByTeamId"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamMemberVO">
|
SELECT id, t2.`name`, t2.gender
|
FROM com_fms_team_member_relation t1
|
INNER JOIN com_fms_team_member t2 ON t1.member_id = t2.id
|
WHERE t1.team_id = #{teamId}
|
</select>
|
|
</mapper>
|