From b2b82c1308fd2cf71e118ab8df8258f8160f010a Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期四, 29 八月 2024 15:52:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master-v2' into master-v2

---
 src/main/java/com/mzl/flower/service/point/PointGoodsService.java |   89 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 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..12fb25c
--- /dev/null
+++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -0,0 +1,89 @@
+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;
+    }
+
+    public void updateStatus(Long id, String status){
+        PointGoods p = pointGoodsMapper.selectById(id);
+        if(p == null){
+            throw new ValidationException("商品未找到");
+        }
+
+        p.setStatus(status);
+        p.update(SecurityUtils.getUserId());
+        pointGoodsMapper.updateById(p);
+    }
+}

--
Gitblit v1.9.3