From 4efd37516a0723c67a2644ab0ddcf86013af6a4b Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 28 十月 2026 17:57:57 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
basic-server/src/main/java/com/ruoyi/basic/service/impl/CertificationServiceImpl.java | 88 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 2 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 43eb9d2..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,13 +1,16 @@
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;
@@ -31,10 +34,71 @@
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;
}
//鍒犻櫎璧勮川鏄庣粏鍒楄〃
@@ -44,4 +108,24 @@
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