From 91506c1fa8d9000db9581951253967cefbd4d3da Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 22 Jun 2021 17:04:29 +0800
Subject: [PATCH] 20210622 商品分类
---
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java | 92 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
new file mode 100644
index 0000000..59030c1
--- /dev/null
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -0,0 +1,92 @@
+package com.xzx.gc.shop.service;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.StrUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.xzx.gc.common.constant.CommonEnum;
+import com.xzx.gc.common.constant.Constants;
+import com.xzx.gc.common.dto.log.OperationAppLog;
+import com.xzx.gc.common.utils.MqUtil;
+import com.xzx.gc.entity.CoreUser;
+import com.xzx.gc.entity.ScoreGoodsCategory;
+import com.xzx.gc.model.JsonResult;
+import com.xzx.gc.model.admin.GoodsCategoryModel;
+import com.xzx.gc.shop.dto.QueryGoodsCategoryListDto;
+import com.xzx.gc.shop.mapper.ScoreGoodsCategoryMapper;
+import com.xzx.gc.shop.vo.QueryGoodsCategoryListVo;
+import com.xzx.gc.shop.vo.ViewGoodsCategoryVo;
+import com.xzx.gc.util.SessionUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Transactional
+@Slf4j
+public class GoodsService {
+
+ @Resource
+ ScoreGoodsCategoryMapper scoreGoodsCategoryMapper;
+
+ @Autowired
+ private MqUtil mqUtil;
+
+ public Map<String, Object> queryGoodsCategoryList(QueryGoodsCategoryListDto model) {
+ String name = model.getName();
+ GoodsCategoryModel goodsCategoryModel = new GoodsCategoryModel();
+ goodsCategoryModel.setName(name);
+ PageHelper.startPage(model.getPage(), model.getLimit());
+
+ List<QueryGoodsCategoryListVo> maps = scoreGoodsCategoryMapper.queryGoodsCategoryList(goodsCategoryModel);
+ PageInfo pageInfo = new PageInfo(maps);
+ int count = Convert.toInt(pageInfo.getTotal());
+ Map<String, Object> map = new HashMap<>();
+ map.put("data", maps);
+ map.put("count", count);
+ map.put("code", 0);
+ return map;
+ }
+
+ public Long addGoodsCategory(GoodsCategoryModel model) {
+ ScoreGoodsCategory scoreGoodsCategory = new ScoreGoodsCategory();
+ scoreGoodsCategory.setName(model.getName());
+ scoreGoodsCategory.setCategoryIden(model.getCategoryIden());
+ scoreGoodsCategory.setParentId(model.getParentId());
+ scoreGoodsCategory.setCreatedBy(model.getCreatedBy());
+ scoreGoodsCategory.setCreatedTime(model.getCreatedTime());
+ scoreGoodsCategoryMapper.insert(scoreGoodsCategory);
+ return scoreGoodsCategory.getId();
+ }
+
+ public void deleteGoodsCategory(long id) {
+ scoreGoodsCategoryMapper.deleteByPrimaryKey(id);
+ }
+
+ public ViewGoodsCategoryVo viewGoodsCategoryById(long id) {
+ ScoreGoodsCategory scoreGoodsCategory = scoreGoodsCategoryMapper.selectByPrimaryKey(id);
+ ViewGoodsCategoryVo viewGoodsCategoryVo = new ViewGoodsCategoryVo();
+ viewGoodsCategoryVo.setId(scoreGoodsCategory.getId());
+ viewGoodsCategoryVo.setName(scoreGoodsCategory.getName());
+ viewGoodsCategoryVo.setCategoryIden(scoreGoodsCategory.getCategoryIden());
+ viewGoodsCategoryVo.setParentId(scoreGoodsCategory.getParentId());
+ return viewGoodsCategoryVo;
+ }
+
+ public void updateGoodsCategory(GoodsCategoryModel model) {
+ long id = model.getId();
+ ScoreGoodsCategory scoreGoodsCategory = scoreGoodsCategoryMapper.selectByPrimaryKey(id);
+ scoreGoodsCategory.setName(model.getName());
+ scoreGoodsCategory.setCategoryIden(model.getCategoryIden());
+ scoreGoodsCategory.setParentId(model.getParentId());
+ scoreGoodsCategoryMapper.updateByPrimaryKey(scoreGoodsCategory);
+ }
+}
--
Gitblit v1.9.1