商品模块代码提交

This commit is contained in:
Tankaikai
2025-02-20 16:03:54 +08:00
parent 00a92905b9
commit 758be911b7
18 changed files with 618 additions and 166 deletions

View File

@@ -0,0 +1,16 @@
package com.czg.service.product.mapper;
import com.czg.product.entity.ConsInfo;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 耗材信息
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-20
*/
@Mapper
public interface ConsInfoMapper extends BaseMapper<ConsInfo> {
}

View File

@@ -6,12 +6,15 @@ import cn.hutool.core.util.StrUtil;
import com.czg.enums.StatusEnum;
import com.czg.exception.CzgException;
import com.czg.product.dto.ConsGroupDTO;
import com.czg.product.dto.ConsInfoDTO;
import com.czg.product.entity.ConsGroup;
import com.czg.product.entity.ConsGroupRelation;
import com.czg.product.entity.ConsInfo;
import com.czg.product.service.ConsGroupService;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.ConsGroupMapper;
import com.czg.service.product.mapper.ConsGroupRelationMapper;
import com.czg.service.product.mapper.ConsInfoMapper;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@@ -34,13 +37,14 @@ import java.util.List;
public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup> implements ConsGroupService {
private final ConsGroupRelationMapper consGroupRelationMapper;
private final ConsInfoMapper consInfoMapper;
private QueryWrapper buildQueryWrapper(ConsGroupDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ConsGroup::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ConsGroup::getShopId, shopId);
queryWrapper.orderBy(ConsGroup::getId, false);
return queryWrapper;
@@ -61,17 +65,19 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
@Override
public ConsGroupDTO getConsGroupById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
ConsGroupDTO dto = super.getOneAs(query().eq(ConsGroup::getId, id).eq(ConsGroup::getShopId, shopId), ConsGroupDTO.class);
List<Long> consIds = consGroupRelationMapper.selectListByQueryAs(query().select(ConsGroupRelation::getConsId).eq(ConsGroupRelation::getGroupId, dto.getId()), Long.class);
dto.setConsIds(consIds);
List<ConsInfoDTO> consInfoList = consInfoMapper.selectListByQueryAs(query().eq(ConsInfo::getConsGroupId, dto.getId()), ConsInfoDTO.class);
dto.setConsInfoList(consInfoList);
return dto;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addConsGroup(ConsGroupDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ConsGroup::getName, dto.getName()).eq(ConsGroup::getShopId, shopId));
if (exists) {
throw new CzgException("耗材分组已存在");
@@ -84,13 +90,11 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
if (CollUtil.isEmpty(consIds)) {
return true;
}
int index = 0;
for (Long consId : consIds) {
index++;
ConsGroupRelation relation = new ConsGroupRelation();
relation.setConsId(consId);
relation.setGroupId(entity.getId());
relation.setSort(index);
relation.setSort(consId.intValue());
consGroupRelationMapper.insert(relation);
}
return true;
@@ -98,7 +102,7 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
@Override
public boolean updateConsGroup(ConsGroupDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ConsGroup::getName, dto.getName()).eq(ConsGroup::getShopId, shopId).ne(ConsGroup::getId, dto.getId()));
if (exists) {
@@ -111,13 +115,11 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
return true;
}
consGroupRelationMapper.deleteByQuery(query().eq(ConsGroupRelation::getGroupId, entity.getId()));
int index = 0;
for (Long consId : consIds) {
index++;
ConsGroupRelation relation = new ConsGroupRelation();
relation.setConsId(consId);
relation.setGroupId(entity.getId());
relation.setSort(index);
relation.setSort(consId.intValue());
consGroupRelationMapper.insert(relation);
}
return true;
@@ -125,13 +127,13 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
@Override
public boolean deleteConsGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.remove(query().eq(ConsGroup::getId, id).eq(ConsGroup::getShopId, shopId));
}
@Override
public boolean disableConsGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ConsGroup.class)
.set(ConsGroup::getStatus, StatusEnum.DISABLE.value())
.eq(ConsGroup::getId, id)
@@ -141,7 +143,7 @@ public class ConsGroupServiceImpl extends ServiceImpl<ConsGroupMapper, ConsGroup
@Override
public boolean enableConsGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ConsGroup.class)
.set(ConsGroup::getStatus, StatusEnum.ENABLED.value())
.eq(ConsGroup::getId, id)

View File

@@ -0,0 +1,156 @@
package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.enums.StatusEnum;
import com.czg.enums.YesNoEnum;
import com.czg.exception.CzgException;
import com.czg.product.dto.ConsInfoDTO;
import com.czg.product.entity.ConsGroupRelation;
import com.czg.product.entity.ConsInfo;
import com.czg.product.service.ConsInfoService;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.ConsGroupRelationMapper;
import com.czg.service.product.mapper.ConsInfoMapper;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
/**
* 耗材信息
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-20
*/
@Service
@AllArgsConstructor
public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> implements ConsInfoService {
private final ConsGroupRelationMapper consGroupRelationMapper;
private QueryWrapper buildQueryWrapper(ConsInfoDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
if (ObjUtil.isNotNull(param.getConsGroupId())) {
queryWrapper.eq(ConsInfo::getConsGroupId, param.getConsGroupId());
}
if (StrUtil.isNotEmpty(param.getConName())) {
queryWrapper.like(ConsInfo::getConName, param.getConName());
}
if (StrUtil.isNotEmpty(param.getBeginTime())) {
queryWrapper.ge(ConsInfo::getCreateTime, param.getBeginTime());
}
if (StrUtil.isNotEmpty(param.getEndTime())) {
queryWrapper.le(ConsInfo::getCreateTime, param.getEndTime());
}
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ConsInfo::getShopId, shopId);
queryWrapper.orderBy(ConsInfo::getId, false);
return queryWrapper;
}
@Override
public Page<ConsInfoDTO> getConsInfoPage(ConsInfoDTO param) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
return super.pageAs(PageUtil.buildPage(), queryWrapper, ConsInfoDTO.class);
}
@Override
public List<ConsInfoDTO> getConsInfoList(ConsInfoDTO param) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
queryWrapper.eq(ConsInfo::getStatus, StatusEnum.ENABLED.value());
return super.listAs(queryWrapper, ConsInfoDTO.class);
}
@Override
public ConsInfoDTO getConsInfoById(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
return super.getOneAs(query().eq(ConsInfo::getId, id).eq(ConsInfo::getShopId, shopId), ConsInfoDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addConsInfo(ConsInfoDTO dto) {
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ConsInfo::getConName, dto.getConName()).eq(ConsInfo::getShopId, shopId));
if (exists) {
throw new CzgException("耗材信息已存在");
}
ConsInfo entity = BeanUtil.copyProperties(dto, ConsInfo.class);
entity.setStockNumber(BigDecimal.ZERO);
entity.setStatus(StatusEnum.ENABLED.value());
//entity.setConWarning(BigDecimal.ZERO);
entity.setIsStock(YesNoEnum.NO.value());
entity.setShopId(shopId);
super.save(entity);
ConsGroupRelation relation = new ConsGroupRelation();
relation.setConsId(entity.getId());
relation.setGroupId(dto.getConsGroupId());
relation.setSort(entity.getId().intValue());
consGroupRelationMapper.insert(relation);
return true;
}
@Override
public boolean updateConsInfo(ConsInfoDTO dto) {
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ConsInfo::getConName, dto.getConName()).eq(ConsInfo::getShopId, shopId).ne(ConsInfo::getId, dto.getId()));
if (exists) {
throw new CzgException("耗材信息已存在");
}
ConsInfo entity = BeanUtil.copyProperties(dto, ConsInfo.class);
super.updateById(entity);
consGroupRelationMapper.deleteByQuery(query().eq(ConsGroupRelation::getConsId, dto.getId()));
ConsGroupRelation relation = new ConsGroupRelation();
relation.setConsId(entity.getId());
relation.setGroupId(dto.getConsGroupId());
relation.setSort(entity.getId().intValue());
consGroupRelationMapper.insert(relation);
return true;
}
@Override
public boolean deleteConsInfo(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
return super.remove(query().eq(ConsInfo::getId, id).eq(ConsInfo::getShopId, shopId));
}
@Override
public boolean disableConsInfo(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ConsInfo.class)
.set(ConsInfo::getStatus, StatusEnum.DISABLE.value())
.eq(ConsInfo::getId, id)
.eq(ConsInfo::getShopId, shopId)
.update();
}
@Override
public boolean enableConsInfo(Long id) {
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ConsInfo.class)
.set(ConsInfo::getStatus, StatusEnum.ENABLED.value())
.eq(ConsInfo::getId, id)
.eq(ConsInfo::getShopId, shopId)
.update();
}
@Override
public boolean onOffConsInfo(Long id, Integer isStock) {
Long shopId = StpKit.USER.getShopId(0L);
ConsInfo entity = super.getOne(query().eq(ConsInfo::getId, id).eq(ConsInfo::getShopId, shopId));
entity.setIsStock(isStock);
super.updateById(entity);
return false;
}
}

View File

@@ -47,7 +47,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ProdGroup::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ProdGroup::getShopId, shopId);
queryWrapper.orderBy(ProdGroup::getId, false);
return queryWrapper;
@@ -68,7 +68,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
public ProdGroupDTO getProdGroupById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
ProdGroupDTO dto = super.getOneAs(query().eq(ProdGroup::getId, id).eq(ProdGroup::getShopId, shopId), ProdGroupDTO.class);
List<Long> productIdList = prodGroupRelationMapper.selectObjectListByQueryAs(query().select(ProdGroupRelation::getProductId).eq(ProdGroupRelation::getProdGroupId, id), Long.class);
if (CollUtil.isNotEmpty(productIdList)) {
@@ -83,7 +83,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addProdGroup(ProdGroupDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ProdGroup::getName, dto.getName()).eq(ProdGroup::getShopId, shopId));
if (exists) {
throw new CzgException("商品分组已存在");
@@ -109,7 +109,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateProdGroup(ProdGroupDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ProdGroup::getName, dto.getName()).eq(ProdGroup::getShopId, shopId).ne(ProdGroup::getId, dto.getId()));
if (exists) {
@@ -136,7 +136,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteProdGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
super.remove(query().eq(ProdGroup::getId, id).eq(ProdGroup::getShopId, shopId));
prodGroupRelationMapper.deleteByQuery(query().eq(ProdGroupRelation::getProdGroupId, id));
return true;
@@ -144,7 +144,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
public boolean disableProdGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ProdGroup.class)
.set(ProdGroup::getStatus, StatusEnum.DISABLE.value())
.eq(ProdGroup::getId, id)
@@ -154,7 +154,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
@Override
public boolean enableProdGroup(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ProdGroup.class)
.set(ProdGroup::getStatus, StatusEnum.ENABLED.value())
.eq(ProdGroup::getId, id)

View File

@@ -1,21 +1,11 @@
package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.exception.CzgException;
import com.czg.product.dto.ProdSkuDTO;
import com.czg.product.entity.ProdSku;
import com.czg.product.service.ProdSkuService;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.ProdSkuMapper;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 商品SKU
*
@@ -25,88 +15,4 @@ import java.util.List;
@Service
public class ProdSkuServiceImpl extends ServiceImpl<ProdSkuMapper, ProdSku> implements ProdSkuService {
private QueryWrapper buildQueryWrapper(ProdSkuDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
/*if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ProdSku::getName, param.getName());
}*/
Long shopId = StpKit.USER.getLoginIdAsLong();
queryWrapper.eq(ProdSku::getShopId, shopId);
queryWrapper.orderBy(ProdSku::getId, false);
return queryWrapper;
}
@Override
public Page<ProdSkuDTO> getProdSkuPage(ProdSkuDTO param) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
return super.pageAs(PageUtil.buildPage(), queryWrapper, ProdSkuDTO.class);
}
@Override
public List<ProdSkuDTO> getProdSkuList(ProdSkuDTO param) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
//queryWrapper.eq(ProdSku::getStatus, StatusEnum.ENABLED.value());
return super.listAs(queryWrapper, ProdSkuDTO.class);
}
@Override
public ProdSkuDTO getProdSkuById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return super.getOneAs(query().eq(ProdSku::getId, id).eq(ProdSku::getShopId, shopId), ProdSkuDTO.class);
}
@Override
public boolean addProdSku(ProdSkuDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
boolean exists = true;
//super.exists(query().eq(ProdSku::getName, dto.getName()).eq(ProdSku::getShopId, shopId));
if (exists) {
throw new CzgException("商品SKU已存在");
}
ProdSku entity = BeanUtil.copyProperties(dto, ProdSku.class);
//entity.setStatus(StatusEnum.ENABLED.value());
entity.setShopId(shopId);
return super.save(entity);
}
@Override
public boolean updateProdSku(ProdSkuDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
dto.setShopId(shopId);
//boolean exists = super.exists(query().eq(ProdSku::getName, dto.getName()).eq(ProdSku::getShopId, shopId).ne(ProdSku::getId, dto.getId()));
boolean exists = true;
if (exists) {
throw new CzgException("商品SKU已存在");
}
ProdSku entity = BeanUtil.copyProperties(dto, ProdSku.class);
return super.updateById(entity);
}
@Override
public boolean deleteProdSku(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
//return super.remove(query().eq(ClassName}::getId, id).eq(ClassName}::getShopId, shopId));
return true;
}
@Override
public boolean disableProdSku(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return UpdateChain.of(ProdSku.class)
//.set(ProdSku::getStatus, StatusEnum.DISABLE.value())
.eq(ProdSku::getId, id)
.eq(ProdSku::getShopId, shopId)
.update();
}
@Override
public boolean enableProdSku(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
return UpdateChain.of(ProdSku.class)
//.set(ProdSku::getStatus, StatusEnum.ENABLED.value())
.eq(ProdSku::getId, id)
.eq(ProdSku::getShopId, shopId)
.update();
}
}

View File

@@ -73,7 +73,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
if (ObjUtil.isNotNull(param.getCreateEndTime())) {
queryWrapper.le(Product::getCreateTime, param.getCreateEndTime());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(Product::getShopId, shopId);
queryWrapper.eq(Product::getIsDel, DeleteEnum.NORMAL.value());
queryWrapper.orderBy(Product::getSort, false);
@@ -149,7 +149,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addProduct(ProductDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId));
if (exists) {
throw new CzgException("商品已存在");
@@ -189,7 +189,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
public boolean updateProduct(ProductDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(Product::getName, dto.getName()).eq(Product::getShopId, shopId).ne(Product::getId, dto.getId()));
if (exists) {
@@ -242,7 +242,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
public boolean deleteProduct(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(Product.class)
.set(Product::getIsDel, DeleteEnum.DELETED.value())
.eq(Product::getId, id)
@@ -253,7 +253,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
@Transactional(rollbackFor = Exception.class)
public boolean onOffProduct(ProductIsSaleParam param) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
String type = param.getType();
Long id = param.getId();
Integer isSale = param.getIsSale();
@@ -274,7 +274,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
@Transactional(rollbackFor = Exception.class)
public boolean markProductIsSoldOut(ProductIsSoldOutParam param) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
String type = param.getType();
Long id = param.getId();
Integer isSoldOut = param.getIsSoldOut();

View File

@@ -32,7 +32,7 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ShopProdCategory::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ShopProdCategory::getShopId, shopId);
queryWrapper.orderBy(ShopProdCategory::getId, false);
return queryWrapper;
@@ -53,13 +53,13 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
@Override
public ShopProdCategoryDTO getShopProdCategoryById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.getOneAs(query().eq(ShopProdCategory::getId, id).eq(ShopProdCategory::getShopId, shopId), ShopProdCategoryDTO.class);
}
@Override
public boolean addShopProdCategory(ShopProdCategoryDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ShopProdCategory::getName, dto.getName()).eq(ShopProdCategory::getShopId, shopId));
if (exists) {
throw new CzgException("商品分类已存在");
@@ -77,7 +77,7 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
@Override
public boolean updateShopProdCategory(ShopProdCategoryDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ShopProdCategory::getName, dto.getName()).eq(ShopProdCategory::getShopId, shopId).ne(ShopProdCategory::getId, dto.getId()));
if (exists) {
@@ -89,13 +89,13 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
@Override
public boolean deleteShopProdCategory(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.remove(query().eq(ShopProdCategory::getId, id).eq(ShopProdCategory::getShopId, shopId));
}
@Override
public boolean disableShopProdCategory(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdCategory.class)
.set(ShopProdCategory::getStatus, StatusEnum.DISABLE.value())
.eq(ShopProdCategory::getId, id)
@@ -105,7 +105,7 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
@Override
public boolean enableShopProdCategory(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdCategory.class)
.set(ShopProdCategory::getStatus, StatusEnum.ENABLED.value())
.eq(ShopProdCategory::getId, id)

View File

@@ -35,7 +35,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ShopProdUnit::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ShopProdUnit::getShopId, shopId);
queryWrapper.orderBy(ShopProdUnit::getId, false);
return queryWrapper;
@@ -56,13 +56,13 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
@Override
public ShopProdUnitDTO getShopProdUnitById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.getOneAs(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId), ShopProdUnitDTO.class);
}
@Override
public boolean addShopProdUnit(ShopProdUnitDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId));
if (exists) {
throw new CzgException("单位名称已存在");
@@ -79,7 +79,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
@Override
public boolean updateShopProdUnit(ShopProdUnitDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName()).eq(ShopProdUnit::getShopId, shopId).ne(ShopProdUnit::getId, dto.getId()));
if (exists) {
@@ -91,13 +91,13 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
@Override
public boolean deleteShopProdUnit(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.remove(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId));
}
@Override
public boolean disableShopProdUnit(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdUnit.class)
.set(ShopProdUnit::getStatus, StatusEnum.DISABLE.value())
.eq(ShopProdUnit::getId, id)
@@ -107,7 +107,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
@Override
public boolean enableShopProdUnit(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdUnit.class)
.set(ShopProdUnit::getStatus, StatusEnum.ENABLED.value())
.eq(ShopProdUnit::getId, id)

View File

@@ -39,7 +39,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ShopProdSpec::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ShopProdSpec::getShopId, shopId);
queryWrapper.orderBy(ShopProdSpec::getSort, true);
queryWrapper.orderBy(ShopProdSpec::getId, false);
@@ -62,13 +62,13 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
@Override
public ShopProdSpecDTO getShopProdSpecById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.getOneAs(query().eq(ShopProdSpec::getId, id).eq(ShopProdSpec::getShopId, shopId), ShopProdSpecDTO.class);
}
@Override
public boolean addShopProdSpec(ShopProdSpecDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query()
.eq(ShopProdSpec::getName, dto.getName())
.eq(ShopProdSpec::getPid, dto.getPid())
@@ -98,7 +98,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
if (dto.getId().equals(dto.getPid())) {
throw new CzgException("上级规格不能为自身");
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query()
.eq(ShopProdSpec::getName, dto.getName())
@@ -129,7 +129,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
@Override
public boolean deleteShopProdSpec(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.remove(query()
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
.and(SHOP_PROD_SPEC.ID.eq(id).or(SHOP_PROD_SPEC.PIDS.like("," + id + ","))))
@@ -138,7 +138,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
@Override
public boolean disableShopProdSpec(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdSpec.class)
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.DISABLE.value())
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)
@@ -147,7 +147,7 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProdSpecMapper,
@Override
public boolean enableShopProdSpec(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopProdSpec.class)
.set(SHOP_PROD_SPEC.STATUS, StatusEnum.ENABLED.value())
.where(SHOP_PROD_SPEC.SHOP_ID.eq(shopId)

View File

@@ -32,7 +32,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
if (StrUtil.isNotEmpty(param.getName())) {
queryWrapper.like(ShopVendor::getName, param.getName());
}
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
queryWrapper.eq(ShopVendor::getShopId, shopId);
queryWrapper.orderBy(ShopVendor::getSort, true);
queryWrapper.orderBy(ShopVendor::getId, false);
@@ -54,13 +54,13 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
@Override
public ShopVendorDTO getShopVendorById(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return super.getOneAs(query().eq(ShopVendor::getId, id).eq(ShopVendor::getShopId, shopId), ShopVendorDTO.class);
}
@Override
public boolean addShopVendor(ShopVendorDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
boolean exists = super.exists(query().eq(ShopVendor::getName, dto.getName()).eq(ShopVendor::getShopId, shopId));
if (exists) {
throw new CzgException("供应商已存在");
@@ -73,7 +73,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
@Override
public boolean updateShopVendor(ShopVendorDTO dto) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
boolean exists = super.exists(query().eq(ShopVendor::getName, dto.getName()).eq(ShopVendor::getShopId, shopId).ne(ShopVendor::getId, dto.getId()));
if (exists) {
@@ -85,7 +85,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
@Override
public boolean deleteShopVendor(Long id) {
Long shopId = StpKit.USER.getLoginIdAsLong();
Long shopId = StpKit.USER.getShopId(0L);
return UpdateChain.of(ShopVendor.class)
.set(ShopVendor::getIsDel, DeleteEnum.DELETED.value())
.eq(ShopVendor::getId, id)

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.product.mapper.ConsInfoMapper">
</mapper>