Commit 0eb00cc9 authored by shiyu's avatar shiyu

邀请码已使用人数

parent f9701514
...@@ -117,7 +117,7 @@ public class InvitationCodeServiceImpl implements InvitationCodeService { ...@@ -117,7 +117,7 @@ public class InvitationCodeServiceImpl implements InvitationCodeService {
if (CollectionUtils.isEmpty(inviteRecordVoList)) { if (CollectionUtils.isEmpty(inviteRecordVoList)) {
invitationCodeVo.setUsedNum(0); invitationCodeVo.setUsedNum(0);
} else { } else {
invitationCodeVo.setUsedNum(invitationCodeVoList.size()); invitationCodeVo.setUsedNum(inviteRecordVoList.size());
} }
invitationCodeVoList.add(invitationCodeVo); invitationCodeVoList.add(invitationCodeVo);
}); });
......
...@@ -19,6 +19,8 @@ public interface CategoryDao { ...@@ -19,6 +19,8 @@ public interface CategoryDao {
List<Category> queryByPid(Integer pid); List<Category> queryByPid(Integer pid);
List<Category> queryByPids(List<Integer> pidList);
Category findById(Integer id); Category findById(Integer id);
/** /**
......
...@@ -56,6 +56,17 @@ public class CategoryDaoImpl implements CategoryDao { ...@@ -56,6 +56,17 @@ public class CategoryDaoImpl implements CategoryDao {
return categoryMapper.selectByExampleWithBLOBs(example); return categoryMapper.selectByExampleWithBLOBs(example);
} }
@Override
public List<Category> queryByPids(List<Integer> pidList) {
CategoryExample example = new CategoryExample();
CategoryExample.Criteria criteria = example.createCriteria();
criteria.andPidIn(pidList).andIsDeletedEqualTo(false);
return categoryMapper.selectByExample(example);
}
public Category findById(Integer id) { public Category findById(Integer id) {
return categoryMapper.selectByPrimaryKey(id); return categoryMapper.selectByPrimaryKey(id);
} }
......
package com.wwdz.ch.wx.entity;
import com.wwdz.ch.db.domain.Category;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class TransverseCategory implements Entity {
private Integer id;
private String name;
private Integer pid;
private Integer level;
private Boolean isLeaf;
public TransverseCategory() {
}
public TransverseCategory(Integer id, String name, Integer pid, Integer level, Boolean isLeaf) {
this.id = id;
this.name = name;
this.pid = pid;
this.level = level;
this.isLeaf = isLeaf;
}
public static TransverseCategory ofTitle(Category category) {
TransverseCategory transverseCategory = new TransverseCategory();
transverseCategory.setId(category.getId());
transverseCategory.setName(category.getName());
transverseCategory.setLevel(category.getLevel());
transverseCategory.setIsLeaf(category.getIsLeaf());
transverseCategory.setPid(category.getPid());
return transverseCategory;
}
}
...@@ -10,4 +10,5 @@ public class CategoryRequestDto implements Entity { ...@@ -10,4 +10,5 @@ public class CategoryRequestDto implements Entity {
private Integer page; private Integer page;
private Integer size; private Integer size;
private String name; private String name;
private Integer pid;
} }
...@@ -185,6 +185,15 @@ public class CategoryVo implements Serializable { ...@@ -185,6 +185,15 @@ public class CategoryVo implements Serializable {
return new CategoryVo(category); return new CategoryVo(category);
} }
public static CategoryVo ofTitle(Category category) {
CategoryVo categoryVo = new CategoryVo();
categoryVo.setId(category.getId());
categoryVo.setName(category.getName());
categoryVo.setLevel(category.getLevel());
categoryVo.setIsLeaf(category.getIsLeaf());
return categoryVo;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
......
package com.wwdz.ch.wx.entity.vo;
import com.wwdz.ch.wx.entity.TransverseCategory;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* 横向类目展示
*/
@Data
public class TransverseCategoryVo {
private List<TransverseCategory> firstCategory;
private List<Map<String, Object>> childCategory;
}
...@@ -5,8 +5,11 @@ import com.wwdz.ch.core.type.Result; ...@@ -5,8 +5,11 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.CategoryDao; import com.wwdz.ch.db.dao.CategoryDao;
import com.wwdz.ch.db.domain.Category; import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.dto.request.CategorySearchRequestDto; import com.wwdz.ch.db.dto.request.CategorySearchRequestDto;
import com.wwdz.ch.wx.entity.TransverseCategory;
import com.wwdz.ch.wx.entity.request.CategoryRequestDto; import com.wwdz.ch.wx.entity.request.CategoryRequestDto;
import com.wwdz.ch.wx.entity.vo.CategoryResponseVo; import com.wwdz.ch.wx.entity.vo.CategoryResponseVo;
import com.wwdz.ch.wx.entity.vo.CategoryVo;
import com.wwdz.ch.wx.entity.vo.TransverseCategoryVo;
import com.wwdz.ch.wx.service.CategoryService; import com.wwdz.ch.wx.service.CategoryService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -21,6 +24,9 @@ import java.util.stream.Collectors; ...@@ -21,6 +24,9 @@ import java.util.stream.Collectors;
@Service @Service
public class CategoryServiceImpl implements CategoryService { public class CategoryServiceImpl implements CategoryService {
private static final Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class);
private static final Integer TOP_PID = 0;
@Autowired @Autowired
private CategoryDao categoryDao; private CategoryDao categoryDao;
...@@ -168,4 +174,38 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -168,4 +174,38 @@ public class CategoryServiceImpl implements CategoryService {
vo.setIsChosen(0); vo.setIsChosen(0);
return vo; return vo;
} }
@Override
public Result findCategoryByTransverse(CategoryRequestDto dto) {
try {
TransverseCategoryVo transverseCategoryVo = new TransverseCategoryVo();
//查询所有的第一级类目
List<Category> categoryList = categoryDao.queryByPid(TOP_PID);
List<TransverseCategory> firstCategoryVoList = categoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
transverseCategoryVo.setFirstCategory(firstCategoryVoList);
List<Map<String, Object>> childList = new ArrayList<>();
categoryList.forEach(firstCategory -> {
int firstCategoryId = firstCategory.getId();
//查询第二级类目
List<Category> secondCategoryList = categoryDao.queryByPid(firstCategoryId);
List<Integer> secondCategoryIdList = secondCategoryList.stream().map(Category::getId).collect(Collectors.toList());
//查询三级类目
List<Category> thirdCategoryList = categoryDao.queryByPids(secondCategoryIdList);
List<TransverseCategory> secondCategoryVoList = secondCategoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
List<TransverseCategory> thirdCategoryVoList = thirdCategoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
Map<String, Object> valueMap = new HashMap<>();
valueMap.put("firstCategoryId", firstCategory.getId());
valueMap.put("secondCategory", secondCategoryVoList);
valueMap.put("thirdCategory", thirdCategoryVoList);
childList.add(valueMap);
});
transverseCategoryVo.setChildCategory(childList);
return Result.success(transverseCategoryVo);
} catch (Exception e) {
logger.error("获取类目横向展示出错:{}", e);
}
return Result.failed();
}
} }
...@@ -42,4 +42,12 @@ public interface CategoryService { ...@@ -42,4 +42,12 @@ public interface CategoryService {
* @return * @return
*/ */
Result findNames(CategoryRequestDto dto); Result findNames(CategoryRequestDto dto);
/**
* 查价页面横向展示类目
* @param dto
* @return
*/
Result findCategoryByTransverse(CategoryRequestDto dto);
} }
...@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON; ...@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.consts.ResultCode; import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.BidRecordRequestDto; import com.wwdz.ch.db.dto.request.BidRecordRequestDto;
import com.wwdz.ch.wx.entity.request.CategoryRequestDto;
import com.wwdz.ch.wx.entity.request.QueryPriceRequestDto; import com.wwdz.ch.wx.entity.request.QueryPriceRequestDto;
import com.wwdz.ch.wx.service.CategoryService;
import com.wwdz.ch.wx.service.QueryPriceService; import com.wwdz.ch.wx.service.QueryPriceService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -26,6 +28,9 @@ public class QueryPriceController { ...@@ -26,6 +28,9 @@ public class QueryPriceController {
@Autowired @Autowired
QueryPriceService queryPriceService; QueryPriceService queryPriceService;
@Autowired
CategoryService categoryService;
@ApiOperation(value = "查价价格详情") @ApiOperation(value = "查价价格详情")
@PostMapping("/findDetails") @PostMapping("/findDetails")
public Result findDetails(@RequestBody QueryPriceRequestDto dto) { public Result findDetails(@RequestBody QueryPriceRequestDto dto) {
...@@ -45,4 +50,11 @@ public class QueryPriceController { ...@@ -45,4 +50,11 @@ public class QueryPriceController {
} }
return queryPriceService.findBidRecord(dto); return queryPriceService.findBidRecord(dto);
} }
@ApiOperation(value = "横向类目查询")
@PostMapping("/findTransverseCategory")
public Result findTransverseCategory(@RequestBody CategoryRequestDto dto) {
return categoryService.findCategoryByTransverse(dto);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment