prescript

This commit is contained in:
wangjinlei
2023-12-14 15:22:10 +08:00
parent af081f6e81
commit a3b3c1f5f6
4 changed files with 47 additions and 6 deletions

View File

@@ -1,7 +1,6 @@
package com.peanut.modules.book.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -31,7 +30,19 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (PrescriptEntity p : prescriptEntityPage.getRecords()){
p.setImageList(JSON.parseArray(p.getImages(),String.class));
p.setPrescriptCategoryEntity(getTree(p.getPrescriptCategoryId()));
}
return prescriptEntityPage;
}
private PrescriptCategoryEntity getTree(int categoryId){
PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId,categoryId));
if(prescriptCategoryEntity.getPid()==0){
return prescriptCategoryEntity;
}
PrescriptCategoryEntity tree = getTree(prescriptCategoryEntity.getPid());
tree.setChild(prescriptCategoryEntity);
return tree;
}
}