耗材分类查询接口增加已绑定数量字段
This commit is contained in:
parent
5226b1719a
commit
86c39780ee
|
|
@ -64,6 +64,9 @@ public class TbConsType implements Serializable {
|
|||
@ApiModelProperty(value = "店铺id")
|
||||
private Integer shopId;
|
||||
|
||||
@Transient
|
||||
private int productNum;
|
||||
|
||||
public void copy(TbConsType source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cn.ysk.cashier.cons.repository;
|
|||
import cn.ysk.cashier.cons.domain.TbConsType;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -14,4 +15,7 @@ public interface TbConsTypeRepository extends JpaRepository<TbConsType, Integer>
|
|||
int countByConTypeCode(String conTypeCode);
|
||||
|
||||
TbConsType findByConTypeCode(String conTypeCode);
|
||||
|
||||
@Query("SELECT count(*) FROM TbProskuCon c LEFT JOIN TbConsInfo i ON c.conInfoId = i.id WHERE i.conTypeId = :id")
|
||||
int countProByTypeId(Integer id);
|
||||
}
|
||||
|
|
@ -45,4 +45,5 @@ public class TbConsTypeDto implements Serializable {
|
|||
|
||||
/** 店铺id */
|
||||
private Integer shopId;
|
||||
private int productNum;
|
||||
}
|
||||
|
|
@ -38,8 +38,18 @@ public class TbConsTypeServiceImpl implements TbConsTypeService {
|
|||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbConsTypeQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbConsType> page = tbConsTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbConsTypeMapper::toDto));
|
||||
Page<TbConsType> page = tbConsTypeRepository
|
||||
.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
|
||||
for (TbConsType tbConsType : page.getContent()) {
|
||||
tbConsType.setProductNum(tbConsTypeRepository.countProByTypeId(tbConsType.getId()));
|
||||
}
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",page.getContent());
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue