luofl
2025-02-23 9ff71e0d63c963f2c2c48facdf2336c558ba7100
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
package com.panzhihua.sangeshenbian.api;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.interfaces.OperLog;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.sangeshenbian.model.entity.MessageNotification;
import com.panzhihua.sangeshenbian.service.IMessageNotificationService;
import com.panzhihua.sangeshenbian.service.ISystemUserService;
import com.panzhihua.sangeshenbian.warpper.MessageNotificationList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * @author zhibing.pu
 * @Date 2025/2/23 3:05
 */
 
@Api
@RestController
@RequestMapping("/sangeshenbian/messageNotification")
public class MessageNotificationController extends BaseController {
    
    @Resource
    private IMessageNotificationService messageNotificationService;
    
    @Resource
    private ISystemUserService systemUserService;
    
    @GetMapping("/list")
    @ApiOperation(value = "获取消息通知列表", tags = {"三个身边后台-消息通知"})
    @OperLog(operModul = "三个身边后台",operType = 0, businessType = "获取消息通知列表")
    public R<IPage<MessageNotification>> list(MessageNotificationList query) {
        IPage<MessageNotification> page = messageNotificationService.list(query);
        return R.ok(page);
    }
    
    
    @PutMapping("/read/{id}")
    @ApiOperation(value = "标记为已读", tags = {"三个身边后台-消息通知"})
    @OperLog(operModul = "三个身边后台",operType = 2, businessType = "标记为已读")
    public R read(@PathVariable("id") Integer id) {
        MessageNotification messageNotification = messageNotificationService.getById(id);
        if(messageNotification.getReadStatus()==1){
            return R.fail("不能重复操作");
        }
        messageNotification.setReadStatus(1);
        messageNotificationService.updateById(messageNotification);
        return R.ok();
    }
    
    
    @GetMapping("/unreadCount")
    @ApiOperation(value = "获取未读数量", tags = {"三个身边后台-消息通知"})
    @OperLog(operModul = "三个身边后台",operType = 0, businessType = "获取未读数量")
    public R unreadCount() {
        Integer count = messageNotificationService.lambdaQuery()
                .eq(MessageNotification::getReadStatus, 0)
                .eq(MessageNotification::getUndertakerUserId, getUserId())
                .count();
        return R.ok(count);
    }
}