From a3d54f0b768aca492e9a9f4689b3a4ec8234381e Mon Sep 17 00:00:00 2001
From: Cui Zhi Feng <7426394+wuxixiaocui@user.noreply.gitee.com>
Date: 星期四, 29 八月 2024 14:30:58 +0800
Subject: [PATCH] Merge branch 'master-v2' of http://47.96.225.205:8888/r/flowerbackend-v2 into master-v2
---
src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 78 +++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
new file mode 100644
index 0000000..0b25f44
--- /dev/null
+++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -0,0 +1,78 @@
+package com.mzl.flower.service.point;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.config.exception.ValidationException;
+import com.mzl.flower.config.security.SecurityUtils;
+import com.mzl.flower.constant.Constants;
+import com.mzl.flower.dto.request.point.PointGoodsCreateDTO;
+import com.mzl.flower.dto.request.point.PointGoodsQueryDTO;
+import com.mzl.flower.dto.request.point.PointGoodsUpdateDTO;
+import com.mzl.flower.dto.response.point.PointGoodsDTO;
+import com.mzl.flower.dto.response.point.PointGoodsListDTO;
+import com.mzl.flower.entity.point.PointGoods;
+import com.mzl.flower.mapper.point.PointGoodsMapper;
+import com.mzl.flower.service.BaseService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Service
+@Transactional
+public class PointGoodsService extends BaseService {
+
+ @Autowired
+ private PointGoodsMapper pointGoodsMapper;
+
+ public Long addPointGoods(PointGoodsCreateDTO dto){
+ PointGoods p = new PointGoods();
+ BeanUtils.copyProperties(dto, p);
+ p.setPictures(toJSONString(dto.getPictureList()));
+ p.setStatus(Constants.POINT_GOODS_STATUS.I.name());
+
+ p.create(SecurityUtils.getUserId());
+ pointGoodsMapper.insert(p);
+
+ return p.getId();
+ }
+
+ public Long updatePointGoods(PointGoodsUpdateDTO dto){
+ PointGoods p = pointGoodsMapper.selectById(dto.getId());
+ if(p == null){
+ throw new ValidationException("商品未找到");
+ }
+
+ BeanUtils.copyProperties(dto, p);
+ p.setPictures(toJSONString(dto.getPictureList()));
+
+ p.update(SecurityUtils.getUserId());
+ pointGoodsMapper.updateById(p);
+
+ return p.getId();
+ }
+
+ public void deletePointGoods(Long id){
+ pointGoodsMapper.deleteById(id);
+ }
+
+ public Page<PointGoodsListDTO> selectGoodsList(Page page, PointGoodsQueryDTO dto){
+ List<PointGoodsListDTO> ls = pointGoodsMapper.selectGoodsList(page, dto);
+
+ page.setRecords(ls);
+ return page;
+ }
+
+ public PointGoodsDTO getGoodsInfo(Long id){
+ PointGoods p = pointGoodsMapper.selectById(id);
+ if(p == null){
+ throw new ValidationException("商品未找到");
+ }
+ PointGoodsDTO dto = new PointGoodsDTO();
+ BeanUtils.copyProperties(p, dto);
+ dto.setPictureList(parseArray(p.getPictures(), String.class));
+
+ return dto;
+ }
+}
--
Gitblit v1.9.3