2021-12-21 19:01:18 +08:00
<?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.xhpc.user.mapper.XhpcCommunityMapper" >
<resultMap type= "com.xhpc.user.domain.XhpcCommunity" id= "XhpcCommunityResult" >
<result column= "community_id" property= "communityId" />
<result column= "name" property= "name" />
<result column= "service_preferential" property= "servicePreferential" />
<result column= "min_people" property= "minPeople" />
<result column= "contact_name" property= "contactName" />
<result column= "contact_phone" property= "contactPhone" />
<result column= "address" property= "address" />
<result column= "parent_id" property= "parentId" />
<result column= "type" property= "type" />
<result column= "dimension" property= "dimension" />
<result column= "status" property= "status" />
<result column= "del_flag" property= "delFlag" />
<result column= "create_by" property= "createBy" />
<result column= "create_time" property= "createTime" />
<result column= "update_by" property= "updateBy" />
<result column= "update_time" property= "updateTime" />
<result column= "remark" property= "remark" />
</resultMap>
<select id= "getLandUser" resultType= "map" >
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<select id= "list" resultType= "map" >
select
community_id as communityId,
name as name
from xhpc_community
2021-12-22 12:33:59 +08:00
where del_flag =0
2021-12-21 19:01:18 +08:00
<if test= "name !=null and name !=''" >
and name like CONCAT('%',#{name},'%')
</if>
</select>
<insert id= "addCommunity" parameterType= "com.xhpc.user.domain.XhpcCommunity" useGeneratedKeys= "true" keyProperty= "communityId" >
insert into xhpc_community
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != communityId" >
community_id,
</if>
<if test= "null != name and '' != name" >
name,
</if>
<if test= "null != servicePreferential" >
service_preferential,
</if>
<if test= "null != minPeople" >
min_people,
</if>
<if test= "null != contactName and '' != contactName" >
contact_name,
</if>
<if test= "null != contactPhone and '' != contactPhone" >
contact_phone,
</if>
<if test= "null != address and '' != address" >
address,
</if>
<if test= "null != dimension" >
dimension,
</if>
2021-12-22 12:33:59 +08:00
<if test= "null != status " >
status,
</if>
2021-12-21 19:01:18 +08:00
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != createBy and '' != createBy" >
create_by,
</if>
<if test= "null != updateTime " >
update_time,
</if>
<if test= "null != updateBy and '' != updateBy" >
update_by,
</if>
<if test= "null != remark and '' != remark" >
remark,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != communityId" >
#{communityId},
</if>
<if test= "null != name and '' != name" >
#{name},
</if>
<if test= "null != servicePreferential" >
#{servicePreferential},
</if>
<if test= "null != minPeople" >
#{minPeople},
</if>
<if test= "null != contactName and '' != contactName" >
#{contactName},
</if>
<if test= "null != contactPhone and '' != contactPhone" >
#{contactPhone},
</if>
<if test= "null != address and '' != address" >
#{address},
</if>
<if test= "null != dimension" >
#{dimension},
</if>
2021-12-22 12:33:59 +08:00
<if test= "null != status " >
#{status},
</if>
2021-12-21 19:01:18 +08:00
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != createBy and '' != createBy" >
#{createBy},
</if>
<if test= "null != updateTime " >
#{updateTime},
</if>
<if test= "null != updateBy and '' != updateBy" >
#{updateBy},
</if>
<if test= "null != remark and '' != remark" >
#{remark},
</if>
</trim>
</insert>
2021-12-22 12:33:59 +08:00
<update id= "updateCommunity" parameterType= "com.xhpc.user.domain.XhpcCommunity" useGeneratedKeys= "true" keyProperty= "communityId" >
update xhpc_community
<trim prefix= "SET" suffixOverrides= "," >
<if test= "name != null" > name = #{name},</if>
<if test= "servicePreferential != null" > service_preferential = #{servicePreferential},</if>
<if test= "minPeople != null" > min_people = #{minPeople},</if>
<if test= "contactName != null" > contact_name = #{contactName},</if>
<if test= "contactPhone != null" > contact_phone = #{contactPhone},</if>
<if test= "address != null" > address = #{address},</if>
<if test= "dimension != null" > address = #{dimension},</if>
<if test= "status != null" > address = #{status},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "remark != null" > remark = #{remark},</if>
</trim>
where community_id=#{communityId}
</update>
2021-12-21 19:01:18 +08:00
<update id= "deleteCommunity" >
update xhpc_community set del_flag =1 where community_id=#{communityId}
</update>
<select id= "countCommunityPersonnel" resultType= "java.lang.Integer" >
2021-12-22 18:06:36 +08:00
select count(community_personnel_id) from xhpc_community_personnel where community_id=#{communityId} and del_flag=0
2021-12-21 19:01:18 +08:00
</select>
2021-12-22 12:33:59 +08:00
<select id= "getCommunityById" resultType= "map" >
select
co.community_id as communityId,
co.name as name,
co.service_preferential as servicePreferential,
co.min_people as minPeople,
co.contact_name as contactName,
co.contact_phone as contactPhone,
co.address as address,
co.dimension as dimension,
co.status as status,
group_concat(me.charging_station_id) chargingStationIds
from xhpc_community co
2021-12-22 18:06:36 +08:00
left join xhpc_mechanism me on me.mechanism_id = co.community_id and me.source = 0 and me.del_flag =0
2021-12-22 12:33:59 +08:00
where 1=1
<if test= "communityId !=null and type !=null and type==1" >
and co.community_id=#{communityId}
</if>
<if test= "communityId !=null and type !=null and type==2" >
and co.community_id !=#{communityId}
</if>
<if test= "name !=null" >
and co.name =#{name}
</if>
limit 1
</select>
2021-12-22 18:06:36 +08:00
<select id= "communityPersonnelList" resultType= "map" >
SELECT
community_personnel_id AS communityPersonnelId,
name AS name,
community_id AS communityId,
account AS account,
phone AS phone,
recharge_money AS rechargeMoney,
consume_money AS consumeMoney,
red_packet AS redPacket,
surplus_money AS surplusMoney,
type,
status
FROM
xhpc_community_personnel
where community_id=#{communityId} and del_flag=0
<if test= "account !=null and account !=''" >
2021-12-27 15:45:06 +08:00
and account like concat('%', #{account), '%')
2021-12-22 18:06:36 +08:00
</if>
<if test= "phone !=null and phone !=''" >
2021-12-27 15:45:06 +08:00
and phone like concat('%', #{phone}, '%')
2021-12-22 18:06:36 +08:00
</if>
<if test= "status !=null" >
and status=#{status}
</if>
</select>
<insert id= "addCommunityPersonnel" parameterType= "com.xhpc.user.domain.XhpcCommunityPersonnel" useGeneratedKeys= "true" keyProperty= "communityPersonnelId" >
insert into xhpc_community_personnel
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != communityPersonnelId" >
community_personnel_id,
</if>
<if test= "null != communityId" >
community_id,
</if>
<if test= "null != name and '' != name" >
name,
</if>
<if test= "null != account" >
account,
</if>
<if test= "null != rechargeMoney" >
recharge_money,
</if>
<if test= "null != consumeMoney" >
consume_money,
</if>
<if test= "null != redPacket" >
red_packet,
</if>
<if test= "null != surplusMoney" >
surplus_money,
</if>
<if test= "null != phone" >
phone,
</if>
<if test= "null != type" >
type,
</if>
<if test= "null != status " >
status,
</if>
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != createBy and '' != createBy" >
create_by,
</if>
<if test= "null != updateTime " >
update_time,
</if>
<if test= "null != updateBy and '' != updateBy" >
update_by,
</if>
<if test= "null != remark and '' != remark" >
remark,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != communityPersonnelId" >
#{communityPersonnelId},
</if>
<if test= "null != communityId" >
#{communityId},
</if>
<if test= "null != name and '' != name" >
#{name},
</if>
<if test= "null != account" >
#{account},
</if>
<if test= "null != rechargeMoney" >
#{rechargeMoney},
</if>
<if test= "null != consumeMoney" >
#{consumeMoney},
</if>
<if test= "null != redPacket" >
#{redPacket},
</if>
<if test= "null != surplusMoney" >
#{surplusMoney},
</if>
<if test= "null != phone" >
#{phone},
</if>
<if test= "null != type" >
#{type},
</if>
<if test= "null != status " >
#{status},
</if>
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != createBy and '' != createBy" >
#{createBy},
</if>
<if test= "null != updateTime " >
#{updateTime},
</if>
<if test= "null != updateBy and '' != updateBy" >
#{updateBy},
</if>
<if test= "null != remark and '' != remark" >
#{remark},
</if>
</trim>
</insert>
<select id= "getCommunityPersonnelById" resultType= "map" >
select
community_personnel_id AS communityPersonnelId,
name AS name,
community_id AS communityId,
account AS account,
phone AS phone,
recharge_money AS rechargeMoney,
2021-12-23 18:22:42 +08:00
surplus_money AS surplusMoney,
2021-12-22 18:06:36 +08:00
type,
status
from xhpc_community_personnel
where del_flag =0
<if test= "communityPersonnelId !=null and type !=null and type==1" >
and community_personnel_id=#{communityPersonnelId}
</if>
<if test= "type !=null and type==3" >
and phone =#{phone} or account =#{account}
</if>
<if test= "communityPersonnelId !=null and type !=null and type==2" >
and community_personnel_id !=#{communityPersonnelId}
and community_personnel_id in ( select community_personnel_id from xhpc_community_personnel where phone =#{phone} or account =#{account} and del_flag =0)
</if>
limit 1
</select>
<update id= "updateCommunityPersonnel" >
update xhpc_community_personnel
<trim prefix= "SET" suffixOverrides= "," >
<if test= "communityId != null" > community_id = #{communityId},</if>
<if test= "name != null" > name = #{name},</if>
<if test= "account != null" > account = #{account},</if>
<if test= "phone != null" > phone = #{phone},</if>
2021-12-23 18:22:42 +08:00
<if test= "rechargeMoney != null" > recharge_money = #{rechargeMoney},</if>
<if test= "surplusMoney != null" > surplus_money = #{surplusMoney},</if>
2021-12-22 18:06:36 +08:00
<if test= "type != null" > type = #{type},</if>
<if test= "status != null" > address = #{status},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "remark != null" > remark = #{remark},</if>
</trim>
where community_personnel_id=#{communityPersonnelId}
</update>
<update id= "deleteCommunityPersonnel" >
update xhpc_community_personnel set del_flag=1 where community_personnel_id=#{communityPersonnelId}
</update>
<update id= "updateCommunityPersonnelStatus" >
update xhpc_community_personnel set status=#{status} where community_personnel_id=#{communityPersonnelId}
</update>
2021-12-21 19:01:18 +08:00
</mapper>