From 8626376b74ec5ecb5c22eb986561f5e39bfb1b6b Mon Sep 17 00:00:00 2001 From: XLR_asd <xueyawei@seaskysh.com> Date: Wed, 2 Jun 2021 17:23:23 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=20=E7=94=B3=E6=8A=A5=E4=B9=A64=E4=B8=AA?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=20=E4=BB=93=E5=82=A8=E5=B1=82?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectInfoplan/PlanSubjectEntity.java | 5 + .../projectInfoplan/ProjectInfoPlanAgg.java | 1 - .../projectInfoplan/ProjectTargetEntity.java | 4 + .../projectInfoplan/SubjectDetailEntity.java | 5 + .../projectdailyplan/PlanSubjectEntity.java | 5 + .../projectdailyplan/SubjectDetailEntity.java | 7 +- .../PersonSubjectEntity.java | 5 + .../po/PlanBookSubjectDetailPo.java | 3 + .../PlanBookPersonSubjectConvert.java | 27 +++ .../PlanBookPersonSubjectRepository.java | 29 +++ .../PlanBookPersonSubjectRepositoryImpl.java | 73 ++++++++ .../PlanBookSubjectConvert.java | 40 ++++ .../PlanBookSubjectRepository.java | 45 +++++ .../PlanBookSubjectRepositoryImpl.java | 171 ++++++++++++++++++ .../PlanBookSubjectDetailConvert.java | 56 ++++++ .../PlanBookSubjectDetailRepository.java | 45 +++++ .../PlanBookSubjectDetailRepositoryImpl.java | 123 +++++++++++++ .../planbooktarget/PlanBookTargetConvert.java | 25 +++ .../PlanBookTargetRepository.java | 28 +++ .../PlanBookTargetRepositoryImpl.java | 67 +++++++ .../ProjectInfoRepositoryImpl.java | 15 +- .../PlanBookPersonSubjectRepository.java | 14 -- 22 files changed, 770 insertions(+), 23 deletions(-) create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectConvert.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepository.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepositoryImpl.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectConvert.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepository.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepositoryImpl.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailConvert.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepository.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepositoryImpl.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetConvert.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepository.java create mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepositoryImpl.java delete mode 100644 ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectplanentity/PlanBookPersonSubjectRepository.java diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/PlanSubjectEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/PlanSubjectEntity.java index ee731351..7c3f2c1b 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/PlanSubjectEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/PlanSubjectEntity.java @@ -19,6 +19,11 @@ import java.util.List; @ToString(callSuper = true) public class PlanSubjectEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; + /** * 缁忔祹绉戠洰鍚嶇О */ diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectInfoPlanAgg.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectInfoPlanAgg.java index 27ecf4a0..dcc8f94d 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectInfoPlanAgg.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectInfoPlanAgg.java @@ -1,6 +1,5 @@ package com.seasky.projectplan.domain.aggregate.projectInfoplan; -import com.seasky.projectplan.domain.aggregate.common.PlanTypeEnum; import com.seasky.projectplan.domain.aggregate.projectplanbase.ProjectPlanBaseAgg; import lombok.*; diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectTargetEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectTargetEntity.java index 9d095cf8..92346b2a 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectTargetEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/ProjectTargetEntity.java @@ -16,6 +16,10 @@ import lombok.*; @ToString(callSuper = true) public class ProjectTargetEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; /** * 鎽樿json diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/SubjectDetailEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/SubjectDetailEntity.java index e4e3fca0..0fe85be6 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/SubjectDetailEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectInfoplan/SubjectDetailEntity.java @@ -18,6 +18,11 @@ import java.math.BigDecimal; @ToString(callSuper = true) public class SubjectDetailEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; + /** * 灏忚閲戦 */ diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/PlanSubjectEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/PlanSubjectEntity.java index 3b4f5a58..202e80d1 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/PlanSubjectEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/PlanSubjectEntity.java @@ -19,6 +19,11 @@ import java.util.List; @ToString(callSuper = true) public class PlanSubjectEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; + /** * 缁忔祹绉戠洰鍚嶇О */ diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/SubjectDetailEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/SubjectDetailEntity.java index 54d5cedc..1e3708ac 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/SubjectDetailEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectdailyplan/SubjectDetailEntity.java @@ -18,6 +18,11 @@ import java.math.BigDecimal; @ToString(callSuper = true) public class SubjectDetailEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; + /** * 灏忚閲戦 */ @@ -28,6 +33,4 @@ public class SubjectDetailEntity extends BaseEntity { */ private String otherJson; - - } diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectpersonplan/PersonSubjectEntity.java b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectpersonplan/PersonSubjectEntity.java index f5cfeaa6..eec3bf30 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectpersonplan/PersonSubjectEntity.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/domain/aggregate/projectpersonplan/PersonSubjectEntity.java @@ -18,6 +18,11 @@ import java.math.BigDecimal; @ToString(callSuper = true) public class PersonSubjectEntity extends BaseEntity { + /** + * 涓婚敭id + */ + private Long id; + /** * 浜哄憳绉戠洰鍚嶇О */ diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/dataobject/po/PlanBookSubjectDetailPo.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/dataobject/po/PlanBookSubjectDetailPo.java index 38757c29..bf0ee29d 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/dataobject/po/PlanBookSubjectDetailPo.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/dataobject/po/PlanBookSubjectDetailPo.java @@ -28,6 +28,9 @@ public class PlanBookSubjectDetailPo extends BaseDataObject { @ApiModelProperty("璁″垝涔� id") private Long planBookId; + @TableField("plan_book_id") + @ApiModelProperty("璁″垝涔� id") + private Long parentId; @TableField("subtotal") @ApiModelProperty("灏忚閲戦") diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectConvert.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectConvert.java new file mode 100644 index 00000000..1fef2161 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectConvert.java @@ -0,0 +1,27 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbookpersonsubject; + +import com.seasky.core.ddd.utils.MapperUtils; +import com.seasky.projectplan.domain.aggregate.projectpersonplan.ProjectPersonPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookPersonSubjectPo; + +import java.util.List; + +/** + * 浜哄憳绉戠洰瀛愰泦瀵硅薄 宸ュ巶绫� + * + * @author XueYawei + * @date 2021/06/02 + */ +public class PlanBookPersonSubjectConvert { + + /** + * 鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link List<PlanBookPersonSubjectPo>} + */ + public static List<PlanBookPersonSubjectPo> aggEntityListToPoList(ProjectPersonPlanAgg projectPersonPlanAgg){ + return MapperUtils.INSTANCE.mapAsList(PlanBookPersonSubjectPo.class,projectPersonPlanAgg.getPersonSubjectList()); + } + +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepository.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepository.java new file mode 100644 index 00000000..6f9c3b41 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepository.java @@ -0,0 +1,29 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbookpersonsubject; + +import com.seasky.projectplan.domain.aggregate.projectpersonplan.ProjectPersonPlanAgg; + +/** + * 鐢虫姤涔� 浜哄憳绉戠洰瀛愰泦瀵硅薄 浠撳偍灞� + * + * @author XueYawei + * @date 2021/06/01 + */ +public interface PlanBookPersonSubjectRepository { + + /** + * 淇濆瓨浜哄憳缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link Integer} + */ + Integer saveProjectPersonPlanEntity(ProjectPersonPlanAgg projectPersonPlanAgg); + + /** + * 鍒犻櫎浜哄憳缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link Integer} + */ + Integer removeProjectPersonPlanEntity(ProjectPersonPlanAgg projectPersonPlanAgg); + +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepositoryImpl.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepositoryImpl.java new file mode 100644 index 00000000..1ccfe86d --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbookpersonsubject/PlanBookPersonSubjectRepositoryImpl.java @@ -0,0 +1,73 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbookpersonsubject; + +import com.seasky.core.common.Error; +import com.seasky.core.common.ResponseCode; +import com.seasky.core.enums.Available; +import com.seasky.core.exception.DataAccessException; +import com.seasky.projectplan.domain.aggregate.projectpersonplan.ProjectPersonPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookPersonSubjectPo; +import com.seasky.projectplan.infrastructure.db.mapper.table.PlanBookPersonSubjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 鐢虫姤涔� 浜哄憳绉戠洰瀛愰泦瀵硅薄 浠撳偍灞俰mpl + * + * @author XueYawei + * @date 2021/06/01 + */ +@Repository +public class PlanBookPersonSubjectRepositoryImpl implements PlanBookPersonSubjectRepository { + + @Autowired + PlanBookPersonSubjectMapper mapper; + + + /** + * 淇濆瓨浜哄憳缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link Integer} + */ + @Override + public Integer saveProjectPersonPlanEntity(ProjectPersonPlanAgg projectPersonPlanAgg) { + List<PlanBookPersonSubjectPo> planBookPersonSubjectPoList = PlanBookPersonSubjectConvert.aggEntityListToPoList(projectPersonPlanAgg); + for (PlanBookPersonSubjectPo po : planBookPersonSubjectPoList) { + if (po.getId() == null){ + //鏂板鏃惰祴鍊肩埗绾d + po.setPlanBookId(projectPersonPlanAgg.getId()); + po.prepareBeforeInsert(); + if (mapper.insert(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "浜哄憳绉戠洰 淇℃伅鏂板澶辫触", "")); + } + }else{ + po.prepareBeforeUpdate(); + if (mapper.updateById(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "浜哄憳绉戠洰 淇℃伅淇敼澶辫触", "")); + } + } + } + return 1; + } + + /** + * 鍒犻櫎浜哄憳缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link Integer} + */ + @Override + public Integer removeProjectPersonPlanEntity(ProjectPersonPlanAgg projectPersonPlanAgg) { + List<PlanBookPersonSubjectPo> planBookPersonSubjectPoList = PlanBookPersonSubjectConvert.aggEntityListToPoList(projectPersonPlanAgg); + for (PlanBookPersonSubjectPo po : planBookPersonSubjectPoList) { + po.available(Available.NO); + po.prepareBeforeUpdate(); +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "浜哄憳绉戠洰 淇℃伅鍒犻櫎澶辫触", "")); +// } + } + return 1; + } +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectConvert.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectConvert.java new file mode 100644 index 00000000..ee7b8143 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectConvert.java @@ -0,0 +1,40 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubject; + +import com.seasky.core.ddd.utils.MapperUtils; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectpersonplan.ProjectPersonPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookPersonSubjectPo; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookSubjectPo; + +import java.util.List; + +/** + * 缁忔祹绉戠洰瀹炰綋 宸ュ巶绫� + * + * @author XueYawei + * @date 2021/06/02 + */ +public class PlanBookSubjectConvert { + + /** + * 鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link List<PlanBookSubjectPo>} + */ + public static List<PlanBookSubjectPo> InfoAggEntityListToPoList(ProjectInfoPlanAgg projectInfoPlanAgg){ + return MapperUtils.INSTANCE.mapAsList(PlanBookSubjectPo.class,projectInfoPlanAgg.getPlanSubjectList()); + } + + /** + * 鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link List<PlanBookSubjectPo>} + */ + public static List<PlanBookSubjectPo> DailyAggEntityListToPoList(ProjectDailyPlanAgg projectDailyPlanAgg){ + return MapperUtils.INSTANCE.mapAsList(PlanBookSubjectPo.class,projectDailyPlanAgg.getSubjectDetailList()); + } + +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepository.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepository.java new file mode 100644 index 00000000..2198e1fe --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepository.java @@ -0,0 +1,45 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubject; + +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; + +/** + * 缁忔祹绉戠洰瀹炰綋 浠撳偍灞� + * + * @author XueYawei + * @date 2021/06/02 + */ +public interface PlanBookSubjectRepository { + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg); + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer removeProjectInfoPlanAggEntity(ProjectInfoPlanAgg projectInfoPlanAgg); + + /** + * 淇濆瓨鏃ュ父缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer saveProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg); + + /** + * 鍒犻櫎鏃ュ父缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer removeProjectDailyPlanEntity(ProjectDailyPlanAgg projectInfoPlanAgg); +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepositoryImpl.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepositoryImpl.java new file mode 100644 index 00000000..a964b6d6 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubject/PlanBookSubjectRepositoryImpl.java @@ -0,0 +1,171 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubject; + +import com.seasky.core.common.Error; +import com.seasky.core.common.ResponseCode; +import com.seasky.core.enums.Available; +import com.seasky.core.exception.DataAccessException; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookSubjectPo; +import com.seasky.projectplan.infrastructure.db.mapper.table.PlanBookSubjectMapper; +import com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubjectdetail.PlanBookSubjectDetailRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 鐢虫姤涔� 缁忔祹绉戠洰瀹炰綋 浠撳偍灞俰mpl + * + * @author XueYawei + * @date 2021/06/02 + */ +@Repository +public class PlanBookSubjectRepositoryImpl implements PlanBookSubjectRepository { + + @Autowired + PlanBookSubjectMapper mapper; + + @Autowired + PlanBookSubjectDetailRepository subjectDetailRepository; + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer}i + */ + @Override + public Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + List<PlanBookSubjectPo> planBookSubjectPos = PlanBookSubjectConvert.InfoAggEntityListToPoList(projectInfoPlanAgg); + //淇濆瓨缁忔祹绉戠洰 骞� 鍒ゆ柇缁忔祹绉戠洰鏄庣粏鏄惁瀛樺湪 + Boolean existDetail = false; + for (int i = 0; i < planBookSubjectPos.size(); i++) { + if (planBookSubjectPos.get(i).getId() == null){ + planBookSubjectPos.get(i).setPlanBookId(projectInfoPlanAgg.getId()); + } + savePo(planBookSubjectPos.get(i)); + projectInfoPlanAgg.getPlanSubjectList().get(i).setId(planBookSubjectPos.get(i).getId()); + if (projectInfoPlanAgg.getPlanSubjectList().get(i).getSubjectDetailList() !=null){ + existDetail = true; + } + } + //淇濆瓨缁忔祹绉戠洰鏄庣粏 + if (existDetail){ + subjectDetailRepository.saveProjectInfoPlanEntity(projectInfoPlanAgg); + } + return 1; + } + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer removeProjectInfoPlanAggEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + List<PlanBookSubjectPo> planBookSubjectPos = PlanBookSubjectConvert.InfoAggEntityListToPoList(projectInfoPlanAgg); + for (PlanBookSubjectPo po : planBookSubjectPos) { + po.available(Available.NO); + po.prepareBeforeUpdate(); + //TODO mapper鏂规硶娣诲姞 logicDelete 鍙栨秷娉ㄩ噴 +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅鍒犻櫎澶辫触", "")); +// } + } + //鍒ゆ柇缁忔祹绉戠洰鏄庣粏鏄惁瀛樺湪 + Boolean existDetail = false; + for (int i = 0; i < projectInfoPlanAgg.getPlanSubjectList().size(); i++) { + if (projectInfoPlanAgg.getPlanSubjectList().get(i).getSubjectDetailList() !=null){ + existDetail = true; + break; + } + } + //鍒犻櫎缁忔祹绉戠洰鏄庣粏 + if (existDetail){ + subjectDetailRepository.removeProjectInfoPlanAggEntity(projectInfoPlanAgg); + } + return 1; + } + + /** + * 淇濆瓨鏃ュ父缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer saveProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg) { + List<PlanBookSubjectPo> planBookSubjectPos = PlanBookSubjectConvert.DailyAggEntityListToPoList(projectDailyPlanAgg); + //淇濆瓨缁忔祹绉戠洰 骞� 鍒ゆ柇缁忔祹绉戠洰鏄庣粏鏄惁瀛樺湪 + Boolean existDetail = false; + for (int i = 0; i < planBookSubjectPos.size(); i++) { + if (planBookSubjectPos.get(i).getId() == null){ + planBookSubjectPos.get(i).setPlanBookId(projectDailyPlanAgg.getId()); + } + savePo(planBookSubjectPos.get(i)); + projectDailyPlanAgg.getSubjectDetailList().get(i).setId(planBookSubjectPos.get(i).getId()); + if (projectDailyPlanAgg.getSubjectDetailList().get(i).getSubjectDetailList() !=null){ + existDetail = true; + } + } + //淇濆瓨缁忔祹绉戠洰鏄庣粏 + if (existDetail){ + subjectDetailRepository.saveProjectDailyPlanEntity(projectDailyPlanAgg); + } + return 1; + } + + /** + * 鍒犻櫎鏃ュ父缁忚垂鐢虫姤涔︾粡娴庣鐩疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer removeProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg) { + List<PlanBookSubjectPo> planBookSubjectPos = PlanBookSubjectConvert.DailyAggEntityListToPoList(projectDailyPlanAgg); + for (PlanBookSubjectPo po : planBookSubjectPos) { + po.available(Available.NO); + po.prepareBeforeUpdate(); + //TODO mapper鏂规硶娣诲姞 logicDelete 鍙栨秷娉ㄩ噴 +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅鍒犻櫎澶辫触", "")); +// } + } + //鍒ゆ柇缁忔祹绉戠洰鏄庣粏鏄惁瀛樺湪 + Boolean existDetail = false; + for (int i = 0; i < projectDailyPlanAgg.getSubjectDetailList().size(); i++) { + if (projectDailyPlanAgg.getSubjectDetailList().get(i).getSubjectDetailList() !=null){ + existDetail = true; + break; + } + } + //鍒犻櫎缁忔祹绉戠洰鏄庣粏 + if (existDetail){ + subjectDetailRepository.removeProjectDailyPlanEntity(projectDailyPlanAgg); + } + return 1; + } + + + /** + * 淇濆瓨po绫� + * + * @param po po绫� + */ + public void savePo(PlanBookSubjectPo po){ + if (po.getId() == null){ + po.prepareBeforeInsert(); + if (mapper.insert(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅鏂板澶辫触", "")); + } + }else{ + po.prepareBeforeUpdate(); + if (mapper.updateById(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅淇敼澶辫触", "")); + } + } + } +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailConvert.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailConvert.java new file mode 100644 index 00000000..5525b6be --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailConvert.java @@ -0,0 +1,56 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubjectdetail; + +import com.seasky.core.ddd.utils.MapperUtils; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookPersonSubjectPo; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookSubjectDetailPo; + +import java.util.ArrayList; +import java.util.List; + +/** + * 鐢虫姤涔� 绉戠洰鏄庣粏瀹炰綋 宸ュ巶绫� + * + * @author XueYawei + * @date 2021/06/02 + */ +public class PlanBookSubjectDetailConvert { + + /** + * 椤圭洰缁忚垂鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link List<PlanBookSubjectDetailPo>} + */ + public static List<PlanBookSubjectDetailPo> InfoAggEntityListToPoList(ProjectInfoPlanAgg projectInfoPlanAgg){ + List<PlanBookSubjectDetailPo> poList = new ArrayList<>(); + for (int i = 0; i < projectInfoPlanAgg.getPlanSubjectList().size(); i++) { + if (projectInfoPlanAgg.getPlanSubjectList().get(i).getSubjectDetailList() !=null){ + List<PlanBookSubjectDetailPo> pos = MapperUtils.INSTANCE.mapAsList(PlanBookSubjectDetailPo.class, projectInfoPlanAgg.getPlanSubjectList().get(i).getSubjectDetailList()); + if (pos.get(0).getId() == null){ + pos.get(0).setParentId(projectInfoPlanAgg.getPlanSubjectList().get(i).getId()); + } + poList.addAll(pos); + } + } + return poList; + } + + /** + * 鏃ュ父缁忚垂鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link List<PlanBookSubjectDetailPo>} + */ + public static List<PlanBookSubjectDetailPo> DailyAggEntityListToPoList(ProjectDailyPlanAgg projectDailyPlanAgg){ + List<PlanBookSubjectDetailPo> poList = new ArrayList<>(); + for (int i = 0; i < projectDailyPlanAgg.getSubjectDetailList().size(); i++) { + if (projectDailyPlanAgg.getSubjectDetailList().get(i).getSubjectDetailList() !=null){ + List<PlanBookSubjectDetailPo> pos = MapperUtils.INSTANCE.mapAsList(PlanBookSubjectDetailPo.class, projectDailyPlanAgg.getSubjectDetailList().get(i).getSubjectDetailList()); + poList.addAll(pos); + } + } + return poList; + } +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepository.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepository.java new file mode 100644 index 00000000..7bea7d32 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepository.java @@ -0,0 +1,45 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubjectdetail; + +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; + +/** + * 鐢虫姤涔� 绉戠洰鏄庣粏瀹炰綋 浠撳偍灞� + * + * @author XueYawei + * @date 2021/06/02 + */ +public interface PlanBookSubjectDetailRepository { + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectPersonPlanAgg 椤圭洰浜鸿鍒掕仛鍚堟牴 + * @return {@link Integer} + */ + Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectPersonPlanAgg); + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer removeProjectInfoPlanAggEntity(ProjectInfoPlanAgg projectInfoPlanAgg); + + /** + * 淇濆瓨鏃ュ父缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer saveProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg); + + /** + * 鍒犻櫎鏃ュ父缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer removeProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg); +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepositoryImpl.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepositoryImpl.java new file mode 100644 index 00000000..afa93b7d --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooksubjectdetail/PlanBookSubjectDetailRepositoryImpl.java @@ -0,0 +1,123 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooksubjectdetail; + +import com.seasky.core.common.Error; +import com.seasky.core.common.ResponseCode; +import com.seasky.core.enums.Available; +import com.seasky.core.exception.DataAccessException; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.domain.aggregate.projectdailyplan.ProjectDailyPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookSubjectDetailPo; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookSubjectPo; +import com.seasky.projectplan.infrastructure.db.mapper.table.PlanBookSubjectDetailMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 鐢虫姤涔� 绉戠洰鏄庣粏瀹炰綋 浠撳偍灞俰mpl + * + * @author XueYawei + * @date 2021/06/02 + */ +@Repository +public class PlanBookSubjectDetailRepositoryImpl implements PlanBookSubjectDetailRepository { + + @Autowired + PlanBookSubjectDetailMapper mapper; + + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + List<PlanBookSubjectDetailPo> planBookSubjectDetailPos = PlanBookSubjectDetailConvert.InfoAggEntityListToPoList(projectInfoPlanAgg); + //淇濆瓨缁忔祹绉戠洰 + for (PlanBookSubjectDetailPo po : planBookSubjectDetailPos) { + savePo(po); + } + return 1; + } + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer removeProjectInfoPlanAggEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + List<PlanBookSubjectDetailPo> planBookSubjectDetailPos = PlanBookSubjectDetailConvert.InfoAggEntityListToPoList(projectInfoPlanAgg); + for (PlanBookSubjectDetailPo po : planBookSubjectDetailPos) { + po.available(Available.NO); + po.prepareBeforeUpdate(); + //TODO mapper鏂规硶娣诲姞 logicDelete 鍙栨秷娉ㄩ噴 +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅鍒犻櫎澶辫触", "")); +// } + } + return 1; + } + + /** + * 淇濆瓨鏃ュ父缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer saveProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg) { + List<PlanBookSubjectDetailPo> planBookSubjectDetailPos = PlanBookSubjectDetailConvert.DailyAggEntityListToPoList(projectDailyPlanAgg); + //淇濆瓨缁忔祹绉戠洰 + for (PlanBookSubjectDetailPo po : planBookSubjectDetailPos) { + savePo(po); + } + return 1; + } + + /** + * 鍒犻櫎鏃ュ父缁忚垂鐢虫姤涔︾鐩槑缁嗗疄浣� + * + * @param projectDailyPlanAgg 椤圭洰姣忓ぉ璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer removeProjectDailyPlanEntity(ProjectDailyPlanAgg projectDailyPlanAgg) { + List<PlanBookSubjectDetailPo> planBookSubjectDetailPos = PlanBookSubjectDetailConvert.DailyAggEntityListToPoList(projectDailyPlanAgg); + for (PlanBookSubjectDetailPo po : planBookSubjectDetailPos) { + po.available(Available.NO); + po.prepareBeforeUpdate(); + //TODO mapper鏂规硶娣诲姞 logicDelete 鍙栨秷娉ㄩ噴 +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰 淇℃伅鍒犻櫎澶辫触", "")); +// } + } + return 1; + } + + + + /** + * 淇濆瓨po绫� + * + * @param po po绫� + */ + public void savePo(PlanBookSubjectDetailPo po){ + if (po.getId() == null){ + po.prepareBeforeInsert(); + if (mapper.insert(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰鏄庣粏 淇℃伅鏂板澶辫触", "")); + } + }else{ + po.prepareBeforeUpdate(); + if (mapper.updateById(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "缁忔祹绉戠洰鏄庣粏 淇℃伅淇敼澶辫触", "")); + } + } + } + +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetConvert.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetConvert.java new file mode 100644 index 00000000..0c1f5f6b --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetConvert.java @@ -0,0 +1,25 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooktarget; + +import com.seasky.core.ddd.utils.MapperUtils; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookTargetPo; + + +/** + * 椤圭洰缁╂晥鐨勫疄浣� 宸ュ巶绫� + * + * @author XueYawei + * @date 2021/06/02 + */ +public class PlanBookTargetConvert { + + /** + * 鑱氬悎鏍瑰疄浣揕ist杞琾o绫籐ist + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link PlanBookTargetPo} + */ + public static PlanBookTargetPo aggEntityListToPoList(ProjectInfoPlanAgg projectInfoPlanAgg){ + return MapperUtils.INSTANCE.map(PlanBookTargetPo.class,projectInfoPlanAgg.getProjectTargetInfo()); + } +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepository.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepository.java new file mode 100644 index 00000000..d3befcb1 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepository.java @@ -0,0 +1,28 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooktarget; + +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; + +/** + * 椤圭洰缁忚垂鐢虫姤涔� 椤圭洰缁╂晥鐨勫疄浣� 浠撳偍灞� + * + * @author XueYawei + * @date 2021/06/02 + */ +public interface PlanBookTargetRepository { + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg); + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + Integer removeProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg); +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepositoryImpl.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepositoryImpl.java new file mode 100644 index 00000000..f14caee5 --- /dev/null +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/planbooktarget/PlanBookTargetRepositoryImpl.java @@ -0,0 +1,67 @@ +package com.seasky.projectplan.infrastructure.repository.projectplanbook.planbooktarget; + +import com.seasky.core.common.Error; +import com.seasky.core.common.ResponseCode; +import com.seasky.core.enums.Available; +import com.seasky.core.exception.DataAccessException; +import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; +import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookTargetPo; +import com.seasky.projectplan.infrastructure.db.mapper.table.PlanBookTargetMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +/** + * 鐢虫姤涔� 椤圭洰缁╂晥鐨勫疄浣� 浠撳偍灞俰mpl + * + * @author XueYawei + * @date 2021/06/02 + */ +@Repository +public class PlanBookTargetRepositoryImpl implements PlanBookTargetRepository { + + @Autowired + PlanBookTargetMapper mapper; + + + /** + * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer saveProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + PlanBookTargetPo po = PlanBookTargetConvert.aggEntityListToPoList(projectInfoPlanAgg); + if (po.getId() == null){ + //鏂板鏃惰祴鍊肩埗绾d + po.setPlanBookId(projectInfoPlanAgg.getId()); + po.prepareBeforeInsert(); + if (mapper.insert(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "椤圭洰缁╂晥 淇℃伅鏂板澶辫触", "")); + } + }else{ + po.prepareBeforeUpdate(); + if (mapper.updateById(po) != 1){ + throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "椤圭洰缁╂晥 淇℃伅淇敼澶辫触", "")); + } + } + return 1; + } + + /** + * 鍒犻櫎椤圭洰缁忚垂鐢虫姤涔﹀疄浣� + * + * @param projectInfoPlanAgg 椤圭洰淇℃伅璁″垝鑱氬悎鏍� + * @return {@link Integer} + */ + @Override + public Integer removeProjectInfoPlanEntity(ProjectInfoPlanAgg projectInfoPlanAgg) { + PlanBookTargetPo po = PlanBookTargetConvert.aggEntityListToPoList(projectInfoPlanAgg); + po.available(Available.NO); + po.prepareBeforeUpdate(); +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "椤圭洰缁╂晥 淇℃伅鍒犻櫎澶辫触", "")); +// } + return 1; + } +} diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectinfoplan/ProjectInfoRepositoryImpl.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectinfoplan/ProjectInfoRepositoryImpl.java index 5bf8aac0..d9ef400a 100644 --- a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectinfoplan/ProjectInfoRepositoryImpl.java +++ b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectinfoplan/ProjectInfoRepositoryImpl.java @@ -3,13 +3,12 @@ package com.seasky.projectplan.infrastructure.repository.projectplanbook.project import com.seasky.core.common.Error; import com.seasky.core.common.ResponseCode; import com.seasky.core.ddd.base.DomainKeysMap; +import com.seasky.core.enums.Available; import com.seasky.core.exception.DataAccessException; import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoPlanAgg; import com.seasky.projectplan.domain.aggregate.projectInfoplan.ProjectInfoRepository; import com.seasky.projectplan.infrastructure.dataobject.po.FundPo; -import com.seasky.projectplan.infrastructure.dataobject.po.PlanBookTargetPo; import com.seasky.projectplan.infrastructure.dataobject.po.ProjectPlanBookPo; -import com.seasky.projectplan.infrastructure.db.mapper.table.PlanBookTargetMapper; import com.seasky.projectplan.infrastructure.db.mapper.table.ProjectPlanBookMapper; import com.seasky.projectplan.infrastructure.repository.fund.FundConvert; import org.springframework.beans.factory.annotation.Autowired; @@ -29,9 +28,6 @@ public class ProjectInfoRepositoryImpl implements ProjectInfoRepository { @Autowired ProjectPlanBookMapper mapper; - @Autowired - PlanBookTargetMapper planBookTargetMapper; - /** * 淇濆瓨椤圭洰缁忚垂鐢虫姤涔� @@ -65,7 +61,14 @@ public class ProjectInfoRepositoryImpl implements ProjectInfoRepository { */ @Override public Integer removeProjectInfoPlan(ProjectInfoPlanAgg projectInfoPlanAgg) { - return null; + ProjectPlanBookPo projectPlanBookPo = ProjectInfoConvert.aggToPo(projectInfoPlanAgg); + projectPlanBookPo.available(Available.NO); + projectPlanBookPo.prepareBeforeUpdate(); +// if (mapper.logicDelete(projectPlanBookPo) != 1){ +// throw new DataAccessException(new Error(ResponseCode.SERVER_INTERNAL_EXCEPTION, null, "椤圭洰缁忚垂鐢虫姤涔� 淇℃伅鍒犻櫎澶辫触", "")); +// } + //TODO 鑱氬悎瀛愮被瀵硅薄鍒犻櫎鏂规硶璋冪敤 + return 1; } /** diff --git a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectplanentity/PlanBookPersonSubjectRepository.java b/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectplanentity/PlanBookPersonSubjectRepository.java deleted file mode 100644 index 6ec72e97..00000000 --- a/ServiceSite/src/main/java/com/seasky/projectplan/infrastructure/repository/projectplanbook/projectplanentity/PlanBookPersonSubjectRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.seasky.projectplan.infrastructure.repository.projectplanbook.projectplanentity; - -/** - * 鐢虫姤涔� 浜哄憳绉戠洰瀛愰泦瀵硅薄 浠撳偍灞� - * - * @author XueYawei - * @date 2021/06/01 - */ -public interface PlanBookPersonSubjectRepository { - - - - -} -- GitLab