提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.dal.mysql.notify; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.PageResult; |
|
4 |
import com.iailab.framework.mybatis.core.enums.SqlConstants; |
|
5 |
import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
|
6 |
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
7 |
import com.iailab.framework.mybatis.core.query.QueryWrapperX; |
|
8 |
import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; |
|
9 |
import com.iailab.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; |
|
10 |
import com.iailab.module.system.dal.dataobject.notify.NotifyMessageDO; |
|
11 |
import org.apache.ibatis.annotations.Mapper; |
|
12 |
|
|
13 |
import java.time.LocalDateTime; |
|
14 |
import java.util.Collection; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
@Mapper |
|
18 |
public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> { |
|
19 |
|
|
20 |
default PageResult<NotifyMessageDO> selectPage(NotifyMessagePageReqVO reqVO) { |
|
21 |
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>() |
|
22 |
.eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId()) |
|
23 |
.eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType()) |
|
24 |
.likeIfPresent(NotifyMessageDO::getTemplateCode, reqVO.getTemplateCode()) |
|
25 |
.eqIfPresent(NotifyMessageDO::getTemplateType, reqVO.getTemplateType()) |
|
26 |
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime()) |
|
27 |
.orderByDesc(NotifyMessageDO::getId)); |
|
28 |
} |
|
29 |
|
|
30 |
default PageResult<NotifyMessageDO> selectPage(NotifyMessageMyPageReqVO reqVO, Long userId, Integer userType) { |
|
31 |
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>() |
|
32 |
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus()) |
|
33 |
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime()) |
|
34 |
.eq(NotifyMessageDO::getUserId, userId) |
|
35 |
.eq(NotifyMessageDO::getUserType, userType) |
|
36 |
.orderByDesc(NotifyMessageDO::getId)); |
|
37 |
} |
|
38 |
|
|
39 |
default int updateListRead(Collection<Long> ids, Long userId, Integer userType) { |
|
40 |
return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()), |
|
41 |
new LambdaQueryWrapperX<NotifyMessageDO>() |
|
42 |
.in(NotifyMessageDO::getId, ids) |
|
43 |
.eq(NotifyMessageDO::getUserId, userId) |
|
44 |
.eq(NotifyMessageDO::getUserType, userType) |
|
45 |
.eq(NotifyMessageDO::getReadStatus, false)); |
|
46 |
} |
|
47 |
|
|
48 |
default int updateListRead(Long userId, Integer userType) { |
|
49 |
return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()), |
|
50 |
new LambdaQueryWrapperX<NotifyMessageDO>() |
|
51 |
.eq(NotifyMessageDO::getUserId, userId) |
|
52 |
.eq(NotifyMessageDO::getUserType, userType) |
|
53 |
.eq(NotifyMessageDO::getReadStatus, false)); |
|
54 |
} |
|
55 |
|
|
56 |
default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) { |
|
57 |
return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句,所以只能用 QueryWrapperX |
|
58 |
.eq("user_id", userId) |
|
59 |
.eq("user_type", userType) |
|
60 |
.eq("read_status", false) |
|
61 |
.orderByDesc("id").limitN(size)); |
|
62 |
} |
|
63 |
|
|
64 |
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) { |
|
65 |
return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>() |
|
66 |
.eq(NotifyMessageDO::getReadStatus, false) |
|
67 |
.eq(NotifyMessageDO::getUserId, userId) |
|
68 |
.eq(NotifyMessageDO::getUserType, userType)); |
|
69 |
} |
|
70 |
|
|
71 |
} |