From d4dbe98353ee81d6c6d05b271aaa53328cdcaefa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zachma=28=E9=A9=AC=E6=99=A8=29?= Date: Mon, 2 Sep 2024 14:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=C3=A6=C2=9B=E6=B7=BB=E5=8A=A0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + wedpr-adm/conf/wedpr.properties | 2 +- .../publish/config/PublishSyncConfig.java | 2 ++ .../WedprPublishedServiceController.java | 8 ++++---- .../WedprServiceInvokeTableController.java | 4 ++-- .../mapper/WedprServiceInvokeTableMapper.java | 13 ++++++------- .../impl/WedprPublishedServiceServiceImpl.java | 16 +++++++++++----- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 6adb501a..ab3add87 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ wedpr-components/user/src/main/resources/ wedpr-adm/src/main/resources/ wedpr-admin/src/main/resources/ logs/ +bin/ diff --git a/wedpr-adm/conf/wedpr.properties b/wedpr-adm/conf/wedpr.properties index 556bbee3..afa72207 100644 --- a/wedpr-adm/conf/wedpr.properties +++ b/wedpr-adm/conf/wedpr.properties @@ -24,7 +24,7 @@ wedpr.crypto.symmetric.iv=123456 wedpr.mybatis.mapperLocations=classpath*:mapper/*Mapper.xml # Note: the basePackage can't set to com.webank.wedpr simply for the mybatis will scan the Service -wedpr.mybatis.BasePackage=com.webank.wedpr.components.meta.resource.follower.dao,com.webank.wedpr.components.meta.sys.config.dao,com.webank.wedpr.components.project.dao,com.webank.wedpr.components.meta.setting.template.dao,com.webank.wedpr.components.sync.dao,com.webank.wedpr.components.authorization.dao,com.webank.wedpr.components.dataset.mapper,com.webank.wedpr.components.user.mapper,com.webank.wedpr.components.meta.agency.dao,com.webank.wedpr.components.integration.jupyter.dao +wedpr.mybatis.BasePackage=com.webank.wedpr.components.meta.resource.follower.dao,com.webank.wedpr.components.meta.sys.config.dao,com.webank.wedpr.components.project.dao,com.webank.wedpr.components.meta.setting.template.dao,com.webank.wedpr.components.sync.dao,com.webank.wedpr.components.authorization.dao,com.webank.wedpr.components.dataset.mapper,com.webank.wedpr.components.user.mapper,com.webank.wedpr.components.meta.agency.dao,com.webank.wedpr.components.api.credential.dao,com.webank.wedpr.components.integration.jupyter.dao,com.webank.wedpr.components.publish.mapper # wedpr.mybatis.typeAliasesPackage= ### the blockchain configuration diff --git a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/config/PublishSyncConfig.java b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/config/PublishSyncConfig.java index fa53dca7..fea4c7e0 100644 --- a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/config/PublishSyncConfig.java +++ b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/config/PublishSyncConfig.java @@ -11,11 +11,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; /** * @author zachma * @date 2024/8/31 */ +@Configuration public class PublishSyncConfig { private static final Logger logger = LoggerFactory.getLogger(PublishSyncConfig.class); diff --git a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprPublishedServiceController.java b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprPublishedServiceController.java index cf3ab09f..75aedff1 100644 --- a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprPublishedServiceController.java +++ b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprPublishedServiceController.java @@ -71,7 +71,7 @@ public WeDPRResponse listPublish(PublishSearchRequest request) { } } - @DeleteMapping("/revoke/{publishId}") + @DeleteMapping("/revoke/{serviceId}") public WeDPRResponse revokePublish(@PathVariable String serviceId, HttpServletRequest request) { try { return wedprPublishService.revokePublishService( @@ -82,10 +82,10 @@ public WeDPRResponse revokePublish(@PathVariable String serviceId, HttpServletRe } } - @GetMapping("/search/{publishId}") - public WeDPRResponse searchPublish(@PathVariable String publishId) { + @GetMapping("/search/{serviceId}") + public WeDPRResponse searchPublish(@PathVariable String serviceId) { try { - return wedprPublishService.searchPublishService(publishId); + return wedprPublishService.searchPublishService(serviceId); } catch (Exception e) { logger.warn("searchPublish exception, error: ", e); return new WeDPRResponse( diff --git a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprServiceInvokeTableController.java b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprServiceInvokeTableController.java index 26daa1fc..7eac8e28 100644 --- a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprServiceInvokeTableController.java +++ b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/controller/WedprServiceInvokeTableController.java @@ -34,10 +34,10 @@ public class WedprServiceInvokeTableController { @GetMapping("/search/{serviceId}") public WeDPRResponse searchPublishRecord( - @PathVariable String publishId, PublishInvokeSearchRequest publishInvokeRequest) { + @PathVariable String serviceId, PublishInvokeSearchRequest publishInvokeRequest) { try { return wedprPublishInvokeService.seachPublishInvokeService( - publishId, publishInvokeRequest); + serviceId, publishInvokeRequest); } catch (Exception e) { logger.warn("发起方搜索申报记录 exception, error: ", e); return new WeDPRResponse( diff --git a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/mapper/WedprServiceInvokeTableMapper.java b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/mapper/WedprServiceInvokeTableMapper.java index beb0c32d..48cc6592 100644 --- a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/mapper/WedprServiceInvokeTableMapper.java +++ b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/mapper/WedprServiceInvokeTableMapper.java @@ -17,14 +17,13 @@ public interface WedprServiceInvokeTableMapper extends BaseMapper { @Select( - "SELECT t.invoke_id,t.invoke_user,t.invoke_agency,t.invoke_status,t.invoke_time,s.expire_time,s.apply_time " + "") List selectWedprPublishInvokeOnCondition( Page page, @Param("serviceId") String serviceId, diff --git a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/service/impl/WedprPublishedServiceServiceImpl.java b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/service/impl/WedprPublishedServiceServiceImpl.java index 22dadacb..3be43537 100644 --- a/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/service/impl/WedprPublishedServiceServiceImpl.java +++ b/wedpr-components/service-publish/src/main/java/com/webank/wedpr/components/publish/service/impl/WedprPublishedServiceServiceImpl.java @@ -24,6 +24,8 @@ import com.webank.wedpr.core.utils.WeDPRResponse; import java.time.LocalDateTime; import java.util.Arrays; +import java.util.Objects; + import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -45,7 +47,7 @@ public class WedprPublishedServiceServiceImpl @Qualifier("publishSyncer") @Autowired - PublishSyncerApi publishSyncer; + private PublishSyncerApi publishSyncer; @Override @Transactional(rollbackFor = WeDPRException.class) @@ -91,6 +93,7 @@ public WeDPRResponse updatePublishService(String username, PublishCreateRequest wedprPublishedService.setServiceDesc(publishCreate.getServiceDesc()); wedprPublishedService.setServiceConfig(publishCreate.getServiceConfig()); + wedprPublishedService.setLastUpdateTime(LocalDateTime.now()); boolean updated = this.update(wedprPublishedService, lambdaQueryWrapper); if (updated) { publishSyncer.publishSync(wedprPublishedService.serialize()); @@ -104,14 +107,17 @@ public WeDPRResponse updatePublishService(String username, PublishCreateRequest @Override @Transactional(rollbackFor = WeDPRException.class) public WeDPRResponse revokePublishService(String username, String serviceId) { - if (getPublishService(serviceId) == null) { - return new WeDPRResponse(Constant.WEDPR_FAILED, serviceId + "无法撤销,不属于用户" + username); - } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper .eq(WedprPublishedService::getServiceId, serviceId) .eq(WedprPublishedService::getOwner, username) .eq(WedprPublishedService::getAgency, WeDPRCommonConfig.getAgency()); + WedprPublishedService one = this.getOne(lambdaQueryWrapper); + if( Objects.isNull(one)){ + return new WeDPRResponse(Constant.WEDPR_FAILED, serviceId + "服务用户无权撤回"); + + } + boolean removed = this.remove(lambdaQueryWrapper); if (removed) { WedprPublishedService wedprPublish = new WedprPublishedService(); @@ -144,7 +150,7 @@ public WeDPRResponse listPublishService(PublishSearchRequest request) { lambdaQueryWrapper.eq(WedprPublishedService::getServiceType, serviceType); } if (StringUtils.isNotBlank(createDate)) { - lambdaQueryWrapper.apply("DATE_FORMAT(publish_time, '%Y-%m-%d') = {0}", createDate); + lambdaQueryWrapper.apply("DATE_FORMAT(create_time, '%Y-%m-%d') = {0}", createDate); } Page wedprPublishPage =