From bcb97cb584eebc27705898a9c06c28bf3051c22d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 28 十月 2026 16:50:01 +0800
Subject: [PATCH] feat(certification): 添加资质编辑和概览图片上传功能 - 标准方法页面移除"是否产品标准"字段
---
basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java | 94 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java
index 11a6e61..b02de81 100644
--- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java
+++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java
@@ -1,18 +1,23 @@
package com.ruoyi.basic.service.impl;
-import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.common.utils.QueryWrappers;
+import com.ruoyi.basic.dto.CertificationImageUpdateDto;
+import com.ruoyi.basic.dto.CertificationUpdateDto;
import com.ruoyi.basic.mapper.CertificationMapper;
import com.ruoyi.basic.pojo.Certification;
import com.ruoyi.basic.service.CertificationService;
+import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
@Service
@AllArgsConstructor
@@ -26,20 +31,101 @@
//鏌ヨ璧勮川鏄庣粏鍒楄〃
@Override
public IPage<Certification> getCertificationDetail(Page page, Certification certification) {
- return certificationMapper.getCertificationDetail(page, QueryWrappers.queryWrappers(certification));
+ return certificationMapper.getCertificationDetail(page, certification);
+ }
+
+ @Override
+ public Certification getCertificationById(Integer id) {
+ if (id == null) {
+ throw new BaseException("璧勮川ID涓嶈兘涓虹┖");
+ }
+ Certification certification = certificationMapper.selectById(id);
+ if (certification == null) {
+ throw new BaseException("璧勮川璁板綍涓嶅瓨鍦�");
+ }
+ return certification;
}
//娣诲姞璧勮川鏄庣粏鍒楄〃
@Override
public int addCertificationDetail(Certification certification) {
+ validateRequiredFields(certification.getName(), certification.getCode(), certification.getOrganization(),
+ certification.getDateOfIssuance(), certification.getExpireTime());
return certificationMapper.insert(certification);
+ }
+
+ @Override
+ public int updateCertificationDetail(CertificationUpdateDto certification) {
+ if (certification == null || certification.getId() == null) {
+ throw new BaseException("璧勮川ID涓嶈兘涓虹┖");
+ }
+ Certification existing = getCertificationById(certification.getId());
+ validateRequiredFields(certification.getName(), certification.getCode(), certification.getOrganization(),
+ certification.getDateOfIssuance(), certification.getExpireTime());
+
+ String imageUrl = StringUtils.isNotBlank(certification.getImageUrl())
+ ? certification.getImageUrl() : existing.getImageUrl();
+ String fileUrl = StringUtils.isNotBlank(certification.getFileUrl())
+ ? certification.getFileUrl() : existing.getFileUrl();
+ int updated = certificationMapper.update(new Certification(), Wrappers.<Certification>lambdaUpdate()
+ .eq(Certification::getId, certification.getId())
+ .set(Certification::getName, certification.getName())
+ .set(Certification::getCode, certification.getCode())
+ .set(Certification::getOrganization, certification.getOrganization())
+ .set(Certification::getExplanation, certification.getExplanation())
+ .set(Certification::getDateOfIssuance, certification.getDateOfIssuance())
+ .set(Certification::getExpireTime, certification.getExpireTime())
+ .set(Certification::getImageUrl, imageUrl)
+ .set(Certification::getFileUrl, fileUrl));
+ if (updated < 1) {
+ throw new BaseException("璧勮川鏇存柊澶辫触");
+ }
+ return updated;
+ }
+
+ @Override
+ public int updateCertificationImage(CertificationImageUpdateDto certification) {
+ if (certification == null || certification.getId() == null) {
+ throw new BaseException("璧勮川ID涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isBlank(certification.getImageUrl())) {
+ throw new BaseException("璧勮川鍥剧墖涓嶈兘涓虹┖");
+ }
+ getCertificationById(certification.getId());
+ int updated = certificationMapper.update(new Certification(), Wrappers.<Certification>lambdaUpdate()
+ .eq(Certification::getId, certification.getId())
+ .set(Certification::getImageUrl, certification.getImageUrl()));
+ if (updated < 1) {
+ throw new BaseException("璧勮川鍥剧墖鏇存柊澶辫触");
+ }
+ return updated;
}
//鍒犻櫎璧勮川鏄庣粏鍒楄〃
@Override
public int delCertificationDetail(String ids) {
- List<Integer> list = JSON.parseArray(ids,Integer.class);
+ List<Integer> list = Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList());
return certificationMapper.deleteBatchIds(list);
}
+ private void validateRequiredFields(String name, String code, String organization,
+ java.time.LocalDateTime dateOfIssuance,
+ java.time.LocalDateTime expireTime) {
+ if (StringUtils.isBlank(name)) {
+ throw new BaseException("璧勮川鍚嶇О涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isBlank(code)) {
+ throw new BaseException("璧勮川缂栫爜涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isBlank(organization)) {
+ throw new BaseException("棰佸彂鏈烘瀯涓嶈兘涓虹┖");
+ }
+ if (dateOfIssuance == null) {
+ throw new BaseException("棰佸彂鏃堕棿涓嶈兘涓虹┖");
+ }
+ if (expireTime == null) {
+ throw new BaseException("鍒版湡鏃堕棿涓嶈兘涓虹┖");
+ }
+ }
+
}
--
Gitblit v1.9.3