PC
2024-03-31 8c9ba6667b89cc0494d05b5da4355dde205b8d4a
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com.qianwen.smartman.modules.notify.controller;
 
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.lang.invoke.SerializedLambda;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.secure.BladeUser;
import com.qianwen.core.secure.utils.AuthUtil;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.websocket.distribute.MessageDO;
import com.qianwen.core.websocket.distribute.RedisMessageDistributor;
import com.qianwen.smartman.modules.notify.convert.NotifySystemConvert;
import com.qianwen.smartman.modules.notify.entity.NotifySystem;
import com.qianwen.smartman.modules.notify.service.INotifySystemService;
import com.qianwen.smartman.modules.notify.vo.NotifySystemSelectVO;
import com.qianwen.smartman.modules.notify.vo.NotifySystemUnreadVO;
import com.qianwen.smartman.modules.notify.vo.NotifySystemVO;
import com.qianwen.smartman.modules.notify.websocket.InternalMessageResponseJsonWebSocketMessage;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
 
@Api(value = "通知公告表管理", tags = {"通知公告表管理"})
@RequestMapping({"blade-notify/notify-system"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/controller/NotifySystemController.class */
public class NotifySystemController extends BladeController {
    private INotifySystemService notifySystemService;
    private RedisMessageDistributor messageDistributor;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1462639958:
                if (implMethodName.equals("getNotifyUser")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = false;
                    break;
                }
                break;
            case 803533544:
                if (implMethodName.equals("getStatus")) {
                    z = true;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/notify/entity/NotifySystem") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getNotifyUser();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/notify/entity/NotifySystem") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getNotifyUser();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public NotifySystemController(final INotifySystemService notifySystemService, final RedisMessageDistributor messageDistributor) {
        this.notifySystemService = notifySystemService;
        this.messageDistributor = messageDistributor;
    }
 
    @ApiOperationSupport(order = 1)
    @GetMapping({"/get/{id}"})
    @ApiOperation(value = "通知公告表详情", notes = "传入notifySystem")
    public R<NotifySystemVO> detail(@PathVariable String id) {
        return R.data(this.notifySystemService.detail(id));
    }
 
    @ApiOperationSupport(order = 2)
    @GetMapping({"/list"})
    @ApiOperation(value = "通知公告表列表", notes = "传入map")
    public R<List<NotifySystemVO>> list(@RequestParam @ApiIgnore Map<String, Object> params) {
        List<NotifySystem> list = this.notifySystemService.list(Condition.getQueryWrapper(params, NotifySystem.class));
        return R.data(NotifySystemConvert.INSTANCE.convert(list));
    }
 
    @ApiOperationSupport(order = 2)
    @GetMapping({"/count"})
    @ApiOperation(value = "通知公告表统计值", notes = "传入map")
    public R<Long> count(@RequestParam @ApiIgnore Map<String, Object> params) {
        long count = this.notifySystemService.count(Condition.getQueryWrapper(params, NotifySystem.class));
        return R.data(Long.valueOf(count));
    }
 
    @ApiOperationSupport(order = 3)
    @GetMapping({"/page"})
    @ApiOperation(value = "通知公告表分页", notes = "传入map")
    public R<IPage<NotifySystemVO>> page(NotifySystemSelectVO notifySystemSelectVO, Query query) {
        return R.data(this.notifySystemService.pageNotifySystem(notifySystemSelectVO, Condition.getPage(query)));
    }
 
    @PostMapping({"/insert"})
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "通知公告表新增", notes = "传入notifySystemVO")
    public R<NotifySystemVO> insert(@Valid @RequestBody NotifySystemVO notifySystemVO) {
        NotifySystem notifySystem = NotifySystemConvert.INSTANCE.convert(notifySystemVO);
        this.notifySystemService.save(notifySystem);
        return R.data(NotifySystemConvert.INSTANCE.convert(notifySystem));
    }
 
    @DeleteMapping({"/remove"})
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "通知公告表删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键", required = true) @RequestBody List<Long> ids) {
        if (ids.isEmpty()) {
            return R.status(false);
        }
        return R.status(this.notifySystemService.removeByIds(ids));
    }
 
    @ApiOperationSupport(order = 7)
    @PostResource({"/{state}"})
    @ApiOperation("修改通知状态")
    public R<String> changeState(@RequestBody List<String> idList, @PathVariable("state") Integer state, BladeUser bladeUser) {
        boolean flag = this.notifySystemService.update((LambdaUpdateWrapper) ((LambdaUpdateWrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().set((v0) -> {
            return v0.getStatus();
        }, state)).eq((v0) -> {
            return v0.getNotifyUser();
        }, bladeUser.getUserId())).in((v0) -> {
            return v0.getId();
        }, idList));
        InternalMessageResponseJsonWebSocketMessage internalMessageResponseJsonWebSocketMessage = new InternalMessageResponseJsonWebSocketMessage();
        long unNotificationCount = this.notifySystemService.count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne((v0) -> {
            return v0.getStatus();
        }, 1)).eq((v0) -> {
            return v0.getNotifyUser();
        }, AuthUtil.getUserId()));
        internalMessageResponseJsonWebSocketMessage.setHaveUnread(unNotificationCount > 0);
        MessageDO messageDO = new MessageDO();
        messageDO.setNeedBroadcast(Boolean.FALSE);
        messageDO.setMessageText(JSONUtil.toJsonStr(internalMessageResponseJsonWebSocketMessage));
        messageDO.setSessionKeys(Arrays.asList(AuthUtil.getUserId()));
        this.messageDistributor.distribute(messageDO);
        return R.status(flag);
    }
 
    @ApiOperationSupport(order = 3)
    @GetMapping({"/getUnreadList"})
    @ApiOperation(value = "获取未读通知-铃铛", notes = "传入map")
    public R<NotifySystemUnreadVO> getUnreadList() {
        NotifySystemUnreadVO result = this.notifySystemService.getUnreadList();
        return R.data(result);
    }
}