From 54e6398cabe1b32b1dbc9857c6a99d8f15b549f7 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 06 十一月 2019 15:31:44 +0800 Subject: [PATCH] 红包信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsClassServiceImpl.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsClassServiceImpl.java index d81a65d..6247484 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsClassServiceImpl.java @@ -1,12 +1,18 @@ package com.yeshi.fanli.service.impl.shop; +import java.util.Date; +import java.util.List; + import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.yeshi.utils.tencentcloud.COSManager; import com.yeshi.fanli.dao.mybatis.shop.BanLiShopGoodsClassMapper; import com.yeshi.fanli.entity.shop.BanLiShopGoodsClass; +import com.yeshi.fanli.exception.shop.BanLiShopGoodsClassException; import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService; +import com.yeshi.fanli.util.StringUtil; @Service public class BanLiShopGoodsClassServiceImpl implements BanLiShopGoodsClassService { @@ -19,4 +25,54 @@ return banLiShopGoodsClassMapper.selectByPrimaryKey(id); } + + @Override + public List<BanLiShopGoodsClass> listAllGoodsClass() { + return banLiShopGoodsClassMapper.listAllGoodsClass(); + } + + @Override + public List<BanLiShopGoodsClass> listGoodsClass(int page, int pageSize, String key) { + return banLiShopGoodsClassMapper.listGoodsClass((page - 1) * pageSize, pageSize, key); + } + + @Override + public long countGoodsClass(String key) { + return banLiShopGoodsClassMapper.countGoodsClass(key); + } + + + @Override + public void save( BanLiShopGoodsClass record) throws BanLiShopGoodsClassException { + String name = record.getName(); + if (StringUtil.isNullOrEmpty(name)) + throw new BanLiShopGoodsClassException(1, "鍚嶇О涓嶈兘涓虹┖"); + + record.setUpdateTime(new Date()); + if (record.getId() == null) { + record.setCreateTime(new Date()); + banLiShopGoodsClassMapper.insert(record); + } else { + BanLiShopGoodsClass resultObj = banLiShopGoodsClassMapper.selectByPrimaryKey(record.getId()); + if (resultObj == null) + throw new BanLiShopGoodsClassException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); + + if (StringUtil.isNullOrEmpty(record.getPicture())) { + record.setPicture(resultObj.getPicture()); + } else if (!StringUtil.isNullOrEmpty(resultObj.getPicture())) { + COSManager.getInstance().deleteFile(resultObj.getPicture()); + } + record.setCreateTime(resultObj.getCreateTime()); + banLiShopGoodsClassMapper.updateByPrimaryKey(record); + } + } + + + @Override + public void delete(List<Long> idsList) { + if (idsList != null) + for (Long id : idsList) + banLiShopGoodsClassMapper.deleteByPrimaryKey(id); + + } } -- Gitblit v1.8.0