| | |
| | | package com.qianwen.smartman.modules.notify.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | 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 java.lang.invoke.SerializedLambda; |
| | | import java.util.List; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | 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.stereotype.ApiResource; |
| | | import com.qianwen.core.secure.BladeUser; |
| | | import com.qianwen.core.tool.api.R; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.modules.notify.convert.NotificationConvert; |
| | | import com.qianwen.smartman.modules.notify.convert.NotifySubscriberConvert; |
| | | import com.qianwen.smartman.modules.notify.dto.Notification; |
| | |
| | | import com.qianwen.smartman.modules.notify.entity.NotifySubscriberEntity; |
| | | import com.qianwen.smartman.modules.notify.service.INotificationService; |
| | | import com.qianwen.smartman.modules.notify.service.INotifySubscriberService; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | @ApiResource({"blade-notify/notifications"}) |
| | | @Api(value = "系统通知管理", tags = {"系统通知管理"}) |
| | |
| | | private final INotificationService notificationService; |
| | | private final INotifySubscriberService subscriberService; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -1517517730: |
| | | if (implMethodName.equals("getSubscriber")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | 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/modules/notify/entity/NotifySubscriberEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSubscriber(); |
| | | }; |
| | | } |
| | | 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/NotifySubscriberEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSubscriber(); |
| | | }; |
| | | } |
| | | 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/NotificationEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSubscriber(); |
| | | }; |
| | | } |
| | | 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/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | 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(); |
| | | }; |
| | | } |
| | | 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/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 NotificationController(final INotificationService notificationService, final INotifySubscriberService subscriberService) { |
| | | this.notificationService = notificationService; |
| | |
| | | @GetResource({"/subscriptions/query"}) |
| | | @ApiOperation(value = "查询当前用户订阅信息", notes = "查询当前用户订阅信息") |
| | | public R<IPage<NotifySubscriberDTO>> querySubscription(Query query, BladeUser bladeUser) { |
| | | IPage<NotifySubscriberEntity> pages = this.subscriberService.page(Condition.getPage(query), |
| | | Wrappers.<NotifySubscriberEntity>query().lambda() |
| | | .eq(NotifySubscriberEntity::getSubscriber, bladeUser.getUserId())); |
| | | /* |
| | | IPage<NotifySubscriberEntity> pages = this.subscriberService.page(Condition.getPage(query), (Wrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getSubscriber(); |
| | | }, bladeUser.getUserId())); |
| | | }, bladeUser.getUserId()));*/ |
| | | return R.data(NotifySubscriberConvert.INSTANCE.convertToPage(pages)); |
| | | } |
| | | |
| | |
| | | @PutResource({"/subscription/{id}/{state}"}) |
| | | @ApiOperation(value = "修改通知订阅状态", notes = "修改通知订阅状态") |
| | | public R<String> changeSubscribeState(@PathVariable("id") String id, @PathVariable("state") Integer state) { |
| | | LambdaUpdateWrapper<NotifySubscriberEntity> updateWrapper = Wrappers.<NotifySubscriberEntity>update().lambda() |
| | | .set(NotifySubscriberEntity::getStatus, state).eq(NotifySubscriberEntity::getId, id); |
| | | |
| | | return R.status(this.subscriberService.update(updateWrapper)); |
| | | /* |
| | | return R.status(this.subscriberService.update((LambdaUpdateWrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().set((v0) -> { |
| | | return v0.getStatus(); |
| | | }, state)).eq((v0) -> { |
| | | return v0.getId(); |
| | | }, id))); |
| | | }, id)));*/ |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 3) |
| | | @DeleteResource({"/subscription/{id}"}) |
| | | @ApiOperation(value = "删除订阅", notes = "删除订阅") |
| | | public R<String> deleteSubscription(@PathVariable("id") String id, BladeUser bladeUser) { |
| | | return R.status(this.subscriberService |
| | | .remove(Wrappers.<NotifySubscriberEntity>lambdaQuery() |
| | | .eq(NotifySubscriberEntity::getId, id) |
| | | .eq(NotifySubscriberEntity::getSubscriber, bladeUser.getUserId()))); |
| | | /* |
| | | return R.status(this.subscriberService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getId(); |
| | | }, id)).eq((v0) -> { |
| | | return v0.getSubscriber(); |
| | | }, bladeUser.getUserId()))); |
| | | }, bladeUser.getUserId())));*/ |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |
| | |
| | | @PostResource({"/{state}"}) |
| | | @ApiOperation("修改通知状态 1已读") |
| | | public R<String> changeNotificationState(@RequestBody List<String> idList, @PathVariable("state") Integer state, BladeUser bladeUser) { |
| | | LambdaUpdateWrapper<NotificationEntity> updateWrapper = Wrappers.<NotificationEntity>update().lambda() |
| | | .set(NotificationEntity::getStatus, state).eq(NotificationEntity::getSubscriber, bladeUser.getUserId()).in(NotificationEntity::getId, idList); |
| | | return R.status(this.notificationService.update(updateWrapper)); |
| | | |
| | | /* |
| | | return R.status(this.notificationService.update((LambdaUpdateWrapper) ((LambdaUpdateWrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().set((v0) -> { |
| | | return v0.getStatus(); |
| | | }, state)).eq((v0) -> { |
| | | return v0.getSubscriber(); |
| | | }, bladeUser.getUserId())).in((v0) -> { |
| | | return v0.getId(); |
| | | }, idList))); |
| | | }, idList)));*/ |
| | | } |
| | | } |