榆山
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

207 lines
8.1 KiB

<?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.elink.esua.epdc.dao.VolunteerInfoDao">
<resultMap type="com.elink.esua.epdc.entity.VolunteerInfoEntity" id="volunteerInfoMap">
<result property="id" column="ID"/>
<result property="userId" column="USER_ID"/>
<result property="realName" column="REAL_NAME"/>
<result property="sex" column="SEX"/>
<result property="birthday" column="BIRTHDAY"/>
<result property="mobile" column="MOBILE"/>
<result property="identityNo" column="IDENTITY_NO"/>
<result property="kindnessTime" column="KINDNESS_TIME"/>
<result property="participationNum" column="PARTICIPATION_NUM"/>
<result property="points" column="POINTS"/>
<result property="gridId" column="GRID_ID"/>
<result property="parentDeptIds" column="PARENT_DEPT_IDS"/>
<result property="parentDeptNames" column="PARENT_DEPT_NAMES"/>
<result property="allDeptIds" column="ALL_DEPT_IDS"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="road" column="ROAD"/>
<result property="villageName" column="VILLAGE_NAME"/>
<result property="dwellingPlace" column="DWELLING_PLACE"/>
<result property="address" column="ADDRESS"/>
<result property="introduce" column="INTRODUCE"/>
<result property="registTime" column="REGIST_TIME"/>
<result property="auditStatus" column="AUDIT_STATUS"/>
<result property="failureReason" column="FAILURE_REASON"/>
<result property="auditTime" column="AUDIT_TIME"/>
<result property="auditor" column="AUDITOR"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!--根据查询条件,返回首页 志愿者信息列表-->
<select id="volunteerInfoList" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
SELECT
v.ID id,
v.USER_ID userId,
v.REAL_NAME realName,
v.SEX sex,
v.BIRTHDAY birthday,
date_format(v.BIRTHDAY,'%Y.%m.%d') birthdayString,
v.MOBILE mobile,
v.IDENTITY_NO identityNo,
v.KINDNESS_TIME kindnessTime,
u.POINTS points,
date_format(v.REGIST_TIME,'%Y.%m.%d %H.%i') registTimeString,
v.REGIST_TIME registTime,
v.AUDIT_STATUS auditStatus
FROM
epdc_volunteer_info v
left join epdc_user u on v.USER_ID = u.ID and u.del_flag = '0'
where v.del_flag = '0' and u.id is not null
<if test="realName !='' and realName.trim() != null">
and v.REAL_NAME = trim(#{realName})
</if>
<if test="mobile !='' and mobile.trim() != null">
and v.MOBILE = trim(#{mobile})
</if>
<if test="deptId !='' and deptId != null">
and v.ALL_DEPT_IDS like concat('%',#{deptId},'%')
</if>
ORDER BY v.CREATED_TIME DESC
</select>
<select id="volunteerInfoCount" resultType="int">
SELECT
count(1)
FROM
epdc_volunteer_info v left join epdc_user u on v.USER_ID = u.ID
where 1=1
<if test="realName !='' and realName != null">
and v.REAL_NAME = #{realName}
</if>
<if test="mobile !='' and mobile != null">
and v.MOBILE = #{mobile}
</if>
<if test="allDeptIds !='' and allDeptIds != null">
and v.ALL_DEPT_IDS like concat('%',#{allDeptIds},'%')
</if>
</select>
<!--根据志愿者id,查询志愿者 单条详情-->
<select id="getVolunteerDetail" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
SELECT
v.ID id,
v.USER_ID userId,
v.REAL_NAME realName,
v.SEX sex,
v.BIRTHDAY birthday,
date_format(v.BIRTHDAY,'%Y.%m.%d') birthdayString,
v.MOBILE mobile,
v.IDENTITY_NO identityNo,
v.ADDRESS address,
v.INTRODUCE introduce,
u.POINTS points,
date_format(v.REGIST_TIME,'%Y.%m.%d %H.%i') registTimeString,
v.REGIST_TIME registTime
FROM
epdc_volunteer_info v left join epdc_user u on v.USER_ID = u.ID
where v.ID = #{id}
</select>
<select id="getVolunteerUserDefaultValue" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
SELECT
eu.ID userId,
eu.REAL_NAME realName,
eu.MOBILE mobile,
eu.IDENTITY_NO identityNo,
eugr.GRID_ID gridId,
eu.PARENT_DEPT_IDS parentDeptIds,
eu.PARENT_DEPT_NAMES parentDeptNames,
eu.ALL_DEPT_IDS allDeptIds,
eu.ALL_DEPT_NAMES allDeptNames,
eu.ROAD road,
eu.VILLAGE_NAME villageName,
eu.DWELLING_PLACE dwellingPlace,
eu.ADDRESS address
FROM
epdc_user eu
Left Join (select * from epdc_user_grid_relation where USER_ID = #{id} order by UPDATED_TIME desc limit 0,1) eugr
on(eu.id=eugr.USER_ID)
WHERE
eu.ID = #{id}
</select>
<select id="volunteerTagQuery" resultType="com.elink.esua.epdc.dto.UserTagDTO">
select t.id,t.tag_name,t.tag_code
from epdc_user_tag t
where tag_code = #{tagCode} and del_flag = 0
</select>
<update id="updateVolunteerInfo" parameterType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
UPDATE epdc_volunteer_info
SET
UPDATED_BY = #{updatedBy}
,UPDATED_TIME = #{updatedTime}
,AUDIT_STATUS = #{auditStatus}
,FAILURE_REASON = #{failureReason}
,AUDIT_TIME = #{auditTime}
,AUDITOR = #{auditor}
WHERE ID = #{id}
</update>
<select id="getVolunteerCountById" resultType="Integer">
SELECT count(*) countNum FROM `epdc_volunteer_info` where del_flag = '0' and USER_ID = #{userId} and AUDIT_STATUS in ('1','0')
</select>
<select id="selectAdjustVolunteerPointsDTO" parameterType="java.lang.String" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO">
SELECT
m.id,
m.USER_ID as userId,
m.REAL_NAME as realName,
m.SEX,
DATE_FORMAT(m.BIRTHDAY,'%Y-%m-%d') as birthday,
m.MOBILE,
eu.POINTS
FROM
epdc_volunteer_info m
LEFT JOIN epdc_user eu ON ( m.USER_ID = eu.ID )
WHERE
m.DEL_FLAG = '0'
AND m.ID = #{id}
</select>
<select id="getRankingList" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO">
select volunteerInfo.* from (
select (@i:=@i+1) sort, info.*
from (select
'1' show_flag,
DATE_FORMAT(NOW(),'%Y-%m-%d') generate_date,
vi.ID volunteer_id,
vi.USER_ID,
eu.FACE_IMG,
eu.NICKNAME,
eu.PARTY_FLAG,
vi.KINDNESS_TIME,
vi.PARTICIPATION_NUM
from epdc_volunteer_info vi
left join epdc_user eu on eu.id = vi.USER_ID
WHERE vi.DEL_FLAG = '0' AND vi.AUDIT_STATUS = '1'
order by vi.KINDNESS_TIME desc,vi.PARTICIPATION_NUM desc,vi.REGIST_TIME ) as info, (select @i:=0) j ) volunteerInfo
where sort &lt; 11
</select>
<!-- 根据用户id查询志愿者信息 -->
<select id="selectOneVolunteerInfoDTO" parameterType="java.lang.String"
resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
select *
from epdc_volunteer_info m
where m.DEL_FLAG='0'
and m.USER_ID=#{userId}
</select>
<update id="updateVolunteerKindnessTime">
UPDATE epdc_volunteer_info
SET KINDNESS_TIME = ( KINDNESS_TIME + #{kindnessTime} ),
PARTICIPATION_NUM = ( PARTICIPATION_NUM + 1 )
WHERE
USER_ID = #{userId}
AND DEL_FLAG = '0'
</update>
</mapper>