diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/DetailController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/DetailController.java new file mode 100644 index 0000000..69c5899 --- /dev/null +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/DetailController.java @@ -0,0 +1,11 @@ +package com.eshore.gringotts.web.domain.base.controller; + +import com.eshore.gringotts.web.configuration.amis.AmisResponse; + +/** + * @author lanyuanxiaoyao + * @date 2024-11-28 + */ +public interface DetailController { + AmisResponse detail(Long id) throws Exception; +} diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/ListController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/ListController.java new file mode 100644 index 0000000..2334b4a --- /dev/null +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/ListController.java @@ -0,0 +1,12 @@ +package com.eshore.gringotts.web.domain.base.controller; + +import com.eshore.gringotts.web.configuration.amis.AmisResponse; +import org.eclipse.collections.api.list.ImmutableList; + +/** + * @author lanyuanxiaoyao + * @date 2024-11-28 + */ +public interface ListController { + AmisResponse> list() throws Exception; +} diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/RemoveController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/RemoveController.java new file mode 100644 index 0000000..5728b0a --- /dev/null +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/RemoveController.java @@ -0,0 +1,11 @@ +package com.eshore.gringotts.web.domain.base.controller; + +import com.eshore.gringotts.web.configuration.amis.AmisResponse; + +/** + * @author lanyuanxiaoyao + * @date 2024-11-28 + */ +public interface RemoveController { + AmisResponse remove(Long id) throws Exception; +} diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SaveController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SaveController.java new file mode 100644 index 0000000..5635ddd --- /dev/null +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SaveController.java @@ -0,0 +1,11 @@ +package com.eshore.gringotts.web.domain.base.controller; + +import com.eshore.gringotts.web.configuration.amis.AmisResponse; + +/** + * @author lanyuanxiaoyao + * @date 2024-11-28 + */ +public interface SaveController { + AmisResponse save(SAVE_ITEM item) throws Exception; +} diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleController.java index b92cc2a..e030727 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleController.java @@ -1,18 +1,8 @@ package com.eshore.gringotts.web.domain.base.controller; -import com.eshore.gringotts.web.configuration.amis.AmisResponse; -import org.eclipse.collections.api.set.ImmutableSet; - /** * @author lanyuanxiaoyao * @date 2024-11-28 */ -public interface SimpleController { - AmisResponse save(SAVE_ITEM item) throws Exception; - - AmisResponse> list() throws Exception; - - AmisResponse detail(Long id) throws Exception; - - AmisResponse remove(Long id) throws Exception; +public interface SimpleController extends SaveController, ListController, DetailController, RemoveController { } diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleControllerSupport.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleControllerSupport.java index d758a17..a3b3ad4 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleControllerSupport.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/controller/SimpleControllerSupport.java @@ -3,7 +3,7 @@ package com.eshore.gringotts.web.domain.base.controller; import com.eshore.gringotts.web.configuration.amis.AmisResponse; import com.eshore.gringotts.web.domain.base.entity.SimpleEntity; import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport; -import org.eclipse.collections.api.set.ImmutableSet; +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.PostMapping; @@ -33,7 +33,7 @@ public abstract class SimpleControllerSupport> list() { + public AmisResponse> list() { return AmisResponse.responseSuccess(service.list().collect(entity -> { try { return toListItem(entity); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleService.java index 26d6c40..cd5505d 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleService.java @@ -2,6 +2,7 @@ package com.eshore.gringotts.web.domain.base.service; import com.eshore.gringotts.web.domain.base.entity.SimpleEntity; import java.util.Optional; +import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.set.ImmutableSet; /** @@ -10,11 +11,18 @@ import org.eclipse.collections.api.set.ImmutableSet; */ public interface SimpleService { Long save(ENTITY entity) throws Exception; - ImmutableSet list() throws Exception; - ImmutableSet list(ImmutableSet ids) throws Exception; + + ImmutableList list() throws Exception; + + ImmutableList list(ImmutableSet ids) throws Exception; + Optional detailOptional(Long id) throws Exception; + ENTITY detail(Long id) throws Exception; + ENTITY detailOrThrow(Long id) throws Exception; + ENTITY detailOrNull(Long id) throws Exception; + void remove(Long id) throws Exception; } diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleServiceSupport.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleServiceSupport.java index 8c587b0..d21076e 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleServiceSupport.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/base/service/SimpleServiceSupport.java @@ -13,7 +13,7 @@ import javax.persistence.criteria.Predicate; import javax.transaction.Transactional; import lombok.extern.slf4j.Slf4j; import org.eclipse.collections.api.factory.Lists; -import org.eclipse.collections.api.factory.Sets; +import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.set.ImmutableSet; import org.springframework.data.domain.Sort; @@ -56,8 +56,8 @@ public abstract class SimpleServiceSupport implemen } @Override - public ImmutableSet list() { - return Sets.immutable.ofAll(repository.findAll( + public ImmutableList list() { + return Lists.immutable.ofAll(repository.findAll( (root, query, builder) -> { MutableList predicates = Lists.mutable.empty(); User user = userService.currentLoginUser(); @@ -71,8 +71,8 @@ public abstract class SimpleServiceSupport implemen } @Override - public ImmutableSet list(ImmutableSet ids) { - return Sets.immutable.ofAll(repository.findAll( + public ImmutableList list(ImmutableSet ids) { + return Lists.immutable.ofAll(repository.findAll( (root, query, builder) -> { MutableList predicates = Lists.mutable.of( builder.in(root.get("id")).value(ids.select(ObjectUtil::isNotNull))