|
|
@@ -0,0 +1,145 @@
|
|
|
+package org.dromara.product.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.dromara.product.domain.bo.ProductGiftCategoryBo;
|
|
|
+import org.dromara.product.domain.vo.ProductGiftCategoryVo;
|
|
|
+import org.dromara.product.domain.ProductGiftCategory;
|
|
|
+import org.dromara.product.mapper.ProductGiftCategoryMapper;
|
|
|
+import org.dromara.product.service.IProductGiftCategoryService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 福礼分类Service业务层处理
|
|
|
+ *
|
|
|
+ * @author LionLi
|
|
|
+ * @date 2025-12-23
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class ProductGiftCategoryServiceImpl extends ServiceImpl<ProductGiftCategoryMapper, ProductGiftCategory> implements IProductGiftCategoryService {
|
|
|
+
|
|
|
+ private final ProductGiftCategoryMapper baseMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询福礼分类
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 福礼分类
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ProductGiftCategoryVo queryById(Long id){
|
|
|
+ return baseMapper.selectVoById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询福礼分类列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 福礼分类分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<ProductGiftCategoryVo> queryPageList(ProductGiftCategoryBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<ProductGiftCategory> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<ProductGiftCategoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的福礼分类列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 福礼分类列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ProductGiftCategoryVo> queryList(ProductGiftCategoryBo bo) {
|
|
|
+ LambdaQueryWrapper<ProductGiftCategory> lqw = buildQueryWrapper(bo);
|
|
|
+ return baseMapper.selectVoList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<ProductGiftCategory> buildQueryWrapper(ProductGiftCategoryBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<ProductGiftCategory> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(ProductGiftCategory::getId);
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getCategoryNo()), ProductGiftCategory::getCategoryNo, bo.getCategoryNo());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getCategoryName()), ProductGiftCategory::getCategoryName, bo.getCategoryName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getParentId()), ProductGiftCategory::getParentId, bo.getParentId());
|
|
|
+ lqw.eq(bo.getLevel() != null, ProductGiftCategory::getLevel, bo.getLevel());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsShow()), ProductGiftCategory::getIsShow, bo.getIsShow());
|
|
|
+ lqw.eq(bo.getSort() != null, ProductGiftCategory::getSort, bo.getSort());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsCategoryTag()), ProductGiftCategory::getIsCategoryTag, bo.getIsCategoryTag());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getOneLabel1()), ProductGiftCategory::getOneLabel1, bo.getOneLabel1());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getOneLabel2()), ProductGiftCategory::getOneLabel2, bo.getOneLabel2());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getOneLink1()), ProductGiftCategory::getOneLink1, bo.getOneLink1());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getOneLink2()), ProductGiftCategory::getOneLink2, bo.getOneLink2());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStatus()), ProductGiftCategory::getStatus, bo.getStatus());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), ProductGiftCategory::getPlatformCode, bo.getPlatformCode());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增福礼分类
|
|
|
+ *
|
|
|
+ * @param bo 福礼分类
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(ProductGiftCategoryBo bo) {
|
|
|
+ ProductGiftCategory add = MapstructUtils.convert(bo, ProductGiftCategory.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改福礼分类
|
|
|
+ *
|
|
|
+ * @param bo 福礼分类
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(ProductGiftCategoryBo bo) {
|
|
|
+ ProductGiftCategory update = MapstructUtils.convert(bo, ProductGiftCategory.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(ProductGiftCategory entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除福礼分类信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deleteByIds(ids) > 0;
|
|
|
+ }
|
|
|
+}
|