Skip to content

Commit

Permalink
æ�添加服务发布
Browse files Browse the repository at this point in the history
  • Loading branch information
zachma(马晨) committed Sep 2, 2024
1 parent 105355f commit d4dbe98
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ wedpr-components/user/src/main/resources/
wedpr-adm/src/main/resources/
wedpr-admin/src/main/resources/
logs/
bin/
2 changes: 1 addition & 1 deletion wedpr-adm/conf/wedpr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
public interface WedprServiceInvokeTableMapper extends BaseMapper<WedprServiceInvokeTable> {

@Select(
"SELECT t.invoke_id,t.invoke_user,t.invoke_agency,t.invoke_status,t.invoke_time,s.expire_time,s.apply_time "
"<script> SELECT t.invoke_id,t.invoke_user,t.invoke_agency,t.invoke_status,t.invoke_time,s.expire_time,s.apply_time "
+ "FROM wedpr_service_invoke_table t , wedpr_service_auth_table s WHERE s.service_id = t.service_id AND s.service_id = #{serviceId} "
+ "<where> "
+ "<if test='invokeAgency != \"\"'> AND t.invoke_agency = #{invokeAgency} </if> "
+ "<if test='invokeStatus != \"\"'> AND t.invoke_status = #{invokeStatus} </if> "
+ "<if test='invokeDate != \"\"'> AND DATE_FORMAT(t.invoke_time, '%Y-%m-%d') = #{invokeDate} </if> "
+ "<if test='expireDate != \"\"'> AND DATE_FORMAT(s.expire_time, '%Y-%m-%d') = #{expireDate} </if> "
+ "</where>")
+ "<if test='invokeAgency != null and invokeAgency != \"\"'> AND t.invoke_agency = #{invokeAgency} </if> "
+ "<if test='invokeStatus != null and invokeStatus != \"\"'> AND t.invoke_status = #{invokeStatus} </if> "
+ "<if test='invokeDate != null and invokeDate != \"\"'> AND DATE_FORMAT(t.invoke_time, '%Y-%m-%d') = #{invokeDate} </if> "
+ "<if test='expireDate != null and expireDate != \"\"'> AND DATE_FORMAT(s.expire_time, '%Y-%m-%d') = #{expireDate} </if> "
+ " </script>")
List<WedprServiceInvokeResult> selectWedprPublishInvokeOnCondition(
Page<WedprServiceInvokeResult> page,
@Param("serviceId") String serviceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +47,7 @@ public class WedprPublishedServiceServiceImpl

@Qualifier("publishSyncer")
@Autowired
PublishSyncerApi publishSyncer;
private PublishSyncerApi publishSyncer;

@Override
@Transactional(rollbackFor = WeDPRException.class)
Expand Down Expand Up @@ -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());
Expand All @@ -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<WedprPublishedService> 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();
Expand Down Expand Up @@ -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<WedprPublishedService> wedprPublishPage =
Expand Down

0 comments on commit d4dbe98

Please sign in to comment.