diff --git a/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java b/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java index b1d88c90db2cf7bb5130468e98c97237025a401a..8c2780fff930d3ac5ef974781dc33b6549f5b4c5 100644 --- a/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java +++ b/src/main/java/com/easysoftware/adapter/query/CoMaintainerAdapter.java @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController; import com.easysoftware.application.applyform.ApplyFormService; import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.dto.MyApply; import com.easysoftware.application.collaboration.CoMaintainerService; import com.easysoftware.application.collaboration.dto.PackageSearchCondition; import com.easysoftware.common.account.UserPermission; @@ -35,6 +36,9 @@ import com.easysoftware.common.entity.MessageCode; import com.easysoftware.common.utils.ResultUtil; import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + @RestController @RequestMapping("/collaboration/maintainer") @@ -115,7 +119,7 @@ public class CoMaintainerAdapter { } /** - * Query apply form based on the provided search condition by. + * Query apply form based on the provided search condition. * * @param condition The search condition for querying apply form. * @return ResponseEntity. @@ -127,4 +131,44 @@ public class CoMaintainerAdapter { condition) { return applyFormService.searchApplyFromByMaintainer(condition); } + + /** + * Submit apply form based on the provided body. + * + * @param myApply The submit condition for querying apply form. + * @return ResponseEntity. + */ + @PostMapping("/apply") + @RequestLimitRedis() + @CoMaintainerPermission() + public ResponseEntity submitMyApply(@Valid @RequestBody MyApply myApply) { + return applyFormService.submitMyApplyWithLimit(myApply); + } + + /** + * Revoke apply form based on the provided body. + * + * @param myApply The revoke condition for querying apply form. + * @return ResponseEntity. + */ + @PostMapping("/revoke") + @RequestLimitRedis() + @CoMaintainerPermission() + public ResponseEntity revokeMyApply(@Valid @RequestBody MyApply myApply) { + return applyFormService.revokeMyApplyWithLimit(myApply); + } + + /** + * Update apply form based on the provided body. + * + * @param myApply The update condition for querying apply form. + * @return ResponseEntity. + */ + @PostMapping("/update") + @RequestLimitRedis() + @CoMaintainerPermission() + public ResponseEntity updateMyApply(@Valid @RequestBody MyApply myApply) { + return applyFormService.updateMyApplyWithLimit(myApply); + } + } diff --git a/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java b/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java index 3a1557b5267f450a930b94e1c14112b83d611483..e2291c744b0a3236bc9f623e1a0564a729ce05c7 100644 --- a/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java +++ b/src/main/java/com/easysoftware/application/apply/ApplyServiceImpl.java @@ -14,7 +14,10 @@ import com.easysoftware.application.apply.dto.ApplyHandleConditon; import com.easysoftware.common.utils.ResultUtil; import com.easysoftware.domain.apply.ApplyHandleRecord; import com.easysoftware.domain.apply.gateway.ApplyGateway; + +import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -28,6 +31,7 @@ public class ApplyServiceImpl implements ApplyService { /** * Resource for interacting with Apply Gateway. */ + @Resource private final ApplyGateway applyGateway; /** diff --git a/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java b/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java index 355c7104b075536661bce9fe77eb951f53f37328..526acf3f09251fb1ca2fc4f7b520d7806f235304 100644 --- a/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java +++ b/src/main/java/com/easysoftware/application/applyform/ApplyFormService.java @@ -15,6 +15,7 @@ import com.easysoftware.application.applyform.dto.ApplyFormSearchAdminCondition; import org.springframework.http.ResponseEntity; import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.dto.MyApply; import com.easysoftware.application.applyform.dto.ProcessApply; public interface ApplyFormService { @@ -42,4 +43,28 @@ public interface ApplyFormService { * @return ResponseEntity. */ ResponseEntity searchApplyFromByAdmin(ApplyFormSearchAdminCondition condition); + + /** + * Submit my apply. + * + * @param myApply The condition for submiting apply form. + * @return ResponseEntity. + */ + ResponseEntity submitMyApplyWithLimit(MyApply myApply); + + /** + * Revoke my apply. + * + * @param myApply The condition for revoking apply form. + * @return ResponseEntity. + */ + ResponseEntity revokeMyApplyWithLimit(MyApply myApply); + + /** + * Update my apply. + * + * @param myApply The condition for update apply form. + * @return ResponseEntity. + */ + ResponseEntity updateMyApplyWithLimit(MyApply myApply); } diff --git a/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java b/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java index 5d07386aab74a459d98ee4b5527cefe106fdf2ae..7e36ddbd8c3341fd2885d7ad85dbb1c3f1fcf2e1 100644 --- a/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java +++ b/src/main/java/com/easysoftware/application/applyform/ApplyFormServiceImpl.java @@ -20,9 +20,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.dto.MyApply; import com.easysoftware.application.applyform.dto.ProcessApply; import com.easysoftware.application.applyform.vo.ApplyFormContentVO; import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; +import com.easysoftware.common.exception.DeleteException; +import com.easysoftware.common.exception.InsertException; import com.easysoftware.common.exception.NoneResException; import com.easysoftware.common.exception.ParamErrorException; import com.easysoftware.common.exception.UpdateException; @@ -137,4 +140,49 @@ public class ApplyFormServiceImpl implements ApplyFormService { return ResultUtil.success(HttpStatus.OK); } + /** + * Submit apply based on the provided condition. + * + * @param myApply The process condition for submit apply form by applyId. + * @return ResponseEntity. + */ + @Override + public ResponseEntity submitMyApplyWithLimit(MyApply myApply) { + boolean flag = applyFormGateway.submitMyApplyWithLimit(myApply); + if (!flag) { + throw new InsertException("submit apply failed"); + } + return ResultUtil.success(HttpStatus.OK); + } + + /** + * revoke apply based on the provided condition. + * + * @param myApply The process condition for revoke apply form by applyId. + * @return ResponseEntity. + */ + @Override + public ResponseEntity revokeMyApplyWithLimit(MyApply myApply) { + boolean flag = applyFormGateway.revokeMyApplyWithLimit(myApply); + if (!flag) { + throw new DeleteException("revoke apply failed"); + } + return ResultUtil.success(HttpStatus.OK); + } + + /** + * update apply based on the provided condition. + * + * @param myApply The process condition for update apply form by applyId. + * @return ResponseEntity. + */ + @Override + public ResponseEntity updateMyApplyWithLimit(MyApply myApply) { + boolean flag = applyFormGateway.updateMyApplyWithLimit(myApply); + if (!flag) { + throw new UpdateException("update apply failed"); + } + return ResultUtil.success(HttpStatus.OK); + } + } diff --git a/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java b/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java index 7e96185f3f739b527584554e23a6535d7c66a784..be55fcf42341ec8774a373e21279f0a34f1ebdaa 100644 --- a/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java +++ b/src/main/java/com/easysoftware/application/applyform/dto/ApplyFormSearchMaintainerCondition.java @@ -50,7 +50,7 @@ public class ApplyFormSearchMaintainerCondition { private String name; /** - * Application number. + * apply number. */ private Long applyId; } diff --git a/src/main/java/com/easysoftware/application/applyform/dto/MyApply.java b/src/main/java/com/easysoftware/application/applyform/dto/MyApply.java new file mode 100644 index 0000000000000000000000000000000000000000..97d87946e70b37816b40d031b326a89441cc6263 --- /dev/null +++ b/src/main/java/com/easysoftware/application/applyform/dto/MyApply.java @@ -0,0 +1,63 @@ +/* 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 com.easysoftware.common.constant.PackageConstant; + +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class MyApply { + + /** + * Package name (maximum length: PackageConstant.MAX_FIELD_LENGTH). + */ + @Size(max = PackageConstant.MAX_FIELD_LENGTH) + @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) + private String repo; + + /** + * Apply type (maximum length: PackageConstant.MAX_FIELD_LENGTH). + */ + @Size(max = PackageConstant.MAX_FIELD_LENGTH) + @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) + private String metric; + + /** + * Modified state (maximum length: PackageConstant.MAX_FIELD_LENGTH). + */ + @Size(max = PackageConstant.MAX_FIELD_LENGTH) + @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) + private String metricStatus; + + /** + * Description reason (maximum length: PackageConstant.MAX_FIELD_LENGTH). + */ + @Size(max = PackageConstant.MAX_FIELD_LENGTH) + @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) + private String description; + + /** + * Approval status (maximum length: PackageConstant.MAX_FIELD_LENGTH). + */ + @Size(max = PackageConstant.MAX_FIELD_LENGTH) + @Pattern(regexp = PackageConstant.VALID_STR_REG, message = PackageConstant.VALID_MESSAGE) + private String applyStatus; + + /** + * Apply form number. + */ + private Long applyId; +} diff --git a/src/main/java/com/easysoftware/common/constant/PackageConstant.java b/src/main/java/com/easysoftware/common/constant/PackageConstant.java index 371890bf7d36004dfb027083de2d66942d5d7ea8..61c1d2c8dc48d4a8f9da8a504517e2d9e4641442 100644 --- a/src/main/java/com/easysoftware/common/constant/PackageConstant.java +++ b/src/main/java/com/easysoftware/common/constant/PackageConstant.java @@ -253,4 +253,14 @@ public final class PackageConstant { * apply status. */ public static final String APPLY_APPROVED = "approved"; + + /** + * applytId in apply_form table. + */ + public static final String APPLY_FORM_ID = "apply_id"; + + /** + * maintainer in apply_form table. + */ + public static final String APPLY_FORM_MAINTAINER = "maintainer"; } diff --git a/src/main/java/com/easysoftware/common/exception/DeleteException.java b/src/main/java/com/easysoftware/common/exception/DeleteException.java new file mode 100644 index 0000000000000000000000000000000000000000..3cdc3f94be76809ff6f729fdfcfde88432a796cc --- /dev/null +++ b/src/main/java/com/easysoftware/common/exception/DeleteException.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.common.exception; + +import java.io.Serial; + +public class DeleteException extends RuntimeException { + /** + * Serial version UID for serialization. + */ + @Serial + private static final long serialVersionUID = 1L; + + /** + * Constructor for DeleteException with a message. + * + * @param message The exception message + */ + public DeleteException(final String message) { + super(message); + } + + /** + * Default constructor for DeleteException. + */ + public DeleteException() { + } + +} diff --git a/src/main/java/com/easysoftware/common/exception/InsertException.java b/src/main/java/com/easysoftware/common/exception/InsertException.java new file mode 100644 index 0000000000000000000000000000000000000000..22c5d9d1f667ff9fa3265f5849d7559159dcba87 --- /dev/null +++ b/src/main/java/com/easysoftware/common/exception/InsertException.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.common.exception; + +import java.io.Serial; + +public class InsertException extends RuntimeException { + /** + * Serial version UID for serialization. + */ + @Serial + private static final long serialVersionUID = 1L; + + /** + * Constructor for InsertException with a message. + * + * @param message The exception message + */ + public InsertException(final String message) { + super(message); + } + + /** + * Default constructor for InsertException. + */ + public InsertException() { + } + +} diff --git a/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java b/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java index 179597b0ffc90f2e09892abb434eaa8d76b51af7..078442c376015f9437a2e3a5f12662789a91ba78 100644 --- a/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java +++ b/src/main/java/com/easysoftware/domain/applyform/gateway/ApplyFormGateway.java @@ -16,6 +16,7 @@ import com.easysoftware.application.applyform.dto.ApplyFormSearchAdminCondition; import org.springframework.stereotype.Component; import com.easysoftware.application.applyform.dto.ApplyFormSearchMaintainerCondition; +import com.easysoftware.application.applyform.dto.MyApply; import com.easysoftware.application.applyform.dto.ProcessApply; @@ -53,4 +54,37 @@ public interface ApplyFormGateway { * @return A map containing relevant information */ Map queryApplyFormByCondition(ApplyFormSearchAdminCondition condition); + + /** + * MyApply apply based on the provided condition.. + * + * @param myApply The submit process result for apply. + * @return A boolean + */ + boolean submitMyApplyWithLimit(MyApply myApply); + + /** + * MyApply apply based on the provided condition. + * + * @param myApply The revoke process result for apply. + * @return A boolean + */ + boolean revokeMyApplyWithLimit(MyApply myApply); + + /** + * MyApply apply based on the provided condition. + * + * @param myApply The update process result for apply. + * @return A boolean + */ + boolean updateMyApplyWithLimit(MyApply myApply); + + /** + * MyApply apply based on the provided condition. + * + * @param applyId check the maintainer's limits of authority. + * @param maintainer check the maintainer's limits of authority. + * @return A boolean . + */ + boolean checkMaintainerLimit(Long applyId, String maintainer); } diff --git a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java index 6d8fcc41d1d6e4ece97f81c3551da24558696f0f..73c49e5cf6d8c261fbdb72b39fd1e6e3c2d2905a 100644 --- a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java +++ b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/ApplyFormGatewayImpl.java @@ -10,12 +10,16 @@ */ package com.easysoftware.infrastructure.applyform.gatewayimpl; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.easysoftware.application.applyform.dto.ApplyFormSearchAdminCondition; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -26,10 +30,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 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.dto.MyApply; import com.easysoftware.application.applyform.dto.ProcessApply; import com.easysoftware.application.applyform.vo.ApplyFormContentVO; import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; import com.easysoftware.common.constant.PackageConstant; +import com.easysoftware.common.exception.DeleteException; +import com.easysoftware.common.exception.InsertException; import com.easysoftware.common.exception.UpdateException; import com.easysoftware.common.account.UserPermission; import com.easysoftware.domain.apply.ApplyHandleRecord; @@ -46,6 +53,12 @@ import jakarta.annotation.Resource; @Component public class ApplyFormGatewayImpl implements ApplyFormGateway { + + /** + * Logger for ApplicationVersionQueryAdapter. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(ApplyFormGatewayImpl.class); + /** * Resource for interacting with package status Gateway. */ @@ -113,16 +126,17 @@ public class ApplyFormGatewayImpl implements ApplyFormGateway { */ public Map queryApplyFormByApplyId(Long applyId) { String maintainer = userPermission.getUserLogin(); + QueryWrapper queryWrapperForm = new QueryWrapper<>(); - queryWrapperForm.eq("apply_id", applyId); - queryWrapperForm.eq("maintainer", maintainer); + queryWrapperForm.eq(PackageConstant.APPLY_FORM_ID, applyId); + queryWrapperForm.eq(PackageConstant.APPLY_FORM_MAINTAINER, maintainer); List applyFormListDOs = applyFormDOMapper.selectList(queryWrapperForm); List applyFormListVOs = ApplyFormConvertor.toApplyFormVO(applyFormListDOs); QueryWrapper queryWrapperRecords = new QueryWrapper<>(); - queryWrapperRecords.eq("apply_id", applyId); - queryWrapperRecords.eq("maintainer", maintainer); + queryWrapperRecords.eq(PackageConstant.APPLY_FORM_ID, applyId); + queryWrapperRecords.eq(PackageConstant.APPLY_FORM_MAINTAINER, maintainer); List applyhandleRecordsDOs = applyHandleRecordsDOMapper.selectList(queryWrapperRecords); @@ -236,4 +250,135 @@ public class ApplyFormGatewayImpl implements ApplyFormGateway { return wrapper; } + /** + * MyApply apply based on the provided condition.. + * + * @param myApply The process result for apply. + * @return A boolean + */ + @Override + @Transactional(rollbackFor = InsertException.class) + public boolean submitMyApplyWithLimit(MyApply myApply) { + boolean result = true; + ApplyFormDO applyFormDO = ApplyFormConvertor.toApplyFormDO(myApply); + Timestamp now = new Timestamp(System.currentTimeMillis()); + applyFormDO.setCreatedAt(now); + applyFormDO.setUpdateAt(now); + + String maintainer = userPermission.getUserLogin(); + applyFormDO.setMaintainer(maintainer); + + int count = applyFormDOMapper.insert(applyFormDO); + if (count != 1) { + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Delete" + " ApplyID:" + + applyFormDO.getApplyId() + " Result: failure."); + throw new InsertException("insert failed"); + } + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Delete" + " ApplyID:" + + applyFormDO.getApplyId() + " Result: success."); + + return result; + } + + /** + * MyApply apply based on the provided condition.. + * + * @param myApply The process result for apply. + * @return A boolean + */ + @Override + @Transactional(rollbackFor = DeleteException.class) + public boolean revokeMyApplyWithLimit(MyApply myApply) { + boolean result = true; + Long id = myApply.getApplyId(); + String maintainer = userPermission.getUserLogin(); + + if (!checkMaintainerLimit(myApply.getApplyId(), maintainer)) { + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Delete" + " ApplyID:" + + id + " Result: failure."); + throw new DeleteException("permission authentication failed"); + } + + int deleteNum = applyFormDOMapper.deleteByMap(Map.of( + PackageConstant.APPLY_FORM_ID, id, + PackageConstant.APPLY_FORM_MAINTAINER, maintainer)); + if (deleteNum != 1) { + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Delete" + " ApplyID:" + + id + " Result: failure."); + throw new DeleteException("revoke failed"); + } + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Delete" + " ApplyID:" + + id + " Result: success."); + + return result; + } + + /** + * MyApply apply based on the provided condition.. + * + * @param myApply The process result for apply. + * @return A boolean + */ + @Override + @Transactional(rollbackFor = UpdateException.class) + public boolean updateMyApplyWithLimit(MyApply myApply) { + boolean result = true; + ApplyFormDO applyFormDO = ApplyFormConvertor.toApplyFormDO(myApply); + Timestamp now = new Timestamp(System.currentTimeMillis()); + applyFormDO.setUpdateAt(now); + + String maintainer = userPermission.getUserLogin(); + applyFormDO.setMaintainer(maintainer); + + if (!checkMaintainerLimit(applyFormDO.getApplyId(), maintainer)) { + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Update" + " ApplyID:" + + applyFormDO.getApplyId() + " Result: failuer."); + throw new UpdateException("permission authentication failed"); + } + + UpdateWrapper wrapper = new UpdateWrapper<>(); + wrapper.eq(PackageConstant.APPLY_FORM_ID, myApply.getApplyId()); + wrapper.eq(PackageConstant.APPLY_FORM_MAINTAINER, maintainer); + + int count = applyFormDOMapper.update(applyFormDO, wrapper); + if (count != 1) { + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Update" + " ApplyID:" + + applyFormDO.getApplyId() + " Result: failuer."); + throw new UpdateException("update failed"); + } + LOGGER.info( + "UserName:" + maintainer + " Client Ip: localhost" + " Type: Update" + " ApplyID:" + + applyFormDO.getApplyId() + " Result: success."); + + return result; + } + + /** + * MyApply apply based on the provided condition. + * + * @param applyId check the maintainer's limits of authority. + * @param maintainer check the maintainer's limits of authority. + * @return A boolean . + */ + @Override + public boolean checkMaintainerLimit(Long applyId, String maintainer) { + List list = applyFormDOMapper.selectByMap(Map.of("apply_id", applyId)); + if (list.size() == 0) { + return false; + } + for (ApplyFormDO applyFormDO : list) { + if (!applyFormDO.getMaintainer().equals(maintainer)) { + return false; + } + } + return true; + } + } 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 index 370efbe79219914470ac40be7e541e41aff8d6b0..02ad5bee76d4b077c81ab96da2d7ea83d5a31832 100644 --- a/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/converter/ApplyFormConvertor.java +++ b/src/main/java/com/easysoftware/infrastructure/applyform/gatewayimpl/converter/ApplyFormConvertor.java @@ -16,6 +16,7 @@ import java.util.List; import org.springframework.beans.BeanUtils; +import com.easysoftware.application.applyform.dto.MyApply; import com.easysoftware.application.applyform.dto.ProcessApply; import com.easysoftware.application.applyform.vo.ApplyFormSearchMaintainerVO; import com.easysoftware.domain.applyform.ApplyForm; @@ -56,6 +57,18 @@ public final class ApplyFormConvertor { return applyFormDO; } + /** + * Convert an myApply object to an ApplyFormDO entity. + * + * @param myApply The myApply object to convert + * @return An ApplyForm entity + */ + public static ApplyFormDO toApplyFormDO(final MyApply myApply) { + ApplyFormDO applyForm = new ApplyFormDO(); + BeanUtils.copyProperties(myApply, applyForm); + return applyForm; + } + /** * Convert a list of ApplicationVersionDO objects to a list of * ApplyForm entities.