| | |
| | | import com.doumee.dao.business.model.Goods; |
| | | import com.doumee.dao.business.model.Labels; |
| | | import com.doumee.dao.web.response.LabelsResponse; |
| | | import com.doumee.service.business.AreasService; |
| | | import com.doumee.service.business.LabelsService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private AreasMapper areasMapper; |
| | | |
| | | @Autowired |
| | | private AreasService areasService; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | labels.setCreator(user.getId()); |
| | | labels.setCreateDate(new Date()); |
| | | labels.setEditor(user.getId()); |
| | | labels.setEditDate(labels.getCreateDate()); |
| | | labels.setIsdeleted(Constants.ZERO); |
| | | labels.setStatus(Constants.ZERO); |
| | | /* if(labels.getParentId()!=null){ |
| | |
| | | areasMapper.update(null,new UpdateWrapper<Areas>().lambda() |
| | | .set(Areas::getBigAreaId,labels.getId()) |
| | | .in(Areas::getId,labels.getAreaIdList())); |
| | | areasService.cacheData(); |
| | | } |
| | | return labels.getId(); |
| | | } |
| | |
| | | labels.setEditDate(new Date()); |
| | | labels.setEditor(user.getId()); |
| | | labelsMapper.updateById(labels); |
| | | if(query!=null && Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey())){ |
| | | int num = areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | .set(Areas::getBigAreaId, null) |
| | | .eq(Areas::getBigAreaId, labels.getId())); |
| | | if(num>0){ |
| | | areasService.cacheData(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Labels labels=new Labels(); |
| | | ids.stream().forEach(s->{ |
| | | int num =0; |
| | | for(Integer s : ids){ |
| | | labels.setId(s); |
| | | labels.setIsdeleted(Constants.ONE); |
| | | labels.setEditDate(new Date()); |
| | | labels.setEditor(user.getId()); |
| | | labelsMapper.updateById(labels); |
| | | }); |
| | | num += areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | .set(Areas::getBigAreaId, null) |
| | | .eq(Areas::getBigAreaId, labels.getId())); |
| | | } |
| | | if(num>0){ |
| | | areasService.cacheData(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | labelsMapper.updateById(labels); |
| | | if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){ |
| | | //先清空原来所有绑定的数据 |
| | | areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | int num = areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | .set(Areas::getBigAreaId, null) |
| | | .eq(Areas::getBigAreaId, labels.getId())); |
| | | if( labels.getAreaIdList()!=null |
| | | &&labels.getAreaIdList().size()>0){ |
| | | //设置最新绑定的数据 |
| | | areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | num += areasMapper.update(null, new UpdateWrapper<Areas>().lambda() |
| | | .set(Areas::getBigAreaId, labels.getId()) |
| | | .in(Areas::getId, labels.getAreaIdList())); |
| | | } |
| | | if(num>0){ |
| | | areasService.cacheData(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<Labels> findList(Labels labels) { |
| | | |
| | | |
| | | MPJLambdaWrapper<Labels> query = new MPJLambdaWrapper<>(); |
| | | |
| | | if(labels!=null&&labels.getParentId()!=null){ |
| | | query.eq(Labels::getParentId,labels.getParentId()); |
| | | }else{ |
| | |
| | | } |
| | | query.eq(Labels::getIsdeleted,Constants.ZERO); |
| | | query.eq(labels.getType()!=null,Labels::getType,labels.getType()); |
| | | query.orderByAsc(Labels::getSortnum); |
| | | List<Labels> list= labelsJoinMapper.selectList(query); |
| | | List<Labels> childList= null; |
| | | if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey())){ |
| | | childList= labelsJoinMapper.selectList(new QueryWrapper<Labels>().lambda() |
| | | .eq(Labels::getIsdeleted,Constants.ZERO) |
| | | .eq(Labels::getType,Constants.LabelsType.SERIES_BRAND.getKey()) |
| | | .orderByAsc(Labels::getSortnum)); |
| | | } |
| | | for(Labels model:list){ |
| | | if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){ |
| | | //如果是大区信息,查询所有绑定额省份信息 |
| | |
| | | .eq(Areas::getIsdeleted,Constants.ZERO) |
| | | .eq(Areas::getBigAreaId,model.getId()))); |
| | | } |
| | | if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey()) |
| | | &&Constants.equalsInteger(model.getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey())){ |
| | | //如果是适应品牌,则查询下级系列 |
| | | model.setChildList(getChildListbyParentId(childList,model.getId())); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private List<Labels> getChildListbyParentId(List<Labels> childList, Integer id) { |
| | | List<Labels> list = new ArrayList<>(); |
| | | if(childList!=null && childList.size()>0){ |
| | | for(Labels labels : childList){ |
| | | if(Constants.equalsInteger(labels.getParentId(),id)){ |
| | | list.add(labels); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return list; |
| | | } |
| | |
| | | |
| | | queryWrapper.selectAll(Labels.class); |
| | | queryWrapper.select("(select name from labels where id=t.PARENT_ID) as parentName"); |
| | | if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.LabelsType.HOMEZHUANQU.getKey())){ |
| | | queryWrapper.select("(select count(g.id) from goods g where g.isdeleted=0 and g.ZHUANQU_IDS like concat('%[',t.id,']%') ) as goodsNum"); |
| | | } |
| | | if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey())){ |
| | | queryWrapper.select("(select count(g.id) from goods g where g.isdeleted=0 and g.BRAND_IDS like concat('%[',t.id,']%') ) as goodsNum"); |
| | | } |
| | | if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.LabelsType.SERIES_BRAND.getKey())){ |
| | | queryWrapper.select("(select count(g.id) from goods g where g.isdeleted=0 and g.SERIAL_IDS like concat('%[',t.id,']%') ) as goodsNum"); |
| | | } |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Labels::getName,pageWrap.getModel().getName()); |
| | | queryWrapper.eq(pageWrap.getModel().getParentId()!=null,Labels::getParentId,pageWrap.getModel().getParentId()); |
| | | queryWrapper.eq(pageWrap.getModel().getType()!=null,Labels::getType,pageWrap.getModel().getType()); |
| | |
| | | IPage<Labels> result = labelsJoinMapper.selectJoinPage(page,Labels.class, queryWrapper); |
| | | /* String resourcePath=systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode();*/ |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(result.getRecords())){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS,Constants.LABELS_IMG).getCode(); |
| | | for(Labels model:result.getRecords()){ |
| | | if(model.getParentId()==null){ |
| | | model.setTypeLevel(0); |
| | | }else{ |
| | | model.setTypeLevel(1); |
| | | } |
| | | if(StringUtils.isNotBlank(model.getImgurl())){ |
| | | model.setImgFullurl(path + model.getImgurl()); |
| | | } |
| | | if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){ |
| | | //如果是大区信息,查询所有绑定额省份信息 |
| | | model.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>() |