| | |
| | | package com.qianwen.smartman.modules.notify.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | 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.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.validation.Valid; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.qianwen.core.boot.ctrl.BladeController; |
| | | import com.qianwen.core.cache.utils.CacheUtil; |
| | | import com.qianwen.core.notify.notifier.NotifierProvider; |
| | |
| | | import com.qianwen.core.secure.BladeUser; |
| | | import com.qianwen.core.tool.api.R; |
| | | import com.qianwen.core.tool.metadata.ConfigMetadata; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.modules.notify.convert.NotifyConfigConvert; |
| | | import com.qianwen.smartman.modules.notify.dto.NotifyConfigDTO; |
| | | import com.qianwen.smartman.modules.notify.dto.NotifyTypeInfo; |
| | | import com.qianwen.smartman.modules.notify.dto.ProviderInfo; |
| | | import com.qianwen.smartman.modules.notify.entity.NotifyConfigEntity; |
| | | import com.qianwen.smartman.modules.notify.service.INotifyConfigService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | |
| | | @ApiResource({"blade-notify/notifier/config"}) |
| | | @Api(value = "通知配置管理", tags = {"通知配置管理"}) |
| | |
| | | public class NotifierConfigController extends BladeController { |
| | | private final INotifyConfigService notifyConfigService; |
| | | private final List<NotifierProvider> providers; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -75308287: |
| | | if (implMethodName.equals("getName")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case -75106384: |
| | | if (implMethodName.equals("getType")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 771206363: |
| | | if (implMethodName.equals("getTenantId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1090405223: |
| | | if (implMethodName.equals("getProvider")) { |
| | | 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/NotifyConfigEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getName(); |
| | | }; |
| | | } |
| | | 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/NotifyConfigEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getType(); |
| | | }; |
| | | } |
| | | 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/NotifyConfigEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getProvider(); |
| | | }; |
| | | } |
| | | 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(); |
| | | }; |
| | | } |
| | | 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/tenant/mp/TenantEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTenantId(); |
| | | }; |
| | | } |
| | | 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/tenant/mp/TenantEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTenantId(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public NotifierConfigController(final INotifyConfigService notifyConfigService, final List<NotifierProvider> providers) { |
| | | this.notifyConfigService = notifyConfigService; |
| | |
| | | public R<String> remove(@PathVariable("id") @ApiParam(value = "主键", required = true) String id, BladeUser bladeUser) { |
| | | CacheUtil.evict("blade:notify", "notifier:id:", id, false); |
| | | this.notifyConfigService.checkUsedByBusinessNotify(id); |
| | | |
| | | return R.status(this.notifyConfigService.remove(Wrappers.<NotifyConfigEntity>query().lambda() |
| | | .eq(NotifyConfigEntity::getId, id).eq(NotifyConfigEntity::getTenantId, bladeUser.getTenantId()))); |
| | | /* |
| | | return R.status(this.notifyConfigService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getId(); |
| | | }, id)).eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, bladeUser.getTenantId()))); |
| | | }, bladeUser.getTenantId())));*/ |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 7) |
| | |
| | | @ApiOperation(value = "业务通知可选的通知配置", notes = "传入通知类型") |
| | | public R<List<NotifyConfigDTO>> getAvailableNotifyConfig(@RequestParam String notifyType, BladeUser bladeUser) { |
| | | List<String> tenantIds = new ArrayList<>(Arrays.asList(bladeUser.getTenantId())); |
| | | |
| | | List<NotifyConfigEntity> result = this.notifyConfigService.list(Wrappers.<NotifyConfigEntity>lambdaQuery() |
| | | .in(NotifyConfigEntity::getTenantId, tenantIds) |
| | | .eq(NotifyConfigEntity::getType, notifyType) |
| | | .select(NotifyConfigEntity::getId, NotifyConfigEntity::getName, NotifyConfigEntity::getProvider)); |
| | | /* |
| | | List<NotifyConfigEntity> result = this.notifyConfigService.list(((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, tenantIds)).eq((v0) -> { |
| | |
| | | return v0.getName(); |
| | | }, (v0) -> { |
| | | return v0.getProvider(); |
| | | }})); |
| | | }}));*/ |
| | | return R.data(NotifyConfigConvert.INSTANCE.convertToDTOList(result)); |
| | | } |
| | | |