<?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.VolunteerActivityDao">
|
|
<resultMap type="com.panzhihua.service_community.entity.VolunteerActivity" id="VolunteerActivityMap">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="acType" column="ac_type" />
|
<result property="address" column="address" />
|
<result property="volunteerNum" column="volunteer_num" />
|
<result property="acState" column="ac_state" />
|
<result property="awardState" column="award_state" />
|
<result property="issueTime" column="issue_time" />
|
<result property="applyBeginTime" column="apply_begin_time" />
|
<result property="applyEndTime" column="apply_end_time" />
|
<result property="actityBeginTime" column="actity_begin_time" />
|
<result property="actityEndTime" column="actity_end_time" />
|
<result property="communityId" column="community_id" />
|
<result property="volunteerLimit" column="volunteer_limit" />
|
<result property="bonusPoints" column="bonus_points" />
|
<result property="isCancelled" column="is_cancelled" />
|
<result property="contactName" column="contact_name" />
|
<result property="contactPhone" column="contact_phone" />
|
<result property="activityCoverUrl" column="activity_cover_url" />
|
<result property="activityContent" column="activity_content" />
|
<result property="creationTime" column="creation_time" />
|
<result property="updateTime" column="update_time" />
|
<result property="lat" column="lat" />
|
<result property="lng" column="lng" />
|
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultMap="VolunteerActivityMap">
|
select
|
id,
|
name,
|
ac_type,
|
address,
|
(select count(id) from volunteer_activities_people_involved where activity_id=volunteer_activity.id) as volunteer_num,
|
ac_state,
|
(if((select count(id) from volunteer_activities_people_involved
|
where activity_id=volunteer_activity.id and user_id=#{userId})>0,1,0)) as isSign,
|
award_state,
|
issue_time,
|
apply_begin_time,
|
apply_end_time,
|
actity_begin_time,
|
actity_end_time,
|
community_id,
|
volunteer_limit,
|
bonus_points,
|
is_cancelled,
|
contact_name,
|
contact_phone,
|
activity_cover_url,
|
activity_content,
|
creation_time,
|
update_time,
|
lng,
|
lat
|
from volunteer_activity
|
where id= #{id}
|
</select>
|
|
<!-- 分页查询 -->
|
<select id="queryList" resultMap="VolunteerActivityMap">
|
select
|
id,
|
name,
|
ac_type,
|
address,
|
(select count(id) from volunteer_activities_people_involved where activity_id=volunteer_activity.id) as volunteer_num,
|
ac_state,
|
(if((select count(id) from volunteer_activities_people_involved
|
where activity_id=volunteer_activity.id and user_id=#{userId})>0,1,0)) as isSign,
|
award_state,
|
issue_time,
|
apply_begin_time,
|
apply_end_time,
|
actity_begin_time,
|
actity_end_time,
|
community_id,
|
volunteer_limit,
|
bonus_points,
|
is_cancelled,
|
contact_name,
|
contact_phone,
|
activity_cover_url,
|
activity_content,
|
creation_time,
|
update_time,
|
lng,
|
lat
|
from volunteer_activity
|
<where>
|
1=1
|
<if test="name!=null">
|
and (`name` like concat('%',#{name},'%'))
|
</if>
|
<if test="acState!=null">
|
and ac_state =#{acState}
|
</if>
|
<if test="acType!=null">
|
and ac_type =#{acType}
|
</if>
|
<if test="actityBeginTime!=null">
|
and actity_begin_time >= #{actityBeginTime}
|
</if>
|
<if test="actityEndTime!=null">
|
and actity_end_time <![CDATA[ <= ]]> #{actityEndTime}
|
</if>
|
|
</where>
|
order by creation_time desc
|
</select>
|
|
<insert id="insertVolunteer">
|
insert into volunteer_activity
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="volunteerActivityVO.id != null">
|
id,
|
</if>
|
<if test="volunteerActivityVO.name != null">
|
name,
|
</if>
|
<if test="volunteerActivityVO.acType != null">
|
ac_type,
|
</if>
|
<if test="volunteerActivityVO.address != null">
|
address,
|
</if>
|
<if test="volunteerActivityVO.volunteerNum != null">
|
volunteer_num,
|
</if>
|
<if test="volunteerActivityVO.acState != null">
|
ac_state,
|
</if>
|
<if test="volunteerActivityVO.awardState != null">
|
award_state,
|
</if>
|
<if test="volunteerActivityVO.issueTime != null">
|
issue_time,
|
</if>
|
<if test="volunteerActivityVO.applyBeginTime != null">
|
apply_begin_time,
|
</if>
|
<if test="volunteerActivityVO.applyEndTime != null">
|
apply_end_time,
|
</if>
|
<if test="volunteerActivityVO.actityBeginTime != null">
|
actity_begin_time,
|
</if>
|
<if test="volunteerActivityVO.actityEndTime != null">
|
actity_end_time,
|
</if>
|
<if test="volunteerActivityVO.communityId != null">
|
community_id,
|
</if>
|
<if test="volunteerActivityVO.volunteerLimit != null">
|
volunteer_limit,
|
</if>
|
<if test="volunteerActivityVO.bonusPoints != null">
|
bonus_points,
|
</if>
|
<if test="volunteerActivityVO.isCancelled != null">
|
is_cancelled,
|
</if>
|
<if test="volunteerActivityVO.contactName != null">
|
contact_name,
|
</if>
|
<if test="volunteerActivityVO.contactPhone != null">
|
contact_phone,
|
</if>
|
<if test="volunteerActivityVO.activityCoverUrl != null">
|
activity_cover_url,
|
</if>
|
<if test="volunteerActivityVO.activityContent != null">
|
activity_content,
|
</if>
|
<if test="volunteerActivityVO.lng != null">
|
lng,
|
</if>
|
<if test="volunteerActivityVO.lat != null">
|
lat,
|
</if>
|
creation_time
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="volunteerActivityVO.id != null">
|
#{volunteerActivityVO.id},
|
</if>
|
<if test="volunteerActivityVO.name != null">
|
#{volunteerActivityVO.name},
|
</if>
|
<if test="volunteerActivityVO.acType != null">
|
#{volunteerActivityVO.acType},
|
</if>
|
<if test="volunteerActivityVO.address != null">
|
#{volunteerActivityVO.address},
|
</if>
|
<if test="volunteerActivityVO.volunteerNum != null">
|
#{volunteerActivityVO.volunteerNum},
|
</if>
|
<if test="volunteerActivityVO.acState != null">
|
#{volunteerActivityVO.acState},
|
</if>
|
<if test="volunteerActivityVO.awardState != null">
|
#{volunteerActivityVO.awardState},
|
</if>
|
<if test="volunteerActivityVO.issueTime != null">
|
#{volunteerActivityVO.issueTime},
|
</if>
|
<if test="volunteerActivityVO.applyBeginTime != null">
|
#{volunteerActivityVO.applyBeginTime},
|
</if>
|
<if test="volunteerActivityVO.applyEndTime != null">
|
#{volunteerActivityVO.applyEndTime},
|
</if>
|
<if test="volunteerActivityVO.actityBeginTime != null">
|
#{volunteerActivityVO.actityBeginTime},
|
</if>
|
<if test="volunteerActivityVO.actityEndTime != null">
|
#{volunteerActivityVO.actityEndTime},
|
</if>
|
<if test="volunteerActivityVO.communityId != null">
|
#{volunteerActivityVO.communityId},
|
</if>
|
<if test="volunteerActivityVO.volunteerLimit != null">
|
#{volunteerActivityVO.volunteerLimit},
|
</if>
|
<if test="volunteerActivityVO.bonusPoints != null">
|
#{volunteerActivityVO.bonusPoints},
|
</if>
|
<if test="volunteerActivityVO.isCancelled != null">
|
#{volunteerActivityVO.isCancelled},
|
</if>
|
<if test="volunteerActivityVO.contactName != null">
|
#{volunteerActivityVO.contactName},
|
</if>
|
<if test="volunteerActivityVO.contactPhone != null">
|
#{volunteerActivityVO.contactPhone},
|
</if>
|
<if test="volunteerActivityVO.activityCoverUrl != null">
|
#{volunteerActivityVO.activityCoverUrl},
|
</if>
|
<if test="volunteerActivityVO.activityContent != null">
|
#{volunteerActivityVO.activityContent},
|
</if>
|
<if test="volunteerActivityVO.lng != null">
|
#{volunteerActivityVO.lng},
|
</if>
|
<if test="volunteerActivityVO.lat != null">
|
#{volunteerActivityVO.lat},
|
</if>
|
sysdate()
|
</trim>
|
</insert>
|
|
<update id="updateById">
|
update volunteer_activity
|
<set>
|
<if test="volunteerActivityVO.id != null">
|
id=#{volunteerActivityVO.id},
|
</if>
|
<if test="volunteerActivityVO.name != null">
|
name=#{volunteerActivityVO.name},
|
</if>
|
<if test="volunteerActivityVO.acType != null">
|
ac_type=#{volunteerActivityVO.acType},
|
</if>
|
<if test="volunteerActivityVO.address != null">
|
address=#{volunteerActivityVO.address},
|
</if>
|
<if test="volunteerActivityVO.volunteerNum != null">
|
volunteer_num=#{volunteerActivityVO.volunteerNum},
|
</if>
|
<if test="volunteerActivityVO.acState != null">
|
ac_state=#{volunteerActivityVO.acState},
|
</if>
|
<if test="volunteerActivityVO.awardState != null">
|
award_state=#{volunteerActivityVO.awardState},
|
</if>
|
<if test="volunteerActivityVO.issueTime != null">
|
issue_time=#{volunteerActivityVO.issueTime},
|
</if>
|
<if test="volunteerActivityVO.applyBeginTime != null">
|
apply_begin_time=#{volunteerActivityVO.applyBeginTime},
|
</if>
|
<if test="volunteerActivityVO.applyEndTime != null">
|
apply_end_time=#{volunteerActivityVO.applyEndTime},
|
</if>
|
<if test="volunteerActivityVO.actityBeginTime != null">
|
actity_begin_time=#{volunteerActivityVO.actityBeginTime},
|
</if>
|
<if test="volunteerActivityVO.actityEndTime != null">
|
actity_end_time=#{volunteerActivityVO.actityEndTime},
|
</if>
|
<if test="volunteerActivityVO.communityId != null">
|
community_id=#{volunteerActivityVO.communityId},
|
</if>
|
<if test="volunteerActivityVO.volunteerLimit != null">
|
volunteer_limit=#{volunteerActivityVO.volunteerLimit},
|
</if>
|
<if test="volunteerActivityVO.bonusPoints != null">
|
bonus_points=#{volunteerActivityVO.bonusPoints},
|
</if>
|
<if test="volunteerActivityVO.isCancelled != null">
|
is_cancelled=#{volunteerActivityVO.isCancelled},
|
</if>
|
<if test="volunteerActivityVO.contactName != null">
|
contact_name=#{volunteerActivityVO.contactName},
|
</if>
|
<if test="volunteerActivityVO.contactPhone != null">
|
contact_phone=#{volunteerActivityVO.contactPhone},
|
</if>
|
<if test="volunteerActivityVO.activityCoverUrl != null">
|
activity_cover_url=#{volunteerActivityVO.activityCoverUrl},
|
</if>
|
<if test="volunteerActivityVO.activityContent != null">
|
activity_content=#{volunteerActivityVO.activityContent},
|
</if>
|
<if test="volunteerActivityVO.lng != null">
|
lng=#{volunteerActivityVO.lng},
|
</if>
|
<if test="volunteerActivityVO.lat != null">
|
lat=#{volunteerActivityVO.lat},
|
</if>
|
update_time=sysdate()
|
</set>
|
where id = #{volunteerActivityVO.id}
|
|
</update>
|
|
|
<delete id="deleteById" parameterType="String">
|
delete from volunteer_activity where id=#{id}
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="timedTaskList" resultMap="VolunteerActivityMap">
|
select
|
id,
|
ac_state,
|
(select count(id) from volunteer_activities_people_involved where activity_id=volunteer_activity.id) volunteer_num,
|
apply_begin_time,
|
apply_end_time,
|
actity_begin_time,
|
actity_end_time
|
from volunteer_activity
|
where ac_state in (2,3,4)
|
</select>
|
|
|
|
|
</mapper>
|