From 8a3a1c0b838d3b532750dc7c69362c2f5b0e7132 Mon Sep 17 00:00:00 2001 From: heheng <475597332@qq.com> Date: 星期一, 18 八月 2025 10:35:59 +0800 Subject: [PATCH] 部分新功能 --- multi-system/src/main/java/com/gkhy/exam/system/service/impl/PurchaseApplyServiceImpl.java | 79 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-) diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/PurchaseApplyServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/PurchaseApplyServiceImpl.java new file mode 100644 index 0000000..0c83d1d --- /dev/null +++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/PurchaseApplyServiceImpl.java @@ -0,0 +1,79 @@ +package com.gkhy.exam.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gkhy.exam.common.api.CommonPage; +import com.gkhy.exam.common.api.CommonResult; +import com.gkhy.exam.common.exception.ApiException; +import com.gkhy.exam.common.utils.PageUtils; +import com.gkhy.exam.common.utils.SecurityUtils; +import com.gkhy.exam.system.domain.PurchaseApply; +import com.gkhy.exam.system.domain.PurchaseApplyPlan; +import com.gkhy.exam.system.mapper.PurchaseApplyMapper; +import com.gkhy.exam.system.mapper.PurchaseApplyPlanMapper; +import com.gkhy.exam.system.service.PurchaseApplyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; + +@Service +public class PurchaseApplyServiceImpl extends ServiceImpl<PurchaseApplyMapper, PurchaseApply> implements PurchaseApplyService { + + @Autowired + private PurchaseApplyMapper applyMapper; + + @Autowired + private PurchaseApplyPlanMapper applyPlanMapper; + + @Override + public CommonPage selectApplyList(PurchaseApply purchaseApply) { + if (!SecurityUtils.adminUser()){ + if (purchaseApply.getCompanyId()==null){ + throw new ApiException("非管理员操作,企业id不可为空"); + } + } + PageUtils.startPage(); + List<PurchaseApply> purchaseApplies = applyMapper.selectApplyList(purchaseApply); + for (PurchaseApply apply : purchaseApplies) { + List<PurchaseApplyPlan> purchaseApplyPlans = applyPlanMapper.selectByApplyId(apply.getId()); + apply.setPurchaseApplyPlans(purchaseApplyPlans); + } + return CommonPage.restPage(purchaseApplies); + } + + @Override + public CommonResult insertApply(PurchaseApply purchaseApply) { + purchaseApply.setCreateTime(LocalDateTime.now()); + purchaseApply.setCreateBy(SecurityUtils.getUsername()); + applyMapper.insert(purchaseApply); + List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); + for (PurchaseApplyPlan purchaseApplyPlan : purchaseApplyPlans) { + purchaseApplyPlan.setApplyId(purchaseApply.getId()); + } + applyPlanMapper.insertPlans(purchaseApplyPlans); + return CommonResult.success(); + } + + @Override + public CommonResult updateApply(PurchaseApply purchaseApply) { + purchaseApply.setUpdateTime(LocalDateTime.now()); + purchaseApply.setUpdateBy(SecurityUtils.getUsername()); + applyMapper.updateById(purchaseApply); + List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); + applyPlanMapper.deletedByIds(purchaseApply.getId()); + applyPlanMapper.insertPlans(purchaseApplyPlans); + return CommonResult.success(); + } + + @Override + public CommonResult deletedApply(Integer applyId) { + PurchaseApply purchaseApply = new PurchaseApply(); + purchaseApply.setId(applyId); + purchaseApply.setUpdateBy(SecurityUtils.getUsername()); + purchaseApply.setUpdateTime(LocalDateTime.now()); + purchaseApply.setDelFlag(2); + applyMapper.updateById(purchaseApply); + return CommonResult.success(); + } +} -- Gitblit v1.9.2