diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/CheckingController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/CheckingController.java new file mode 100644 index 0000000..fe4c78c --- /dev/null +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/CheckingController.java @@ -0,0 +1,34 @@ +package com.eshore.gringotts.web.domain.base.controller; + +import com.eshore.gringotts.web.configuration.amis.AmisResponse; +import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity; +import com.eshore.gringotts.web.domain.base.service.CheckingService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +/** + * @author wn + * @version 20241224 + */ +@Slf4j +public abstract class CheckingController extends SimpleControllerSupport { + private final CheckingService checkingService; + + public CheckingController(CheckingService service) { + super(service); + this.checkingService = service; + } + + @GetMapping("/submit/{id}") + public AmisResponse submit(@PathVariable Long id) throws Exception { + checkingService.submit(id); + return AmisResponse.responseSuccess(); + } + + @GetMapping("/retract/{id}") + public AmisResponse retract(@PathVariable Long id) throws Exception { + checkingService.retract(id); + return AmisResponse.responseSuccess(); + } +} diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/CheckingService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/CheckingService.java index 47449dc..14c22f8 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/CheckingService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/CheckingService.java @@ -1,6 +1,10 @@ package com.eshore.gringotts.web.domain.base.service; +import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity; +import com.eshore.gringotts.web.domain.base.repository.SimpleRepository; import com.eshore.gringotts.web.domain.entity.CheckOrder; +import com.eshore.gringotts.web.domain.service.UserService; +import javax.persistence.EntityManager; import org.eclipse.collections.api.map.ImmutableMap; /** @@ -9,6 +13,16 @@ import org.eclipse.collections.api.map.ImmutableMap; * @author lanyuanxiaoyao * @date 2024-11-28 */ -public interface CheckingService { - void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap parameters); +public abstract class CheckingService extends LogicDeleteService { + public CheckingService(SimpleRepository repository, UserService userService, EntityManager manager) { + super(repository, userService, manager); + } + + abstract public void submit(Long id) throws Exception; + + abstract public void retract(Long id) throws Exception; + + abstract public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap parameters); + + abstract public ImmutableMap archive(ENTITY entity); } diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/AuthenticationController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/AuthenticationController.java index a934829..3a4cc3f 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/AuthenticationController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/AuthenticationController.java @@ -1,7 +1,6 @@ package com.eshore.gringotts.web.domain.controller; -import com.eshore.gringotts.web.configuration.amis.AmisResponse; -import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport; +import com.eshore.gringotts.web.domain.base.controller.CheckingController; import com.eshore.gringotts.web.domain.base.entity.FileInfo; import com.eshore.gringotts.web.domain.base.entity.SimpleListItem; import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem; @@ -9,7 +8,6 @@ import com.eshore.gringotts.web.domain.entity.Authentication; import com.eshore.gringotts.web.domain.service.AuthenticationService; import com.eshore.gringotts.web.domain.service.DataFileService; import com.eshore.gringotts.web.domain.service.DataResourceService; -import com.fasterxml.jackson.core.JsonProcessingException; import java.time.LocalDateTime; import lombok.Data; import lombok.EqualsAndHashCode; @@ -17,8 +15,6 @@ import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.set.ImmutableSet; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -29,30 +25,16 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("authentication") -public class AuthenticationController extends SimpleControllerSupport { - private final AuthenticationService authenticationService; +public class AuthenticationController extends CheckingController { private final DataResourceService dataResourceService; private final DataFileService dataFileService; public AuthenticationController(AuthenticationService service, DataResourceService dataResourceService, DataFileService dataFileService) { super(service); - this.authenticationService = service; this.dataResourceService = dataResourceService; this.dataFileService = dataFileService; } - @GetMapping("/submit/{id}") - public AmisResponse submit(@PathVariable Long id) throws JsonProcessingException { - authenticationService.submit(id); - return AmisResponse.responseSuccess(); - } - - @GetMapping("/retract/{id}") - public AmisResponse retract(@PathVariable Long id) { - authenticationService.retract(id); - return AmisResponse.responseSuccess(); - } - @Override protected Authentication fromSaveItem(SaveItem item) throws Exception { Authentication authentication = new Authentication(); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/ConfirmationController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/ConfirmationController.java index eae6ea0..c8a262a 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/ConfirmationController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/ConfirmationController.java @@ -1,7 +1,6 @@ package com.eshore.gringotts.web.domain.controller; -import com.eshore.gringotts.web.configuration.amis.AmisResponse; -import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport; +import com.eshore.gringotts.web.domain.base.controller.CheckingController; import com.eshore.gringotts.web.domain.base.entity.FileInfo; import com.eshore.gringotts.web.domain.base.entity.SimpleListItem; import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem; @@ -9,15 +8,12 @@ import com.eshore.gringotts.web.domain.entity.Confirmation; import com.eshore.gringotts.web.domain.service.ConfirmationService; import com.eshore.gringotts.web.domain.service.DataFileService; import com.eshore.gringotts.web.domain.service.DataResourceService; -import com.fasterxml.jackson.core.JsonProcessingException; import java.time.LocalDateTime; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.set.ImmutableSet; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -28,30 +24,16 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("confirmation") -public class ConfirmationController extends SimpleControllerSupport { - private final ConfirmationService confirmationService; +public class ConfirmationController extends CheckingController { private final DataResourceService dataResourceService; private final DataFileService dataFileService; - public ConfirmationController(ConfirmationService service, ConfirmationService confirmationService, DataResourceService dataResourceService, DataFileService dataFileService) { + public ConfirmationController(ConfirmationService service, DataResourceService dataResourceService, DataFileService dataFileService) { super(service); - this.confirmationService = confirmationService; this.dataResourceService = dataResourceService; this.dataFileService = dataFileService; } - @GetMapping("/submit/{id}") - public AmisResponse submit(@PathVariable Long id) throws JsonProcessingException { - confirmationService.submit(id); - return AmisResponse.responseSuccess(); - } - - @GetMapping("/retract/{id}") - public AmisResponse retract(@PathVariable Long id) { - confirmationService.retract(id); - return AmisResponse.responseSuccess(); - } - @Override protected Confirmation fromSaveItem(SaveItem item) throws Exception { Confirmation confirmation = new Confirmation(); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java index 13732c4..100657f 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java @@ -3,21 +3,19 @@ package com.eshore.gringotts.web.domain.controller; import cn.hutool.core.util.StrUtil; import com.eshore.gringotts.web.configuration.HostConfiguration; import com.eshore.gringotts.web.configuration.amis.AmisResponse; -import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport; +import com.eshore.gringotts.web.domain.base.controller.CheckingController; import com.eshore.gringotts.web.domain.base.entity.SimpleListItem; import com.eshore.gringotts.web.domain.base.entity.SimpleSaveItem; import com.eshore.gringotts.web.domain.entity.Ware; import com.eshore.gringotts.web.domain.service.DataFileService; import com.eshore.gringotts.web.domain.service.DataResourceService; import com.eshore.gringotts.web.domain.service.WareService; -import com.fasterxml.jackson.core.JsonProcessingException; import java.time.LocalDateTime; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.eclipse.collections.api.list.ImmutableList; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -28,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("ware") -public class WareController extends SimpleControllerSupport { +public class WareController extends CheckingController { private final HostConfiguration hostConfiguration; private final WareService wareService; private final DataResourceService dataResourceService; @@ -47,18 +45,6 @@ public class WareController extends SimpleControllerSupport submit(@PathVariable Long id) throws JsonProcessingException { - wareService.submit(id); - return AmisResponse.responseSuccess(); - } - - @GetMapping("/retract/{id}") - public AmisResponse retract(@PathVariable Long id) { - wareService.retract(id); - return AmisResponse.responseSuccess(); - } - @Override protected Ware fromSaveItem(SaveItem saveItem) { Ware ware = new Ware(); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/AuthenticationService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/AuthenticationService.java index b1f120b..3facfc2 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/AuthenticationService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/AuthenticationService.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity; import com.eshore.gringotts.web.domain.base.service.CheckingService; -import com.eshore.gringotts.web.domain.base.service.LogicDeleteService; import com.eshore.gringotts.web.domain.entity.Authentication; import com.eshore.gringotts.web.domain.entity.Authentication_; import com.eshore.gringotts.web.domain.entity.CheckOrder; @@ -33,7 +32,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service("com.eshore.gringotts.web.domain.service.AuthenticationService") -public class AuthenticationService extends LogicDeleteService implements CheckingService { +public class AuthenticationService extends CheckingService { private final AuthenticationRepository authenticationRepository; private final UserService userService; private final CheckOrderService checkOrderService; @@ -84,6 +83,7 @@ public class AuthenticationService extends LogicDeleteService im } @Transactional(rollbackOn = Throwable.class) + @Override public void submit(Long id) throws JsonProcessingException { Authentication authentication = detailOrThrow(id); authentication.setState(CheckingNeededEntity.State.OWNER_CHECKING); @@ -101,6 +101,7 @@ public class AuthenticationService extends LogicDeleteService im } @Transactional(rollbackOn = Throwable.class) + @Override public void retract(Long id) { Authentication authentication = detailOrThrow(id); authentication.setState(Authentication.State.DRAFT); @@ -145,6 +146,11 @@ public class AuthenticationService extends LogicDeleteService im checkOrderService.save(order); } + @Override + public ImmutableMap archive(Authentication authentication) { + return null; + } + public static final class AuthenticationDuplicatedException extends RuntimeException { public AuthenticationDuplicatedException() { super("数据资源已绑定该账号的授权申请,无法再次申请"); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/ConfirmationService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/ConfirmationService.java index 1a22834..34e2a85 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/ConfirmationService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/ConfirmationService.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity; import com.eshore.gringotts.web.domain.base.service.CheckingService; -import com.eshore.gringotts.web.domain.base.service.LogicDeleteService; import com.eshore.gringotts.web.domain.entity.CheckOrder; import com.eshore.gringotts.web.domain.entity.CheckOrder_; import com.eshore.gringotts.web.domain.entity.Confirmation; @@ -35,7 +34,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service("com.eshore.gringotts.web.domain.service.ConfirmationService") -public class ConfirmationService extends LogicDeleteService implements CheckingService { +public class ConfirmationService extends CheckingService { private final ConfirmationRepository confirmationRepository; private final CheckOrderService checkOrderService; private final ObjectMapper mapper; @@ -81,6 +80,7 @@ public class ConfirmationService extends LogicDeleteService implem } @Transactional(rollbackOn = Throwable.class) + @Override public void submit(Long id) throws JsonProcessingException { Confirmation confirmation = detailOrThrow(id); confirmation.setState(Confirmation.State.CHECKING); @@ -98,6 +98,7 @@ public class ConfirmationService extends LogicDeleteService implem } @Transactional(rollbackOn = Throwable.class) + @Override public void retract(Long id) { Confirmation confirmation = detailOrThrow(id); confirmation.setState(CheckingNeededEntity.State.DRAFT); @@ -129,6 +130,11 @@ public class ConfirmationService extends LogicDeleteService implem } } + @Override + public ImmutableMap archive(Confirmation confirmation) { + return null; + } + public static final class ConfirmationDuplicatedException extends RuntimeException { public ConfirmationDuplicatedException() { super("数据资源已绑定确权申请,无法再次申请"); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/WareService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/WareService.java index 3efcfc9..4305326 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/WareService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/WareService.java @@ -2,7 +2,6 @@ package com.eshore.gringotts.web.domain.service; import cn.hutool.core.util.StrUtil; import com.eshore.gringotts.web.domain.base.service.CheckingService; -import com.eshore.gringotts.web.domain.base.service.LogicDeleteService; import com.eshore.gringotts.web.domain.entity.CheckOrder; import com.eshore.gringotts.web.domain.entity.User; import com.eshore.gringotts.web.domain.entity.Ware; @@ -25,7 +24,7 @@ import org.springframework.stereotype.Service; */ @Slf4j @Service("com.eshore.gringotts.web.domain.service.WareService") -public class WareService extends LogicDeleteService implements CheckingService { +public class WareService extends CheckingService { private final WareRepository wareRepository; private final CheckOrderService checkOrderService; private final ObjectMapper mapper; @@ -64,7 +63,13 @@ public class WareService extends LogicDeleteService implements CheckingSer } } + @Override + public ImmutableMap archive(Ware ware) { + return null; + } + @Transactional(rollbackOn = Throwable.class) + @Override public void submit(Long id) throws JsonProcessingException { Ware ware = detailOrThrow(id); ware.setState(Ware.State.CHECKING); @@ -82,6 +87,7 @@ public class WareService extends LogicDeleteService implements CheckingSer } @Transactional(rollbackOn = Throwable.class) + @Override public void retract(Long id) { Ware ware = detailOrThrow(id); ware.setState(Ware.State.DRAFT);