|
|
@@ -1,104 +0,0 @@
|
|
|
-package com.zhongzheng.modules.top.mall.service.impl;
|
|
|
-
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.modules.top.mall.bo.TopStoreCategoryAddBo;
|
|
|
-import com.zhongzheng.modules.top.mall.bo.TopStoreCategoryEditBo;
|
|
|
-import com.zhongzheng.modules.top.mall.bo.TopStoreCategoryQueryBo;
|
|
|
-import com.zhongzheng.modules.top.mall.domain.TopStoreCategory;
|
|
|
-import com.zhongzheng.modules.top.mall.mapper.TopStoreCategoryMapper;
|
|
|
-import com.zhongzheng.modules.top.mall.service.ITopStoreCategoryService;
|
|
|
-import com.zhongzheng.modules.top.mall.vo.TopStoreCategoryVo;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
-
|
|
|
-
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * 店铺类目IDService业务层处理
|
|
|
- *
|
|
|
- * @author ruoyi
|
|
|
- * @date 2023-05-26
|
|
|
- */
|
|
|
-@Service
|
|
|
-public class TopStoreCategoryServiceImpl extends ServiceImpl<TopStoreCategoryMapper, TopStoreCategory> implements ITopStoreCategoryService {
|
|
|
-
|
|
|
- @Override
|
|
|
- public TopStoreCategoryVo queryById(Long catId){
|
|
|
- TopStoreCategory db = this.baseMapper.selectById(catId);
|
|
|
- return BeanUtil.toBean(db, TopStoreCategoryVo.class);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<TopStoreCategoryVo> queryList(TopStoreCategoryQueryBo bo) {
|
|
|
- LambdaQueryWrapper<TopStoreCategory> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.like(StrUtil.isNotBlank(bo.getCatName()), TopStoreCategory::getCatName, bo.getCatName());
|
|
|
- lqw.eq(bo.getStoreId() != null, TopStoreCategory::getStoreId, bo.getStoreId());
|
|
|
- lqw.eq(bo.getMerId() != null, TopStoreCategory::getMerId, bo.getMerId());
|
|
|
- lqw.eq(bo.getParentId() != null, TopStoreCategory::getParentId, bo.getParentId());
|
|
|
- lqw.eq(bo.getStatus() != null, TopStoreCategory::getStatus, bo.getStatus());
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 实体类转化成视图对象
|
|
|
- *
|
|
|
- * @param collection 实体类集合
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<TopStoreCategoryVo> entity2Vo(Collection<TopStoreCategory> collection) {
|
|
|
- List<TopStoreCategoryVo> voList = collection.stream()
|
|
|
- .map(any -> BeanUtil.toBean(any, TopStoreCategoryVo.class))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (collection instanceof Page) {
|
|
|
- Page<TopStoreCategory> page = (Page<TopStoreCategory>)collection;
|
|
|
- Page<TopStoreCategoryVo> pageVo = new Page<>();
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
- pageVo.addAll(voList);
|
|
|
- voList = pageVo;
|
|
|
- }
|
|
|
- return voList;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean insertByAddBo(TopStoreCategoryAddBo bo) {
|
|
|
- TopStoreCategory add = BeanUtil.toBean(bo, TopStoreCategory.class);
|
|
|
- validEntityBeforeSave(add);
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean updateByEditBo(TopStoreCategoryEditBo bo) {
|
|
|
- TopStoreCategory update = BeanUtil.toBean(bo, TopStoreCategory.class);
|
|
|
- validEntityBeforeSave(update);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.updateById(update);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存前的数据校验
|
|
|
- *
|
|
|
- * @param entity 实体类数据
|
|
|
- */
|
|
|
- private void validEntityBeforeSave(TopStoreCategory entity){
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
- }
|
|
|
- return this.removeByIds(ids);
|
|
|
- }
|
|
|
-}
|