🎨 标签/专题管理维护功能完善
🎨 标签/专题管理维护功能完善
This commit is contained in:
commit
0a0e794c18
@ -3,10 +3,7 @@ package com.rymcu.forest.entity;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -75,4 +72,9 @@ public class Tag implements Serializable, Cloneable {
|
|||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
private String tagDescriptionHtml;
|
private String tagDescriptionHtml;
|
||||||
|
/**
|
||||||
|
* 图标类型
|
||||||
|
*/
|
||||||
|
@Transient
|
||||||
|
private transient String tagImageType;
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@ package com.rymcu.forest.entity;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,5 +68,10 @@ public class Topic {
|
|||||||
* 专题描述 Html
|
* 专题描述 Html
|
||||||
*/
|
*/
|
||||||
private String topicDescriptionHtml;
|
private String topicDescriptionHtml;
|
||||||
|
/**
|
||||||
|
* 专题图片类型
|
||||||
|
*/
|
||||||
|
@Transient
|
||||||
|
private transient String topicImageType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ public class ProductServiceImpl extends AbstractService<Product> implements Prod
|
|||||||
if (FileDataType.BASE64.equals(product.getProductImgType())) {
|
if (FileDataType.BASE64.equals(product.getProductImgType())) {
|
||||||
String headImgUrl = UploadController.uploadBase64File(product.getProductImgUrl(), FilePath.PRODUCT);
|
String headImgUrl = UploadController.uploadBase64File(product.getProductImgUrl(), FilePath.PRODUCT);
|
||||||
product.setProductImgUrl(headImgUrl);
|
product.setProductImgUrl(headImgUrl);
|
||||||
|
product.setProductImgType(FileDataType.URL);
|
||||||
}
|
}
|
||||||
Product newProduct;
|
Product newProduct;
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
@ -60,7 +61,9 @@ public class ProductServiceImpl extends AbstractService<Product> implements Prod
|
|||||||
newProduct.setProductImgUrl(product.getProductImgUrl());
|
newProduct.setProductImgUrl(product.getProductImgUrl());
|
||||||
newProduct.setProductTitle(product.getProductTitle());
|
newProduct.setProductTitle(product.getProductTitle());
|
||||||
newProduct.setProductPrice(product.getProductPrice());
|
newProduct.setProductPrice(product.getProductPrice());
|
||||||
|
newProduct.setTags(product.getTags());
|
||||||
newProduct.setProductDescription(product.getProductDescription());
|
newProduct.setProductDescription(product.getProductDescription());
|
||||||
|
newProduct.setUpdatedTime(new Date());
|
||||||
productMapper.updateByPrimaryKeySelective(newProduct);
|
productMapper.updateByPrimaryKeySelective(newProduct);
|
||||||
// 更新产品详情
|
// 更新产品详情
|
||||||
productMapper.updateProductContent(newProduct.getIdProduct(), product.getProductContent(), product.getProductContentHtml());
|
productMapper.updateProductContent(newProduct.getIdProduct(), product.getProductContent(), product.getProductContentHtml());
|
||||||
|
@ -10,6 +10,7 @@ import com.rymcu.forest.dto.ArticleTagDTO;
|
|||||||
import com.rymcu.forest.dto.LabelModel;
|
import com.rymcu.forest.dto.LabelModel;
|
||||||
import com.rymcu.forest.entity.Article;
|
import com.rymcu.forest.entity.Article;
|
||||||
import com.rymcu.forest.entity.Tag;
|
import com.rymcu.forest.entity.Tag;
|
||||||
|
import com.rymcu.forest.enumerate.FileDataType;
|
||||||
import com.rymcu.forest.enumerate.FilePath;
|
import com.rymcu.forest.enumerate.FilePath;
|
||||||
import com.rymcu.forest.mapper.ArticleMapper;
|
import com.rymcu.forest.mapper.ArticleMapper;
|
||||||
import com.rymcu.forest.mapper.TagMapper;
|
import com.rymcu.forest.mapper.TagMapper;
|
||||||
@ -126,7 +127,7 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
throw new BusinessException("标签 '" + tag.getTagTitle() + "' 已存在!");
|
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);
|
String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG);
|
||||||
tag.setTagIconPath(tagIconPath);
|
tag.setTagIconPath(tagIconPath);
|
||||||
} else {
|
} else {
|
||||||
@ -137,7 +138,7 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
result = tagMapper.insertSelective(tag);
|
result = tagMapper.insertSelective(tag);
|
||||||
} else {
|
} else {
|
||||||
tag.setUpdatedTime(new Date());
|
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);
|
String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), FilePath.TAG);
|
||||||
tag.setTagIconPath(tagIconPath);
|
tag.setTagIconPath(tagIconPath);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.rymcu.forest.dto.admin.TopicDTO;
|
|||||||
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
||||||
import com.rymcu.forest.entity.Tag;
|
import com.rymcu.forest.entity.Tag;
|
||||||
import com.rymcu.forest.entity.Topic;
|
import com.rymcu.forest.entity.Topic;
|
||||||
|
import com.rymcu.forest.enumerate.FileDataType;
|
||||||
import com.rymcu.forest.enumerate.FilePath;
|
import com.rymcu.forest.enumerate.FilePath;
|
||||||
import com.rymcu.forest.mapper.TopicMapper;
|
import com.rymcu.forest.mapper.TopicMapper;
|
||||||
import com.rymcu.forest.service.TopicService;
|
import com.rymcu.forest.service.TopicService;
|
||||||
@ -59,7 +60,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
throw new BusinessException("专题 '" + topic.getTopicTitle() + "' 已存在!");
|
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);
|
String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC);
|
||||||
topic.setTopicIconPath(topicIconPath);
|
topic.setTopicIconPath(topicIconPath);
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +75,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
topic.setUpdatedTime(topic.getCreatedTime());
|
topic.setUpdatedTime(topic.getCreatedTime());
|
||||||
result = topicMapper.insertSelective(topic);
|
result = topicMapper.insertSelective(topic);
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) {
|
if (FileDataType.BASE64.equals(topic.getTopicImageType())) {
|
||||||
String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC);
|
String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), FilePath.TOPIC);
|
||||||
topic.setTopicIconPath(topicIconPath);
|
topic.setTopicIconPath(topicIconPath);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import javax.annotation.Resource;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/product")
|
@RequestMapping("/api/v1/product")
|
||||||
|
@RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR)
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -38,14 +39,12 @@ public class ProductController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/post")
|
@PostMapping("/post")
|
||||||
@RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR)
|
|
||||||
public GlobalResult<Product> add(@RequestBody ProductDTO product) {
|
public GlobalResult<Product> add(@RequestBody ProductDTO product) {
|
||||||
Product newProduct = productService.postProduct(product);
|
Product newProduct = productService.postProduct(product);
|
||||||
return GlobalResultGenerator.genSuccessResult(newProduct);
|
return GlobalResultGenerator.genSuccessResult(newProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/post")
|
@PutMapping("/post")
|
||||||
@RequiresRoles(value = {"blog_admin", "admin"}, logical = Logical.OR)
|
|
||||||
public GlobalResult<Product> update(@RequestBody ProductDTO product) {
|
public GlobalResult<Product> update(@RequestBody ProductDTO product) {
|
||||||
if (product.getIdProduct() == null || product.getIdProduct() == 0) {
|
if (product.getIdProduct() == null || product.getIdProduct() == 0) {
|
||||||
throw new IllegalArgumentException("产品主键参数异常!");
|
throw new IllegalArgumentException("产品主键参数异常!");
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
where id_product = #{idProduct}
|
where id_product = #{idProduct}
|
||||||
</update>
|
</update>
|
||||||
<select id="selectProducts" resultMap="DTOResultMap">
|
<select id="selectProducts" resultMap="DTOResultMap">
|
||||||
select id, product_title, product_img_url, tags, product_description, product_price, weights, status
|
select id, product_title, product_img_url, tags, product_description, product_price, weights, status, created_time
|
||||||
from forest_product
|
from forest_product
|
||||||
order by weights
|
order by weights
|
||||||
</select>
|
</select>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<select id="selectOnlineProducts" resultMap="DTOResultMap">
|
<select id="selectOnlineProducts" resultMap="DTOResultMap">
|
||||||
select id, product_title, product_img_url, product_description, product_price
|
select id, product_title, product_img_url, product_description, product_price
|
||||||
from forest_product
|
from forest_product
|
||||||
where status = 1
|
where status = 0
|
||||||
order by weights
|
order by weights
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user