From 823ef3d1c48f7d52316784b45a07a4f22932cd14 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 20 Mar 2024 21:43:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:art:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=BB=B4=E6=8A=A4=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/service/impl/ProductServiceImpl.java | 3 +++ src/main/java/mapper/ProductMapper.xml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java index 8c7152e..3b5f277 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ProductServiceImpl.java @@ -53,6 +53,7 @@ public class ProductServiceImpl extends AbstractService implements Prod if (FileDataType.BASE64.equals(product.getProductImgType())) { String headImgUrl = UploadController.uploadBase64File(product.getProductImgUrl(), FilePath.PRODUCT); product.setProductImgUrl(headImgUrl); + product.setProductImgType(FileDataType.URL); } Product newProduct; if (isUpdate) { @@ -60,7 +61,9 @@ public class ProductServiceImpl extends AbstractService implements Prod newProduct.setProductImgUrl(product.getProductImgUrl()); newProduct.setProductTitle(product.getProductTitle()); newProduct.setProductPrice(product.getProductPrice()); + newProduct.setTags(product.getTags()); newProduct.setProductDescription(product.getProductDescription()); + newProduct.setUpdatedTime(new Date()); productMapper.updateByPrimaryKeySelective(newProduct); // 更新产品详情 productMapper.updateProductContent(newProduct.getIdProduct(), product.getProductContent(), product.getProductContentHtml()); diff --git a/src/main/java/mapper/ProductMapper.xml b/src/main/java/mapper/ProductMapper.xml index ddf51f6..ca94d19 100644 --- a/src/main/java/mapper/ProductMapper.xml +++ b/src/main/java/mapper/ProductMapper.xml @@ -37,7 +37,7 @@ where id_product = #{idProduct} @@ -57,7 +57,7 @@ From 58c9a2995d3608b171e43d2e6ba937f58e8484d4 Mon Sep 17 00:00:00 2001 From: ronger Date: Thu, 21 Mar 2024 09:28:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:art:=20=E5=AE=8C=E5=96=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/web/api/product/ProductController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/rymcu/forest/web/api/product/ProductController.java b/src/main/java/com/rymcu/forest/web/api/product/ProductController.java index f54dfa0..9e84980 100644 --- a/src/main/java/com/rymcu/forest/web/api/product/ProductController.java +++ b/src/main/java/com/rymcu/forest/web/api/product/ProductController.java @@ -26,6 +26,7 @@ import javax.annotation.Resource; */ @RestController @RequestMapping("/api/v1/product") +@RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR) public class ProductController { @Resource @@ -38,14 +39,12 @@ public class ProductController { } @PostMapping("/post") - @RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR) public GlobalResult add(@RequestBody ProductDTO product) { Product newProduct = productService.postProduct(product); return GlobalResultGenerator.genSuccessResult(newProduct); } @PutMapping("/post") - @RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR) public GlobalResult update(@RequestBody ProductDTO product) { if (product.getIdProduct() == null || product.getIdProduct() == 0) { throw new IllegalArgumentException("产品主键参数异常!"); From 29894ce63137d3cd92a72ba30210609ae89d7b0e Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 22 Mar 2024 22:45:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:art:=20=E6=A0=87=E7=AD=BE/=E4=B8=93?= =?UTF-8?q?=E9=A2=98=E7=AE=A1=E7=90=86=E7=BB=B4=E6=8A=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/entity/Tag.java | 10 ++++++---- src/main/java/com/rymcu/forest/entity/Topic.java | 10 ++++++---- .../com/rymcu/forest/service/impl/TagServiceImpl.java | 5 +++-- .../rymcu/forest/service/impl/TopicServiceImpl.java | 5 +++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/rymcu/forest/entity/Tag.java b/src/main/java/com/rymcu/forest/entity/Tag.java index a5c8b2d..074ae54 100644 --- a/src/main/java/com/rymcu/forest/entity/Tag.java +++ b/src/main/java/com/rymcu/forest/entity/Tag.java @@ -3,10 +3,7 @@ package com.rymcu.forest.entity; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.io.Serializable; import java.util.Date; @@ -75,4 +72,9 @@ public class Tag implements Serializable, Cloneable { * 描述 */ private String tagDescriptionHtml; + /** + * 图标类型 + */ + @Transient + private transient String tagImageType; } diff --git a/src/main/java/com/rymcu/forest/entity/Topic.java b/src/main/java/com/rymcu/forest/entity/Topic.java index ed8168d..83c10cc 100644 --- a/src/main/java/com/rymcu/forest/entity/Topic.java +++ b/src/main/java/com/rymcu/forest/entity/Topic.java @@ -3,10 +3,7 @@ package com.rymcu.forest.entity; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.util.Date; /** @@ -71,5 +68,10 @@ public class Topic { * 专题描述 Html */ private String topicDescriptionHtml; + /** + * 专题图片类型 + */ + @Transient + private transient String topicImageType; } diff --git a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java index d060687..ae872b2 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java @@ -10,6 +10,7 @@ import com.rymcu.forest.dto.ArticleTagDTO; import com.rymcu.forest.dto.LabelModel; import com.rymcu.forest.entity.Article; import com.rymcu.forest.entity.Tag; +import com.rymcu.forest.enumerate.FileDataType; import com.rymcu.forest.enumerate.FilePath; import com.rymcu.forest.mapper.ArticleMapper; import com.rymcu.forest.mapper.TagMapper; @@ -126,7 +127,7 @@ public class TagServiceImpl extends AbstractService implements TagService { throw new BusinessException("标签 '" + tag.getTagTitle() + "' 已存在!"); } } - if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(tag.getTagImageType())) { String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG); tag.setTagIconPath(tagIconPath); } else { @@ -137,7 +138,7 @@ public class TagServiceImpl extends AbstractService implements TagService { result = tagMapper.insertSelective(tag); } else { tag.setUpdatedTime(new Date()); - if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(tag.getTagImageType())) { String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG); tag.setTagIconPath(tagIconPath); } diff --git a/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java index 787d9df..f92dcf0 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TopicServiceImpl.java @@ -8,6 +8,7 @@ import com.rymcu.forest.dto.admin.TopicDTO; import com.rymcu.forest.dto.admin.TopicTagDTO; import com.rymcu.forest.entity.Tag; import com.rymcu.forest.entity.Topic; +import com.rymcu.forest.enumerate.FileDataType; import com.rymcu.forest.enumerate.FilePath; import com.rymcu.forest.mapper.TopicMapper; import com.rymcu.forest.service.TopicService; @@ -59,7 +60,7 @@ public class TopicServiceImpl extends AbstractService implements TopicSer throw new BusinessException("专题 '" + topic.getTopicTitle() + "' 已存在!"); } } - if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(topic.getTopicImageType())) { String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC); topic.setTopicIconPath(topicIconPath); } else { @@ -74,7 +75,7 @@ public class TopicServiceImpl extends AbstractService implements TopicSer topic.setUpdatedTime(topic.getCreatedTime()); result = topicMapper.insertSelective(topic); } else { - if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) { + if (FileDataType.BASE64.equals(topic.getTopicImageType())) { String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC); topic.setTopicIconPath(topicIconPath); }