huanghongfa
2021-01-23 7d9fc9634ad84a6ea1336c64ed13321c45aa8c7a
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
90
91
92
93
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.dtos.community.PageComActDiscussCommentDTO;
import com.panzhihua.common.model.dtos.community.PageComActDiscussDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.community.ComActDiscussCommentVO;
import com.panzhihua.common.model.vos.community.ComActDiscussVO;
import com.panzhihua.service_community.model.dos.ComActDiscussDO;
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: 2021-01-22 14:49
 **/
@Mapper
public interface ComActDiscussDAO extends BaseMapper<ComActDiscussDO> {
    //    @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("select type,name,phone from sys_user where user_id=#{userId}")
    LoginUserInfoVO selectUserByUserId(Long userId);
    @Select("<script> " +
            "select t.* from ("+
            "SELECT\n" +
            "d.id,\n" +
            "d.`discuss_subject`,\n" +
            "d.type,\n" +
            "COUNT( c.id ) commentNum,\n" +
            "u.name userName,\n" +
            "d.create_at \n" +
            "FROM\n" +
            "com_act_discuss d\n" +
            "JOIN sys_user u ON d.user_id = u.user_id\n" +
            "LEFT JOIN com_act_discuss_comment c ON d.id = c.discuss_id \n" +
            " where d.community_id=#{pageComActDiscussDTO.communityId}" +
            "<if test='pageComActDiscussDTO.subject != null and pageComActDiscussDTO.subject.trim() != &quot;&quot;'>" +
            " and d.`discuss_subject` LIKE concat( #{pageComActDiscussDTO.subject}, '%' ) \n" +
            " </if> " +
            "<if test='pageComActDiscussDTO.begin != null '>" +
            "AND d.create_at BETWEEN #{pageComActDiscussDTO.begin} \n" +
            "AND #{pageComActDiscussDTO.end} \n" +
            " </if> " +
            "GROUP BY\n" +
            "d.id" +
            ")t order by t.commentNum desc ,t.create_at desc "+
            "</script>")
    IPage<ComActDiscussVO> pageDiscuss(Page page, @Param("pageComActDiscussDTO") PageComActDiscussDTO pageComActDiscussDTO);
 
    @Select("<script> " +
            "select * from ("+
            "SELECT\n" +
            "u.`name` userName,\n" +
            "u.phone,\n" +
            "c.`comment`,\n" +
            "COUNT( cu.id ) num,\n" +
            "c.create_at,\n" +
            "c.id \n" +
            "FROM\n" +
            "com_act_discuss_comment c\n" +
            "JOIN sys_user u ON c.user_id = u.user_id \n" +
            "<if test='pageComActDiscussCommentDTO.name != null and pageComActDiscussCommentDTO.name.trim() != &quot;&quot;'>" +
            "AND u.`name` LIKE concat( #{pageComActDiscussCommentDTO.name}, '%' ) \n" +
            " </if> " +
            "<if test='pageComActDiscussCommentDTO.account != null and pageComActDiscussCommentDTO.account.trim() != &quot;&quot;'>" +
            "AND u.phone LIKE concat( #{pageComActDiscussCommentDTO.account}, '%' )\n" +
            " </if> " +
            "LEFT JOIN com_act_discuss_comment_user cu ON c.id = cu.disscuss_comment_id \n" +
            " <where>" +
            "<if test='pageComActDiscussCommentDTO.comment != null and pageComActDiscussCommentDTO.comment.trim() != &quot;&quot;'>" +
            "c.`comment` LIKE concat( '%', #{pageComActDiscussCommentDTO.comment" +
            "}, '%' ) \n" +
            " </if> " +
            " </where>" +
            "GROUP BY\n" +
            "c.id\n" +
            ")t order by num desc ,t.create_at desc"+
            "</script>")
    IPage<ComActDiscussCommentVO> pageDiscussComment(Page page, @Param("pageComActDiscussCommentDTO")PageComActDiscussCommentDTO pageComActDiscussCommentDTO);
}