From 1d25b34db9ee73d20ef0586334aed7404b87b635 Mon Sep 17 00:00:00 2001 From: xiaqihang <xiaqihang@seaskysh.com> Date: Wed, 25 Aug 2021 09:29:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestAssembler.java} | 4 +- .../command/{api => test}/TestCmdService.java | 62 +++--- .../{service => test}/TestCmdServiceImpl.java | 207 +++++++++--------- .../{api => service}/TestDomainService.java | 2 +- .../domain/service/TestDomainServiceImpl.java | 1 - .../interfaces/controller/TestController.java | 2 +- .../controller/test/TestControllerTest.java | 2 +- 7 files changed, 139 insertions(+), 141 deletions(-) rename ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/{factory/TestFactory.java => assembler/TestAssembler.java} (88%) rename ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/{api => test}/TestCmdService.java (85%) rename ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/{service => test}/TestCmdServiceImpl.java (78%) rename ServiceSite/src/main/java/com/seasky/dddtemplate/domain/{api => service}/TestDomainService.java (88%) diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/factory/TestFactory.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/assembler/TestAssembler.java similarity index 88% rename from ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/factory/TestFactory.java rename to ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/assembler/TestAssembler.java index a2670ae..de2a0c4 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/factory/TestFactory.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/assembler/TestAssembler.java @@ -1,4 +1,4 @@ -package com.seasky.dddtemplate.application.command.factory; +package com.seasky.dddtemplate.application.command.assembler; import com.seasky.core.ddd.utils.MapperUtils; @@ -14,7 +14,7 @@ import java.util.Map; * @author XueYawei * @date 2020/12/07 */ -public class TestFactory { +public class TestAssembler { /** diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/api/TestCmdService.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdService.java similarity index 85% rename from ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/api/TestCmdService.java rename to ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdService.java index ded4e56..2b1f0b3 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/api/TestCmdService.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdService.java @@ -1,31 +1,31 @@ -package com.seasky.dddtemplate.application.command.api; - -import com.seasky.dddtemplate.dto.test.TestCmd; - -public interface TestCmdService { - /** - * 淇濆瓨绀轰緥 - * - * @param testCmd 娴嬭瘯cmd - * @return int - */ - Long SaveTest(TestCmd testCmd); - - /** - * 鎻愪氦绀轰緥 - * - * @param testCmd 娴嬭瘯cmd - * @return int - */ - Long SubmitTest(TestCmd testCmd); - - /** - * 淇濆瓨骞舵彁浜ょず渚� - * - * @param testCmd 娴嬭瘯cmd - * @return int - */ - Long SavaAndSubmitTest(TestCmd testCmd); - - void Delete(TestCmd testCmd); -} +package com.seasky.dddtemplate.application.command.test; + +import com.seasky.dddtemplate.dto.test.TestCmd; + +public interface TestCmdService { + /** + * 淇濆瓨绀轰緥 + * + * @param testCmd 娴嬭瘯cmd + * @return int + */ + Long SaveTest(TestCmd testCmd); + + /** + * 鎻愪氦绀轰緥 + * + * @param testCmd 娴嬭瘯cmd + * @return int + */ + Long SubmitTest(TestCmd testCmd); + + /** + * 淇濆瓨骞舵彁浜ょず渚� + * + * @param testCmd 娴嬭瘯cmd + * @return int + */ + Long SavaAndSubmitTest(TestCmd testCmd); + + void Delete(TestCmd testCmd); +} diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/service/TestCmdServiceImpl.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdServiceImpl.java similarity index 78% rename from ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/service/TestCmdServiceImpl.java rename to ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdServiceImpl.java index 6f61141..7c05696 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/service/TestCmdServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/application/command/test/TestCmdServiceImpl.java @@ -1,104 +1,103 @@ -package com.seasky.dddtemplate.application.command.service; - -import com.seasky.dddtemplate.application.command.api.TestCmdService; -import com.seasky.dddtemplate.application.command.factory.TestFactory; -import com.seasky.dddtemplate.domain.aggregate.test.TestAggregate; -import com.seasky.dddtemplate.domain.aggregate.test.TestRepository; -import com.seasky.dddtemplate.domain.api.TestDomainService; -import com.seasky.dddtemplate.domain.event.DeleteTestEvent; -import com.seasky.dddtemplate.domain.event.SendMessageEvent; -import com.seasky.dddtemplate.dto.test.TestCmd; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class TestCmdServiceImpl implements TestCmdService { - @Autowired - private TestDomainService testDomainService; - - @Autowired - private TestRepository testRepository; - - @Autowired - private SendMessageEvent sendMessageEvent; - - @Autowired - private DeleteTestEvent deleteTestEvent; - /** - * 淇濆瓨 - * - * @param testCmd - * @return {@link Long} - */ - @Override - public Long SaveTest(TestCmd testCmd) { - TestAggregate testAggregate = TestFactory.buildTestAggregate(testCmd); - return this.save(testAggregate); - } - - /** - * 鎻愪氦 - * - * @param testCmd - * @return {@link int} - */ - @Override - public Long SubmitTest(TestCmd testCmd) { - TestAggregate testAggregate = TestFactory.buildTestAggregate(testCmd); - this.submit(testAggregate); - return 0l; - } - - /** - * 淇濆瓨骞舵彁浜� - * - * @param testCmd - * @return {@link int} - */ - @Override - public Long SavaAndSubmitTest(TestCmd testCmd) { - TestAggregate testAggregate = TestFactory.buildTestAggregate(testCmd); - Long result = this.save(testAggregate); - this.submit(testAggregate); - return result; - } - - /** - * 鍒犻櫎 - * - * @param testCmd - * @return {@link int} - */ - @Override - public void Delete(TestCmd testCmd) { - TestAggregate testAggregate = TestFactory.buildTestAggregate(testCmd); - deleteTestEvent.DeleteVerify(testAggregate.getCode()); - testRepository.remove(testAggregate); - } - - /** - * 淇濆瓨鍏辩敤鏂规硶 - * - * @param testAggregate - * @return {@link Long} - */ - private Long save(TestAggregate testAggregate){ - TestAggregate aggregate = testRepository.findByPersistentId(testAggregate.getId()); - aggregate = aggregate.updata(testAggregate); - return testRepository.save(aggregate); - } - - /** - * 鎻愪氦鍏辩敤鏂规硶 - * - * @param testAggregate - * @return {@link TestAggregate} - */ - private TestAggregate submit(TestAggregate testAggregate) { - testAggregate = testDomainService.submitTest(testAggregate); - String message = testAggregate.BuildSubmitMessage(); - // 姝ゅ璋冪敤flowRepository 鏍规嵁 涓氬姟鍗曞彿鑾峰彇瀹℃牳鐢ㄦ埛鍒楄〃 - sendMessageEvent.send(message,"鑾峰彇鍒扮殑鐢ㄦ埛鍒楄〃"); - return testAggregate; - } -} +package com.seasky.dddtemplate.application.command.test; + +import com.seasky.dddtemplate.application.command.assembler.TestAssembler; +import com.seasky.dddtemplate.domain.aggregate.test.TestAggregate; +import com.seasky.dddtemplate.domain.aggregate.test.TestRepository; +import com.seasky.dddtemplate.domain.service.TestDomainService; +import com.seasky.dddtemplate.domain.event.DeleteTestEvent; +import com.seasky.dddtemplate.domain.event.SendMessageEvent; +import com.seasky.dddtemplate.dto.test.TestCmd; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TestCmdServiceImpl implements TestCmdService { + @Autowired + private TestDomainService testDomainService; + + @Autowired + private TestRepository testRepository; + + @Autowired + private SendMessageEvent sendMessageEvent; + + @Autowired + private DeleteTestEvent deleteTestEvent; + /** + * 淇濆瓨 + * + * @param testCmd + * @return {@link Long} + */ + @Override + public Long SaveTest(TestCmd testCmd) { + TestAggregate testAggregate = TestAssembler.buildTestAggregate(testCmd); + return this.save(testAggregate); + } + + /** + * 鎻愪氦 + * + * @param testCmd + * @return {@link int} + */ + @Override + public Long SubmitTest(TestCmd testCmd) { + TestAggregate testAggregate = TestAssembler.buildTestAggregate(testCmd); + this.submit(testAggregate); + return 0l; + } + + /** + * 淇濆瓨骞舵彁浜� + * + * @param testCmd + * @return {@link int} + */ + @Override + public Long SavaAndSubmitTest(TestCmd testCmd) { + TestAggregate testAggregate = TestAssembler.buildTestAggregate(testCmd); + Long result = this.save(testAggregate); + this.submit(testAggregate); + return result; + } + + /** + * 鍒犻櫎 + * + * @param testCmd + * @return {@link int} + */ + @Override + public void Delete(TestCmd testCmd) { + TestAggregate testAggregate = TestAssembler.buildTestAggregate(testCmd); + deleteTestEvent.DeleteVerify(testAggregate.getCode()); + testRepository.remove(testAggregate); + } + + /** + * 淇濆瓨鍏辩敤鏂规硶 + * + * @param testAggregate + * @return {@link Long} + */ + private Long save(TestAggregate testAggregate){ + TestAggregate aggregate = testRepository.findByPersistentId(testAggregate.getId()); + aggregate = aggregate.updata(testAggregate); + return testRepository.save(aggregate); + } + + /** + * 鎻愪氦鍏辩敤鏂规硶 + * + * @param testAggregate + * @return {@link TestAggregate} + */ + private TestAggregate submit(TestAggregate testAggregate) { + testAggregate = testDomainService.submitTest(testAggregate); + String message = testAggregate.BuildSubmitMessage(); + // 姝ゅ璋冪敤flowRepository 鏍规嵁 涓氬姟鍗曞彿鑾峰彇瀹℃牳鐢ㄦ埛鍒楄〃 + sendMessageEvent.send(message,"鑾峰彇鍒扮殑鐢ㄦ埛鍒楄〃"); + return testAggregate; + } +} diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/api/TestDomainService.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainService.java similarity index 88% rename from ServiceSite/src/main/java/com/seasky/dddtemplate/domain/api/TestDomainService.java rename to ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainService.java index 00ff77a..5c934b9 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/api/TestDomainService.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainService.java @@ -1,4 +1,4 @@ -package com.seasky.dddtemplate.domain.api; +package com.seasky.dddtemplate.domain.service; import com.seasky.dddtemplate.domain.aggregate.test.TestAggregate; diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainServiceImpl.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainServiceImpl.java index 7c004ca..1d69364 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/domain/service/TestDomainServiceImpl.java @@ -3,7 +3,6 @@ package com.seasky.dddtemplate.domain.service; import com.seasky.dddtemplate.domain.aggregate.test.TestAggregate; import com.seasky.dddtemplate.domain.aggregate.test.TestRepository; -import com.seasky.dddtemplate.domain.api.TestDomainService; import com.seasky.dddtemplate.domain.event.DeleteTestEvent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; diff --git a/ServiceSite/src/main/java/com/seasky/dddtemplate/interfaces/controller/TestController.java b/ServiceSite/src/main/java/com/seasky/dddtemplate/interfaces/controller/TestController.java index 53fa680..9a2c2b7 100644 --- a/ServiceSite/src/main/java/com/seasky/dddtemplate/interfaces/controller/TestController.java +++ b/ServiceSite/src/main/java/com/seasky/dddtemplate/interfaces/controller/TestController.java @@ -4,7 +4,7 @@ package com.seasky.dddtemplate.interfaces.controller; import com.seasky.core.common.ResponseCode; import com.seasky.core.common.Result; import com.seasky.dddtemplate.api.ITestController; -import com.seasky.dddtemplate.application.command.api.TestCmdService; +import com.seasky.dddtemplate.application.command.test.TestCmdService; import com.seasky.dddtemplate.application.query.TestQueryService; import com.seasky.dddtemplate.dto.test.TestCmd; import com.seasky.dddtemplate.dto.test.TestQueryOut; diff --git a/ServiceSite/src/test/java/com/seasky/dddtemplate/interfaces/controller/test/TestControllerTest.java b/ServiceSite/src/test/java/com/seasky/dddtemplate/interfaces/controller/test/TestControllerTest.java index 279fd58..57ea341 100644 --- a/ServiceSite/src/test/java/com/seasky/dddtemplate/interfaces/controller/test/TestControllerTest.java +++ b/ServiceSite/src/test/java/com/seasky/dddtemplate/interfaces/controller/test/TestControllerTest.java @@ -1,7 +1,7 @@ package com.seasky.dddtemplate.interfaces.controller.test; import com.seasky.core.ddd.test.PoAssertions; -import com.seasky.dddtemplate.application.command.api.TestCmdService; +import com.seasky.dddtemplate.application.command.test.TestCmdService; import com.seasky.dddtemplate.application.query.TestQueryService; import com.seasky.dddtemplate.dto.test.TestQueryOut; import com.seasky.dddtemplate.infrastructure.db.mapper.table.TestMapper; -- GitLab