prescript
This commit is contained in:
@@ -71,6 +71,8 @@ public class PrescriptController {
|
|||||||
public R editPrescript(@RequestBody PrescriptEntity p){
|
public R editPrescript(@RequestBody PrescriptEntity p){
|
||||||
if(p.getImageList()!=null&&p.getImageList().size()>0){
|
if(p.getImageList()!=null&&p.getImageList().size()>0){
|
||||||
p.setImages(JSON.toJSONString(p.getImageList()));
|
p.setImages(JSON.toJSONString(p.getImageList()));
|
||||||
|
} else if (!p.getImages().equals("")&&(p.getImageList()==null||p.getImageList().size()==0)) {
|
||||||
|
p.setImages("");
|
||||||
}
|
}
|
||||||
prescriptService.updateById(p);
|
prescriptService.updateById(p);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -25,7 +26,11 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
|
|||||||
@Override
|
@Override
|
||||||
public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) {
|
public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) {
|
||||||
LambdaQueryWrapper<PrescriptEntity> wrapper = new LambdaQueryWrapper<>();
|
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);
|
wrapper.orderByDesc(PrescriptEntity::getSort);
|
||||||
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||||
for (PrescriptEntity p : prescriptEntityPage.getRecords()){
|
for (PrescriptEntity p : prescriptEntityPage.getRecords()){
|
||||||
@@ -45,4 +50,14 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
|
|||||||
tree.setChild(prescriptCategoryEntity);
|
tree.setChild(prescriptCategoryEntity);
|
||||||
return tree;
|
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