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 detail(@PathVariable String id) { return R.data(this.notifySystemService.detail(id)); } @ApiOperationSupport(order = 2) @GetMapping({"/list"}) @ApiOperation(value = "通知公告表列表", notes = "传入map") public R> list(@RequestParam @ApiIgnore Map params) { List 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 count(@RequestParam @ApiIgnore Map 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> 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 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 ids) { if (ids.isEmpty()) { return R.status(false); } return R.status(this.notifySystemService.removeByIds(ids)); } @ApiOperationSupport(order = 7) @PostResource({"/{state}"}) @ApiOperation("修改通知状态") public R changeState(@RequestBody List 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 getUnreadList() { NotifySystemUnreadVO result = this.notifySystemService.getUnreadList(); return R.data(result); } }