huanghongfa
2021-07-07 edbbe803b5c270a1acffbc7946bdda0d5e420dc5
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
package com.panzhihua.service_community.dao;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.service_community.model.dos.ComActDiscussOptionUserDO;
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 16:13
 **/
@Mapper
public interface ComActDiscussOptionUserDAO extends BaseMapper<ComActDiscussOptionUserDO> {
    //    @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 \n" +
            "COUNT(ou.id)\n" +
            "FROM\n" +
            "com_act_discuss d\n" +
            "JOIN com_act_discuss_option o ON d.id = o.discuss_id and d.id=#{id}\n" +
            "JOIN com_act_discuss_option_user ou ON o.id = ou.discuss_option_id and ou.user_id=#{loginUserId}")
    int selectHaveVote(@Param("id") Long id, @Param("loginUserId") Long loginUserId);
 
    @Select("select count(id) from com_act_discuss_option_user where discuss_option_id = #{discussOptionId} and user_id = #{userId}")
    int selectHaveVotes(@Param("discussOptionId") Long discussOptionId, @Param("userId") Long userId);
}