huanghongfa
2020-12-10 f76377ffd111434d90c5aaf5507cd33a982d4aa6
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.panzhihua.service_community.dao;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.vos.community.ComActActivityVO;
import com.panzhihua.common.model.vos.partybuilding.PageActivityMembersVO;
import com.panzhihua.service_community.model.dos.ComActActivityDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 社区活动
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-12-07 13:59
 **/
@Mapper
public interface ComActActivityDAO extends BaseMapper<ComActActivityDO> {
    //    @Select("<script> " +
//            " <where>" +
//            "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
//            " </if> " +
//            "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
//            " </if> " +
//            "<if test='nameCn != null and nameCn.trim() != &quot;&quot;'>" +
//            " </if> " +
//            " </where>" +
//            "</script>")
    @Select("<script> " +
            "SELECT \n" +
            "a.id,\n" +
            "a.activity_name,\n" +
            "u.`name` sponsorName,\n" +
            "a.activity_addr,\n" +
            "a.`status`,\n" +
            "a.publish_at,\n" +
            "a.begin_at,\n" +
            "a.end_at,\n" +
            "a.volunteer_max,\n" +
            "count(if(s.is_volunteer=1,s.id,null))volunteer_now,\n"+
            "count(if(s.is_volunteer=0,s.id,null))participant_now,\n"+
            "a.participant_max,\n" +
            "a.sign_up_begin,\n" +
            "a.sign_up_end\n" +
            "FROM\n" +
            "com_act_activity a \n" +
            "join sys_user u on a.sponsor_id=u.user_id\n" +
            "left join com_act_act_sign s on a.id=s.activity_id \n"+
            " where a.community_id=#{comActActivityVO.communityId}" +
            "<if test='comActActivityVO.activityName != null and comActActivityVO.activityName.trim() != &quot;&quot;'>" +
            " and a.activity_name = #{comActActivityVO.activityName} \n" +
            " </if> " +
            "<if test='comActActivityVO.status != null and comActActivityVO.status !=0'>" +
            "AND a.`status` = #{comActActivityVO.status} \n" +
            " </if> " +
            "<if test='comActActivityVO.beginAt != null and comActActivityVO.beginAt.trim() != &quot;&quot;'>" +
            "AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt} \n" +
            " </if> " +
            " group by a.id "+
            "</script>")
    IPage<ComActActivityVO> pageActivity( Page page, @Param("comActActivityVO") ComActActivityVO comActActivityVO);
 
    @Select("SELECT \n" +
            "u.name sponsorName,\n" +
            "count(if(s.is_volunteer=1,s.id,null))volunteer_now,\n"+
            "count(if(s.is_volunteer=0,s.id,null))participant_now,\n"+
            "a.* \n" +
            "FROM \n" +
            "com_act_activity a \n" +
            "join sys_user u on a.sponsor_id=u.user_id \n"+
            "left join com_act_act_sign s on a.id=s.activity_id \n"+
            "where a.id=#{id} \n"+
            " group by a.id "
    )
    ComActActivityVO inforActivity(Long id);
 
    @Select("SELECT\n" +
            "a.* \n" +
            "FROM\n" +
            "com_act_act_sign s\n" +
            "JOIN com_act_activity a ON s.activity_id = a.id \n" +
            "WHERE\n" +
            "s.user_id = #{comActActivityVO.sponsorId} \n" +
            "ORDER BY\n" +
            "s.create_at DESC")
    IPage<ComActActivityVO> pageMyActivity(Page page, @Param("comActActivityVO") ComActActivityVO comActActivityVO);
}