| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | |
| | | @Service |
| | | public class CategoryServiceImpl implements CategoryService { |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private CategoryMapper categoryMapper; |
| | | |
| | |
| | | IPage<Category> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<Category> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + |
| | | systemDictDataBiz.queryByCode(Constants.FTP,Constants.BANNER_IMG).getCode(); |
| | | |
| | | queryWrapper.lambda().eq(Category::getIsdeleted,Constants.ZERO) |
| | | .eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType()) |
| | | .isNull(Category::getParentId); |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Category::getName,pageWrap.getModel().getName()) |
| | | .isNull(Category::getParentId) |
| | | .orderByDesc(Category::getSortnum); |
| | | PageData<Category> categoryPageData = PageData.from(categoryMapper.selectPage(page, queryWrapper)); |
| | | //查询所有二级数据 |
| | | List<Category> categoryList = categoryMapper.selectList( |
| | | new QueryWrapper<Category>().lambda() |
| | | .eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType()) |
| | | .eq(Category::getIsdeleted,Constants.ZERO).isNotNull(Category::getParentId)); |
| | | .eq(Category::getIsdeleted,Constants.ZERO).isNotNull(Category::getParentId).orderByDesc(Category::getSortnum)); |
| | | |
| | | for (Category category:categoryPageData.getRecords()) { |
| | | category.setChildCategoryList( |
| | | categoryList.stream().filter(i->Constants.equalsInteger(i.getParentId(),category.getId())).collect(Collectors.toList()) |
| | | ); |
| | | if(StringUtils.isNotBlank(category.getImgurl())){ |
| | | category.setImgurlFull(prefixUrl + category.getImgurl()); |
| | | } |
| | | } |
| | | |
| | | return categoryPageData; |
| | |
| | | } |
| | | @Override |
| | | public List<Category> findChileList(Category model) { |
| | | if(Objects.isNull(model)){ |
| | | model = new Category(); |
| | | } |
| | | model.setIsdeleted(Constants.ZERO); |
| | | List<Category> list =findList(model); |
| | | List<Category> data = new ArrayList<>(); |
| | |
| | | category.setGroupName( category.getParentName()+"/"+category.getName()); |
| | | data.add(category); |
| | | } |
| | | }else{ |
| | | data.add(category); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | List<Category> categories = categoryMapper.selectList(wrapper); |
| | | if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categories)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"分类信息已存在"); |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"信息已存在"); |
| | | } |
| | | } |
| | | } |