prescript

This commit is contained in:
wangjinlei
2023-12-14 17:11:46 +08:00
parent a3b3c1f5f6
commit b527976180
2 changed files with 18 additions and 1 deletions

View File

@@ -71,6 +71,8 @@ public class PrescriptController {
public R editPrescript(@RequestBody PrescriptEntity p){
if(p.getImageList()!=null&&p.getImageList().size()>0){
p.setImages(JSON.toJSONString(p.getImageList()));
} else if (!p.getImages().equals("")&&(p.getImageList()==null||p.getImageList().size()==0)) {
p.setImages("");
}
prescriptService.updateById(p);
return R.ok();

View File

@@ -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);
}
}