| | |
| | | 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.metadata.IPage; |
| | | 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.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.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.mp.support.Condition; |
| | |
| | | import com.qianwen.core.tool.metadata.ConfigMetadata; |
| | | import com.qianwen.core.tool.tuple.NameValue; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.modules.notify.convert.NotifyTemplateConvert; |
| | | import com.qianwen.smartman.modules.notify.dto.NotifyTemplateDTO; |
| | | import com.qianwen.smartman.modules.notify.dto.NotifyTemplateQueryDTO; |
| | |
| | | import com.qianwen.smartman.modules.notify.service.INotifyConfigService; |
| | | import com.qianwen.smartman.modules.notify.service.INotifyTemplateService; |
| | | import com.qianwen.smartman.modules.notify.wrapper.NotifyTemplateWrapper; |
| | | 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/template"}) |
| | | @Api(value = "消息通知模版", tags = {"消息通知模版"}) |
| | |
| | | private final INotifyConfigService notifyConfigService; |
| | | private final List<TemplateProvider> 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 931069238: |
| | | if (implMethodName.equals("getBusiness")) { |
| | | 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/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getName(); |
| | | }; |
| | | } |
| | | 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/NotifyTemplateEntity") && 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/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getType(); |
| | | }; |
| | | } |
| | | 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/NotifyTemplateEntity") && 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/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getBusiness(); |
| | | }; |
| | | } |
| | | 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/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getBusiness(); |
| | | }; |
| | | } |
| | | 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/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getProvider(); |
| | | }; |
| | | } |
| | | 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/NotifyTemplateEntity") && 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 RegionCache.VILLAGE_LEVEL /* 5 */: |
| | | 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(); |
| | | }; |
| | | } |
| | | 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 NotifierTemplateController(final INotifyTemplateService templateService, final INotifyConfigService notifyConfigService, final List<TemplateProvider> providers) { |
| | | this.templateService = templateService; |
| | |
| | | public R<String> remove(@PathVariable("id") @ApiParam(value = "主键", required = true) String id, BladeUser bladeUser) { |
| | | CacheUtil.evict("blade:notify", "template:id:", id, false); |
| | | this.templateService.checkUsedByBusinessNotify(id); |
| | | return R.status(this.templateService |
| | | .remove(Wrappers.<NotifyTemplateEntity>query().lambda() |
| | | .eq(NotifyTemplateEntity::getId, id).eq(NotifyTemplateEntity::getTenantId, bladeUser.getTenantId()))); |
| | | /* |
| | | return R.status(this.templateService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getId(); |
| | | }, id)).eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, bladeUser.getTenantId()))); |
| | | }, bladeUser.getTenantId())));*/ |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |
| | | @GetResource({"/list"}) |
| | | @ApiOperation(value = "通知模板列表", notes = "传入模板") |
| | | public R<IPage<NotifyTemplateResponseDTO>> configPageList(NotifyTemplateQueryDTO notifyTemplateQueryDTO, Query query, BladeUser bladeUser) { |
| | | LambdaQueryWrapper<NotifyTemplateEntity> lambdaQueryWrapper = Wrappers.<NotifyTemplateEntity>lambdaQuery() |
| | | .eq(NotifyTemplateEntity::getTenantId, bladeUser.getTenantId()); |
| | | /* |
| | | Wrapper wrapper = (LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, bladeUser.getTenantId()); |
| | | }, bladeUser.getTenantId());*/ |
| | | if (Func.isNotEmpty(notifyTemplateQueryDTO)) { |
| | | lambdaQueryWrapper.like(Func.isNotEmpty(notifyTemplateQueryDTO.getName()), NotifyTemplateEntity::getName, notifyTemplateQueryDTO.getName()) |
| | | .in(Func.isNotEmpty(notifyTemplateQueryDTO.getType()), NotifyTemplateEntity::getType, Arrays.asList(notifyTemplateQueryDTO.getType().split(","))) |
| | | .eq(Func.isNotEmpty(notifyTemplateQueryDTO.getBusinessKey()), NotifyTemplateEntity::getBusiness, notifyTemplateQueryDTO.getBusinessKey()) |
| | | .eq(Func.isNotEmpty(notifyTemplateQueryDTO.getProvider()), NotifyTemplateEntity::getProvider, notifyTemplateQueryDTO.getProvider()); |
| | | /* |
| | | wrapper.like(Func.isNotEmpty(notifyTemplateQueryDTO.getName()), (v0) -> { |
| | | return v0.getName(); |
| | | }, notifyTemplateQueryDTO.getName()).in(Func.isNotEmpty(notifyTemplateQueryDTO.getType()), (v0) -> { |
| | |
| | | return v0.getBusiness(); |
| | | }, notifyTemplateQueryDTO.getBusinessKey()).eq(Func.isNotEmpty(notifyTemplateQueryDTO.getProvider()), (v0) -> { |
| | | return v0.getProvider(); |
| | | }, notifyTemplateQueryDTO.getProvider()); |
| | | }, notifyTemplateQueryDTO.getProvider());*/ |
| | | } |
| | | IPage<NotifyTemplateEntity> list = this.templateService.page(Condition.getPage(query), wrapper); |
| | | IPage<NotifyTemplateEntity> list = this.templateService.page(Condition.getPage(query), lambdaQueryWrapper); |
| | | return R.data(NotifyTemplateWrapper.build().pageVO(NotifyTemplateConvert.INSTANCE.convertToPage(list))); |
| | | } |
| | | |
| | |
| | | List<NameValue<String>> result = new ArrayList<>(); |
| | | NotifyConfigEntity notifyConfigEntity = (NotifyConfigEntity) this.notifyConfigService.getById(notifyId); |
| | | if (Func.isNotEmpty(notifyConfigEntity)) { |
| | | result = this.templateService.list(Wrappers.<NotifyTemplateEntity>lambdaQuery() |
| | | .in(NotifyTemplateEntity::getTenantId, Arrays.asList(new String[] { bladeUser.getTenantId(), "000000" })) |
| | | .eq(NotifyTemplateEntity::getType, notifyConfigEntity.getType()) |
| | | .eq(NotifyTemplateEntity::getBusiness, businessKey) |
| | | .eq(NotifyTemplateEntity::getProvider, notifyConfigEntity.getProvider()) |
| | | .select(NotifyTemplateEntity::getId, NotifyTemplateEntity::getName )) |
| | | .stream().map(x -> new NameValue<String>(x.getName(), x.getId().toString())).collect(Collectors.toList()); |
| | | /* |
| | | result = (List) this.templateService.list(((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, Arrays.asList(bladeUser.getTenantId(), "000000"))).eq((v0) -> { |
| | |
| | | return v0.getName(); |
| | | }})).stream().map(x -> { |
| | | return new NameValue(x.getName(), x.getId().toString()); |
| | | }).collect(Collectors.toList()); |
| | | }).collect(Collectors.toList());*/ |
| | | } |
| | | return R.data(result); |
| | | } |