prescript
This commit is contained in:
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@@ -25,7 +26,11 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
|
||||
@Override
|
||||
public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) {
|
||||
LambdaQueryWrapper<PrescriptEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(prescriptCategoryId>0,PrescriptEntity::getPrescriptCategoryId,prescriptCategoryId);
|
||||
if(prescriptCategoryId>0){
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
getCategoryIds(prescriptCategoryId,list);
|
||||
wrapper.in(PrescriptEntity::getPrescriptCategoryId,list);
|
||||
}
|
||||
wrapper.orderByDesc(PrescriptEntity::getSort);
|
||||
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
for (PrescriptEntity p : prescriptEntityPage.getRecords()){
|
||||
@@ -45,4 +50,14 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
|
||||
tree.setChild(prescriptCategoryEntity);
|
||||
return tree;
|
||||
}
|
||||
|
||||
private void getCategoryIds(int id,List<Integer> list){
|
||||
PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId, id));
|
||||
|
||||
List<PrescriptCategoryEntity> prescriptCategoryEntities = prescriptCategoryDao.selectList(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid, prescriptCategoryEntity.getPrescriptCategoryId()));
|
||||
for (PrescriptCategoryEntity p : prescriptCategoryEntities){
|
||||
getCategoryIds(p.getPrescriptCategoryId(),list);
|
||||
}
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user