diff --git a/src/main/java/com/easysoftware/adapter/query/CoAdminAdapter.java b/src/main/java/com/easysoftware/adapter/query/CoAdminAdapter.java index 97745fee310e4f3a778dc3d83942fee73c292bb6..b3815824c05b78ecbb3594f20a93fafc888031ac 100644 --- a/src/main/java/com/easysoftware/adapter/query/CoAdminAdapter.java +++ b/src/main/java/com/easysoftware/adapter/query/CoAdminAdapter.java @@ -14,6 +14,7 @@ package com.easysoftware.adapter.query; import java.util.HashMap; import com.easysoftware.application.apply.ApplyService; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -100,10 +101,10 @@ public class CoAdminAdapter { * @param applyId The handle form content id. * @return ResponseEntity. */ - @GetMapping("/query/apply") + @GetMapping("/query/records") @RequestLimitRedis() @PreUserPermission(UerPermissionDef.COLLABORATION_PERMISSION_ADMIN) - public ResponseEntity getApply(@RequestParam(value = "applyId") String applyId) { + public ResponseEntity getApply(@RequestParam(value = "applyId") Long applyId) { return applyService.queryApplyHandleRecords(applyId); } } diff --git a/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java b/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java index 893ef7506226a2a03af12673267d07ec7db1b311..188d04c59c0a9a1c49d2732dfa9d2199c9cee3a2 100644 --- a/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java +++ b/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java @@ -20,15 +20,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.easysoftware.application.applyform.ApplyFormService; +import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; import com.easysoftware.application.collaboration.CoMaintainerService; import com.easysoftware.application.collaboration.dto.PackageSearchCondition; import com.easysoftware.common.account.UserPermission; import com.easysoftware.common.annotation.CoMaintainerPermission; -import com.easysoftware.common.annotation.CoUserRepoPermission; import com.easysoftware.common.aop.RequestLimitRedis; import com.easysoftware.common.entity.MessageCode; import com.easysoftware.common.utils.ResultUtil; @@ -55,6 +57,12 @@ public class CoMaintainerAdapter { @Autowired private UserPermission userPermission; + /** + * Autowired service for search applyForm. + */ + @Autowired + private ApplyFormService applyFormService; + /** * Endpoint to search for repos based on the provided search * condition. @@ -64,7 +72,7 @@ public class CoMaintainerAdapter { */ @GetMapping() @RequestLimitRedis() - @CoUserRepoPermission() + @CoMaintainerPermission() public ResponseEntity queryRepos(@RequestParam(value = "repo") String repo) { return ResultUtil.success(HttpStatus.OK, "success"); } @@ -106,4 +114,29 @@ public class CoMaintainerAdapter { return ResultUtil.fail(HttpStatus.UNAUTHORIZED, MessageCode.EC00020); } } + + /** + * Query apply form based on the provided search condition by. + * + * @param condition The search condition for querying apply form. + * @return ResponseEntity. + */ + @GetMapping("/query/apply") + // @RequestLimitRedis() + public ResponseEntity queryApplyFromByMaintainer(@Valid final ApplyFormSearchMaintainerCondition + condition) { + return applyFormService.searchApplyFromByMaintainer(condition); + } + + /** + * Query apply form based on the provided search condition by applyId. + * + * @param applyId The search condition for querying apply form. + * @return ResponseEntity. + */ + @GetMapping("/query/apply/{applyId}") + // @RequestLimitRedis() + public ResponseEntity queryApplyFromByApplyId(@PathVariable("applyId") Long applyId) { + return applyFormService.searchApplyFromByApplyId(applyId); + } } diff --git a/src/main/java/com/easysoftware/application/apply/ApplyService.java b/src/main/java/com/easysoftware/application/apply/ApplyService.java index f731c3e0376f5688a2b4aab72bd1ccade2cb20ee..7d3c42e44e7d1816f455203f8972417b3fb4567e 100644 --- a/src/main/java/com/easysoftware/application/apply/ApplyService.java +++ b/src/main/java/com/easysoftware/application/apply/ApplyService.java @@ -19,5 +19,5 @@ public interface ApplyService { * @param applyId The handle form content id. * @return ResponseEntity. */ - ResponseEntity queryApplyHandleRecords(String applyId); + ResponseEntity queryApplyHandleRecords(Long applyId); } diff --git a/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java b/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java index 8885edb11a5d52afa644b83bcd09ab830f14f0c7..3a1557b5267f450a930b94e1c14112b83d611483 100644 --- a/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java +++ b/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java @@ -37,7 +37,7 @@ public class ApplyServiceImpl implements ApplyService { * @return ResponseEntity. */ @Override - public ResponseEntity queryApplyHandleRecords(String applyId) { + public ResponseEntity queryApplyHandleRecords(Long applyId) { ApplyHandleConditon applyHandleConditon = new ApplyHandleConditon(); applyHandleConditon.setApplyId(applyId); diff --git a/src/main/java/com/easysoftware/application/apply/dto/ApplyHandleConditon.java b/src/main/java/com/easysoftware/application/apply/dto/ApplyHandleConditon.java index f271b9ec5a4f6d1b08ef54e1a863d4a4b0f9c7af..5dfe90a4e827208974f3be9172a12f87682fadc4 100644 --- a/src/main/java/com/easysoftware/application/apply/dto/ApplyHandleConditon.java +++ b/src/main/java/com/easysoftware/application/apply/dto/ApplyHandleConditon.java @@ -16,8 +16,6 @@ public class ApplyHandleConditon { /** * Field name with a maximum length of PackageConstant.MAX_FIELD_LENGTH. */ - @Size(max = PackageConstant.MAX_FIELD_LENGTH) - @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) private Integer applyStatus; @@ -32,9 +30,7 @@ public class ApplyHandleConditon { /** * Package ID with a maximum length of PackageConstant.MAX_FIELD_LENGTH. */ - @Size(max = PackageConstant.MAX_FIELD_LENGTH) - @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) - private String applyId; + private Long applyId; /** diff --git a/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java b/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java new file mode 100644 index 0000000000000000000000000000000000000000..77a6bd6a7ea32ee44135bbd9b9f825226bc880b9 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java @@ -0,0 +1,35 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package com.easysoftware.application.applyform; + +import org.springframework.http.ResponseEntity; + +import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; + +public interface ApplyFormService { + + /** + * Search for apply form based on the provided search condition. + * + * @param condition The search condition for querying apply form. + * @return ResponseEntity. + */ + ResponseEntity searchApplyFromByMaintainer(ApplyFormSearchMaintainerCondition condition); + + /** + *Search for apply form based on the provided search condition by applyId. + * + * @param applyId The search id for querying apply form. + * @return ResponseEntity. + */ + ResponseEntity searchApplyFromByApplyId(Long applyId); +} diff --git a/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java b/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9cf9890c436eabe8c2dffd998968ff1f2e10c796 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java @@ -0,0 +1,88 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.application.applyform; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.vo.ApplyFormContentVO; +import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; +import com.easysoftware.common.exception.NoneResException; +import com.easysoftware.common.exception.ParamErrorException; +import com.easysoftware.common.utils.ResultUtil; +import com.easysoftware.domain.applyform.gateway.ApplyFormGateway; + +import jakarta.annotation.Resource; + +@Service +public class ApplyFormServiceImpl implements ApplyFormService { + + /** + * Resource for interacting with Apply Form Gateway. + */ + @Resource + private ApplyFormGateway applyFormGateway; + + /** + * Search for apply form based on the provided search condition. + * + * @param condition The search condition for querying apply form. + * @return ResponseEntity. + */ + @Override + public ResponseEntity searchApplyFromByMaintainer(ApplyFormSearchMaintainerCondition condition) { + Map map = applyFormGateway.queryApplyFormByMaintainer(condition); + Long total = (Long) map.get("total"); + List appylFormVOs = (List) map.get("list"); + if (total == 0 || appylFormVOs.size() == 0) { + throw new NoneResException("the apply forms is null"); + } + + Map res = new HashMap<>(); + res.put("total", total); + res.put("list", appylFormVOs); + + return ResultUtil.success(HttpStatus.OK, res); + } + + /** + * Search for apply form based on the provided search condition. + * + * @param applyId The search condition for querying apply form by applyId. + * @return ResponseEntity. + */ + @Override + public ResponseEntity searchApplyFromByApplyId(Long applyId) { + if (applyId == null) { + throw new ParamErrorException("the applyId can not be null"); + } + + Map res = applyFormGateway.queryApplyFormByApplyId(applyId); + + Long total = (Long) res.get("total"); + + List list = (List) res.get("list"); + + if (total == 0 || list.size() == 0) { + throw new ParamErrorException("the apply form content does not exist"); + } + + return ResultUtil.success(HttpStatus.OK, res); + + } + +} diff --git a/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java b/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..fb32a6c735d935b30e076c27e56b9a51698618e7 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java @@ -0,0 +1,47 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.application.applyform.dto; + +import org.hibernate.validator.constraints.Range; + +import com.easysoftware.common.constant.PackageConstant; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ApplyFormSearchMaintainerCondition { + + /** + * Page number within the range of PackageConstant.MIN_PAGE_NUM to PackageConstant. + * MAX_PAGE_NUM, default value is 1. + */ + @Range(min = PackageConstant.MIN_PAGE_NUM, max = PackageConstant.MAX_PAGE_NUM) + @NotNull + private Integer pageNum = 1; + + /** + * Page size within the range of PackageConstant.MIN_PAGE_SIZE to PackageConstant. + * MAX_PAGE_SIZE, default value is 10. + */ + @Range(min = PackageConstant.MIN_PAGE_SIZE, max = PackageConstant.MAX_PAGE_SIZE) + @NotNull + private Integer pageSize = 10; + + /** + * Application number. + */ + private Long applyId; +} diff --git a/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormContentVO.java b/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormContentVO.java new file mode 100644 index 0000000000000000000000000000000000000000..7ebfe3d93592b73442849018b6cbc134fc04ac65 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormContentVO.java @@ -0,0 +1,94 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.application.applyform.vo; + +import lombok.Getter; +import lombok.Setter; + +import java.sql.Timestamp; + + +@Getter +@Setter +public class ApplyFormContentVO { + + /** + * Package name. + */ + private String repo; + + /** + * Timestamp for last update. + */ + private Timestamp updateAt; + + /** + * Application type. + */ + private String metric; + + /** + * Modified state. + */ + private String metricStatus; + + /** + * Description of the application form. + */ + private String description; + + /** + * maintainer of the entity. + */ + private String maintainer; + + /** + * Approval status. + */ + private String applyStatus; + + /** + * Application number. + */ + private Long applyId; + + /** + * comment. + */ + private String comment; + + /** + * get an ApplyFormContentVO entity updateAt field value. + * + * @return An Timestamp entity + */ + public Timestamp getUpdateAt() { + if (this.updateAt != null) { + return (Timestamp) this.updateAt.clone(); + } else { + return null; + } + } + + + /** + * set an ApplyFormContentVO entity updateAt field value. + * + * @param updateAt The ApplyFormContentVO entity createAt field for set + */ + public void setUpdateAt(Timestamp updateAt) { + if (updateAt != null) { + this.updateAt = (Timestamp) updateAt.clone(); + } else { + this.updateAt = null; + } + } +} diff --git a/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormSearchMaintainerVO.java b/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormSearchMaintainerVO.java new file mode 100644 index 0000000000000000000000000000000000000000..0231fd18001cb64bac8a782d324d33a0adf815c5 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/vo/ApplyFormSearchMaintainerVO.java @@ -0,0 +1,96 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package com.easysoftware.application.applyform.vo; + +import lombok.Getter; +import lombok.Setter; + +import java.sql.Timestamp; + + +@Getter +@Setter +public class ApplyFormSearchMaintainerVO { + /** + * Package name. + */ + private String repo; + + /** + * Timestamp for last update. + */ + private Timestamp updateAt; + + /** + * Application type. + */ + private String metric; + + /** + * Modified state. + */ + private String metricStatus; + + /** + * Description of the application form. + */ + private String description; + + /** + * maintainer of the entity. + */ + private String maintainer; + + /** + * adminstrator of the entity. + */ + private String adminstrator; + + + /** + * Approval status. + */ + private String applyStatus; + + /** + * Application number. + */ + private Long applyId; + + + /** + * get an ApplyFormSearchMaintainerVO entity updateAt field value. + * + * @return An Timestamp entity + */ + public Timestamp getUpdateAt() { + if (this.updateAt != null) { + return (Timestamp) this.updateAt.clone(); + } else { + return null; + } + } + + + /** + * set an ApplyFormSearchMaintainerVO entity updateAt field value. + * + * @param updateAt The ApplyFormSearchMaintainerVO entity createAt field for set + */ + public void setUpdateAt(Timestamp updateAt) { + if (updateAt != null) { + this.updateAt = (Timestamp) updateAt.clone(); + } else { + this.updateAt = null; + } + } +} diff --git a/src/main/java/com/easysoftware/application/filedapplication/FieldApplicationServiceImpl.java b/src/main/java/com/easysoftware/application/filedapplication/FieldApplicationServiceImpl.java index 494de13db25c8d9a9e0cac484c1612da7bada2b3..2ac5d1f5cbc514a2adb42c3d994926e718d71b33 100644 --- a/src/main/java/com/easysoftware/application/filedapplication/FieldApplicationServiceImpl.java +++ b/src/main/java/com/easysoftware/application/filedapplication/FieldApplicationServiceImpl.java @@ -27,6 +27,7 @@ import com.easysoftware.application.rpmpackage.RPMPackageService; import com.easysoftware.application.rpmpackage.dto.RPMPackageSearchCondition; import com.easysoftware.application.rpmpackage.vo.RPMPackageDetailVo; import com.easysoftware.common.constant.PackageConstant; +import com.easysoftware.common.constant.RedisConstant; import com.easysoftware.common.entity.MessageCode; import com.easysoftware.common.exception.ParamErrorException; import com.easysoftware.common.exception.enumvalid.AppCategoryEnum; @@ -43,6 +44,7 @@ import com.easysoftware.domain.oepackage.gateway.OEPackageGateway; import com.easysoftware.domain.rpmpackage.gateway.RPMPackageGateway; import com.easysoftware.infrastructure.fieldapplication.gatewayimpl.converter.FieldApplicationConverter; import com.easysoftware.ranking.Ranker; +import com.easysoftware.redis.RedisGateway; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; @@ -60,6 +62,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; @Service public class FieldApplicationServiceImpl implements FieldApplicationService { @@ -132,6 +135,11 @@ public class FieldApplicationServiceImpl implements FieldApplicationService { */ @Resource private ArchNumGateway archNumGateway; + /** + * gateway. + */ + @Resource + private RedisGateway redisGateway; /** * Query menu by name. @@ -441,11 +449,24 @@ public class FieldApplicationServiceImpl implements FieldApplicationService { */ @Override public ResponseEntity queryStat() { + Long opekgNum; Long appNum = appGateway.queryTableLength(); + String opeknumString = redisGateway.get(RedisConstant.DISTINCT_OPEKGNUM); + + if (opeknumString != null) { + opekgNum = Long.parseLong(opeknumString); + } else { + opekgNum = oePkgGateway.queryTableLength(); + if (opekgNum != null && opekgNum > PackageConstant.SOFTWARE_NUM) { + String opekgNumString = String.valueOf(opekgNum); + redisGateway.setWithExpire(RedisConstant.DISTINCT_OPEKGNUM, opekgNumString, 90, TimeUnit.MINUTES); + } + } Map res = new HashMap<>(); res.put("apppkg", appNum); - res.put("total", PackageConstant.SOFTWARE_NUM); + res.put("total", opekgNum); + return ResultUtil.success(HttpStatus.OK, res); } diff --git a/src/main/java/com/easysoftware/common/constant/PackageConstant.java b/src/main/java/com/easysoftware/common/constant/PackageConstant.java index 8aec50a5c66750894ad6d12d3b3b120021ce2929..73942b0ede395bea7216017114ebe776309ca646 100644 --- a/src/main/java/com/easysoftware/common/constant/PackageConstant.java +++ b/src/main/java/com/easysoftware/common/constant/PackageConstant.java @@ -178,4 +178,9 @@ public final class PackageConstant { * package status keyword format. */ public static final String KEY_WORD_FORMAT = " AND %s.keyword:%s"; + + /** + * table name of ApplyForm. + */ + public static final String APPLY_FORM_TABLE = "apply_form"; } diff --git a/src/main/java/com/easysoftware/common/constant/RedisConstant.java b/src/main/java/com/easysoftware/common/constant/RedisConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..9ce990c3683f9e7fe2cff798371a55d864dadeba --- /dev/null +++ b/src/main/java/com/easysoftware/common/constant/RedisConstant.java @@ -0,0 +1,26 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package com.easysoftware.common.constant; + +public final class RedisConstant { + + // Private constructor to prevent instantiation of the RedisConstant class + private RedisConstant() { + // private constructor to hide the implicit public one + throw new AssertionError("RedisConstant class cannot be instantiated."); + } + + /** + * Key of distinct_opekg_nums. + */ + public static final String DISTINCT_OPEKGNUM = "distinct_opekg_num"; +} diff --git a/src/main/java/com/easysoftware/domain/apply/ApplyHandleRecord.java b/src/main/java/com/easysoftware/domain/apply/ApplyHandleRecord.java index e54a917776df21b26c8b0806335d4b92d3efd9f0..27cad2685b75d411b8a50ced2c1763800ea83710 100644 --- a/src/main/java/com/easysoftware/domain/apply/ApplyHandleRecord.java +++ b/src/main/java/com/easysoftware/domain/apply/ApplyHandleRecord.java @@ -39,13 +39,18 @@ public class ApplyHandleRecord { /** * apply Id. */ - private String applyId; + private Long applyId; /** * recordId. */ private Long recordId; + /** + * comment. + */ + private String comment; + /** * maintainer. */ @@ -82,7 +87,7 @@ public class ApplyHandleRecord { * @param createAt The ApplicationPackageDO entity createAt field for set */ public void setCreatedAt(Timestamp createAt) { - if (this.createdAt != null) { + if (createAt != null) { this.createdAt = (Timestamp) createAt.clone(); } else { this.createdAt = null; diff --git a/src/main/java/com/easysoftware/domain/applyform/ApplyForm.java b/src/main/java/com/easysoftware/domain/applyform/ApplyForm.java new file mode 100644 index 0000000000000000000000000000000000000000..0efe3aaae0c178606508f6c157fe1e103c5e7c9f --- /dev/null +++ b/src/main/java/com/easysoftware/domain/applyform/ApplyForm.java @@ -0,0 +1,97 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package com.easysoftware.domain.applyform; + +import java.sql.Timestamp; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ApplyForm { + + /** + * Package name. + */ + private String repo; + + /** + * Timestamp for last update. + */ + private Timestamp updateAt; + + /** + * Application type. + */ + private String metric; + + /** + * Modified state. + */ + private String metricStatus; + + /** + * Description of the application form. + */ + private String description; + + /** + * maintainer of the entity. + */ + private String maintainer; + + /** + * adminstrator of the entity. + */ + private String adminstrator; + + + /** + * Approval status. + */ + private String applyStatus; + + /** + * Application number. + */ + private Long applyId; + + + /** + * get an ApplyForm entity updateAt field value. + * + * @return An Timestamp entity + */ + public Timestamp getUpdateAt() { + if (this.updateAt != null) { + return (Timestamp) this.updateAt.clone(); + } else { + return null; + } + } + + + /** + * set an ApplyForm entity updateAt field value. + * + * @param updateAt The ApplyForm entity createAt field for set + */ + public void setUpdateAt(Timestamp updateAt) { + if (updateAt != null) { + this.updateAt = (Timestamp) updateAt.clone(); + } else { + this.updateAt = null; + } + } + +} diff --git a/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java b/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java new file mode 100644 index 0000000000000000000000000000000000000000..31eebac0efca0e916b68438dee3c815db6ed3d65 --- /dev/null +++ b/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java @@ -0,0 +1,38 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.domain.applyform.gateway; + +import java.util.Map; + +import org.springframework.stereotype.Component; + +import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; + + +@Component +public interface ApplyFormGateway { + + /** + * Query information based on the provided search condition. + * + * @param condition The search condition for querying apply form + * @return A map containing relevant information + */ + Map queryApplyFormByMaintainer(ApplyFormSearchMaintainerCondition condition); + + /** + * Query information based on the provided search condition by appId. + * + * @param applyId The search condition for querying apply form + * @return A map containing relevant information + */ + Map queryApplyFormByApplyId(Long applyId); +} diff --git a/src/main/java/com/easysoftware/infrastructure/applicationversion/gatewayimpl/ApplicationVersionGatewayImpl.java b/src/main/java/com/easysoftware/infrastructure/applicationversion/gatewayimpl/ApplicationVersionGatewayImpl.java index 6cf95c74fc2d271bcd2312cd775b1256ead8cd6a..376cc61c9ffcdd5ce1b40fbe810db3916bf17dfa 100644 --- a/src/main/java/com/easysoftware/infrastructure/applicationversion/gatewayimpl/ApplicationVersionGatewayImpl.java +++ b/src/main/java/com/easysoftware/infrastructure/applicationversion/gatewayimpl/ApplicationVersionGatewayImpl.java @@ -63,7 +63,9 @@ public class ApplicationVersionGatewayImpl implements ApplicationVersionGateway List appDOs = resPage.getRecords(); List appDetails = ApplicationVersionConvertor.toEntity(appDOs); - Map res = Map.ofEntries(Map.entry("total", resPage.getTotal()), Map.entry("list", appDetails)); + Map res = Map.ofEntries( + Map.entry("total", resPage.getTotal()), + Map.entry("list", appDetails)); return res; } diff --git a/src/main/java/com/easysoftware/infrastructure/apply/gatewayimpl/dataobject/ApplyhandleRecordsDO.java b/src/main/java/com/easysoftware/infrastructure/apply/gatewayimpl/dataobject/ApplyhandleRecordsDO.java index a551611c7aeaef075b8c48c3475b6390ae5870a9..430f12f67d5997f5750a617d87143a9b0b445bad 100644 --- a/src/main/java/com/easysoftware/infrastructure/apply/gatewayimpl/dataobject/ApplyhandleRecordsDO.java +++ b/src/main/java/com/easysoftware/infrastructure/apply/gatewayimpl/dataobject/ApplyhandleRecordsDO.java @@ -34,13 +34,18 @@ public class ApplyhandleRecordsDO { /** * apply Id. */ - private String applyId; + private Long applyId; /** * recordId. */ private Long recordId; + /** + * comment. + */ + private String comment; + /** * maintainer. */ @@ -77,7 +82,7 @@ public class ApplyhandleRecordsDO { * @param createAt The ApplicationPackageDO entity createAt field for set */ public void setCreatedAt(Timestamp createAt) { - if (this.createdAt != null) { + if (createAt != null) { this.createdAt = (Timestamp) createAt.clone(); } else { this.createdAt = null; diff --git a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b8be46adebdb5176ef7f289708d3c75502e41327 --- /dev/null +++ b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java @@ -0,0 +1,108 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.infrastructure.applyform.gatewayimpl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.vo.ApplyFormContentVO; +import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; +import com.easysoftware.domain.applyform.gateway.ApplyFormGateway; +import com.easysoftware.infrastructure.apply.gatewayimpl.dataobject.ApplyhandleRecordsDO; +import com.easysoftware.infrastructure.applyform.gatewayimpl.converter.ApplyFormConvertor; +import com.easysoftware.infrastructure.applyform.gatewayimpl.dataobject.ApplyFormDO; +import com.easysoftware.infrastructure.mapper.ApplyFormDOMapper; +import com.easysoftware.infrastructure.mapper.ApplyHandleRecordsDOMapper; + +@Component +public class ApplyFormGatewayImpl implements ApplyFormGateway { + + /** + * Autowired field for the ApplicationVersionDOMapper. + */ + @Autowired + private ApplyFormDOMapper applyFormDOMapper; + + /** + * Autowired field for the ApplyHandleRecordsDOMapper. + */ + @Autowired + private ApplyHandleRecordsDOMapper applyHandleRecordsDOMapper; + + /** + * Query information based on the provided search condition. + * + * @param condition The search condition for querying apply form + * @return A map containing relevant information + */ + @Override + public Map queryApplyFormByMaintainer(ApplyFormSearchMaintainerCondition condition) { + int pageNum = condition.getPageNum(); + int pageSize = condition.getPageSize(); + Page page = new Page<>(pageNum, pageSize); + IPage resPage = applyFormDOMapper.selectPage(page, null); + + long total = resPage.getTotal(); + List applyFormDOs = resPage.getRecords(); + List applyFormVOs = ApplyFormConvertor.toApplyFormVO(applyFormDOs); + + Map res = new HashMap<>(); + res.put("total", total); + res.put("list", applyFormVOs); + + return res; + + } + + /** + * Query information based on the provided search condition. + * + * @param applyId The search condition for querying apply form + * @return A map containing relevant information + */ + public Map queryApplyFormByApplyId(Long applyId) { + QueryWrapper queryWrapperForm = new QueryWrapper<>(); + queryWrapperForm.eq("apply_id", applyId); + + List applyFormListDOs = applyFormDOMapper.selectList(queryWrapperForm); + List applyFormListVOs = ApplyFormConvertor.toApplyFormVO(applyFormListDOs); + + QueryWrapper queryWrapperRecords = new QueryWrapper<>(); + queryWrapperRecords.eq("apply_id", applyId); + + List applyhandleRecordsDOs = applyHandleRecordsDOMapper.selectList(queryWrapperRecords); + + List applyFormContentVOs = new ArrayList<>(); + for (ApplyFormSearchMaintainerVO applyFormVO : applyFormListVOs) { + ApplyFormContentVO applyFormContentVO = new ApplyFormContentVO(); + BeanUtils.copyProperties(applyFormVO, applyFormContentVO); + applyFormContentVO.setComment(applyhandleRecordsDOs.get(0).getComment()); + applyFormContentVOs.add(applyFormContentVO); + } + + Map res = new HashMap<>(); + res.put("total", (long) applyFormContentVOs.size()); + res.put("list", applyFormContentVOs); + + return res; + } + +} diff --git a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/converter/ApplyFormConvertor.java b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/converter/ApplyFormConvertor.java new file mode 100644 index 0000000000000000000000000000000000000000..66dd65a4e63be198d8cbca75518a5f6bdb4906b2 --- /dev/null +++ b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/converter/ApplyFormConvertor.java @@ -0,0 +1,88 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.infrastructure.applyform.gatewayimpl.converter; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.BeanUtils; + +import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; +import com.easysoftware.domain.applyform.ApplyForm; +import com.easysoftware.infrastructure.applyform.gatewayimpl.dataobject.ApplyFormDO; + + +public final class ApplyFormConvertor { + + // Private constructor to prevent instantiation of the utility class + private ApplyFormConvertor() { + // private constructor to hide the implicit public one + throw new AssertionError("Cannot instantiate ApplyFormConvertor class"); + } + + /** + * Convert an ApplyFormDO object to an ApplyForm entity. + * + * @param applyFormDO The ApplyFormDO object to convert + * @return An ApplyForm entity + */ + public static ApplyForm toEntity(final ApplyFormDO applyFormDO) { + ApplyForm applyForm = new ApplyForm(); + BeanUtils.copyProperties(applyFormDO, applyForm); + return applyForm; + } + + /** + * Convert a list of ApplicationVersionDO objects to a list of + * ApplyForm entities. + * + * @param applyFormDOs The list of ApplicationVersionDO objects to convert + * @return A list of ApplyForm entities + */ + public static List toEntity(final List applyFormDOs) { + List res = new ArrayList<>(); + for (ApplyFormDO applyFormDO : applyFormDOs) { + ApplyForm applyForm = toEntity(applyFormDO); + res.add(applyForm); + } + return res; + } + + /** + * Convert a list of ApplicationVersionDO objects to a list of + * ApplyFormVOs Lists. + * + * @param applyFormDO The ApplyFormSearchMaintainerVO objects to convert + * @return A list of ApplyForm entities + */ + public static ApplyFormSearchMaintainerVO toApplyFormVO(final ApplyFormDO applyFormDO) { + ApplyFormSearchMaintainerVO applyFormVO = new ApplyFormSearchMaintainerVO(); + BeanUtils.copyProperties(applyFormDO, applyFormVO); + return applyFormVO; + } + + /** + * Convert a list of ApplicationVersionDO objects to a list of + * ApplyFormVOs Lists. + * + * @param applyFormDOs The list of ApplyFormSearchMaintainerVO objects to convert + * @return A list of ApplyForm entities + */ + public static List toApplyFormVO(final List applyFormDOs) { + List res = new ArrayList<>(); + for (ApplyFormDO applyFormDO : applyFormDOs) { + ApplyFormSearchMaintainerVO applyFormVO = toApplyFormVO(applyFormDO); + res.add(applyFormVO); + } + return res; + } + +} diff --git a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/dataobject/ApplyFormDO.java b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/dataobject/ApplyFormDO.java new file mode 100644 index 0000000000000000000000000000000000000000..28b1515c242e0c9518e29a18fa10d21c7412e987 --- /dev/null +++ b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/dataobject/ApplyFormDO.java @@ -0,0 +1,134 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.infrastructure.applyform.gatewayimpl.dataobject; + +import java.sql.Timestamp; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.easysoftware.common.constant.PackageConstant; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@TableName(PackageConstant.APPLY_FORM_TABLE) +public class ApplyFormDO { + + /** + * Timestamp for creation. + */ + private Timestamp createdAt; + + /** + * Package name. + */ + private String repo; + + /** + * Timestamp for last update. + */ + private Timestamp updateAt; + + /** + * Application type. + */ + private String metric; + + /** + * Modified state. + */ + private String metricStatus; + + /** + * Description of the application form. + */ + private String description; + + /** + * maintainer of the entity. + */ + private String maintainer; + + /** + * adminstrator of the entity. + */ + private String adminstrator; + + + /** + * Approval status. + */ + private String applyStatus; + + /** + * Application number. + */ + @TableId(value = "apply_id") + private Long applyId; + + + /** + * get an ApplyFormDO entity updateAt field value. + * + * @return An Timestamp entity + */ + public Timestamp getUpdateAt() { + if (this.updateAt != null) { + return (Timestamp) this.updateAt.clone(); + } else { + return null; + } + } + + + /** + * get an ApplyFormDO entity updateAt field value. + * + * @return An Timestamp entity + */ + public Timestamp getCreatedAt() { + if (this.createdAt != null) { + return (Timestamp) this.createdAt.clone(); + } else { + return null; + } + } + + + /** + * set an ApplyFormDO entity createAt field value. + * + * @param createdAt The ApplicationPackageDO entity createAt field for set + */ + public void setCreatedAt(Timestamp createdAt) { + if (createdAt != null) { + this.createdAt = (Timestamp) createdAt.clone(); + } else { + this.createdAt = null; + } + } + + + /** + * set an ApplyFormDO entity createAt field value. + * + * @param updateAt The ApplicationPackageDO entity createAt field for set + */ + public void setUpdateAt(Timestamp updateAt) { + if (updateAt != null) { + this.updateAt = (Timestamp) updateAt.clone(); + } else { + this.updateAt = null; + } + } +} diff --git a/src/main/java/com/easysoftware/infrastructure/mapper/ApplyFormDOMapper.java b/src/main/java/com/easysoftware/infrastructure/mapper/ApplyFormDOMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..e4999c74bc58e63f5326f3b9b799ed10ac3738a9 --- /dev/null +++ b/src/main/java/com/easysoftware/infrastructure/mapper/ApplyFormDOMapper.java @@ -0,0 +1,18 @@ +/* Copyright (c) 2024 openEuler Community + EasySoftware is licensed under the Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ +package com.easysoftware.infrastructure.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easysoftware.infrastructure.applyform.gatewayimpl.dataobject.ApplyFormDO; + +public interface ApplyFormDOMapper extends BaseMapper { + +}