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

@@ -33,11 +33,7 @@ public class PrescriptController {
*/ */
@RequestMapping("/getPrescriptList") @RequestMapping("/getPrescriptList")
public R getPrescriptList(@RequestBody Map<String,Object> map){ public R getPrescriptList(@RequestBody Map<String,Object> map){
Integer limit = Integer.valueOf(map.get("limit").toString()); return getR(map);
Integer page = Integer.valueOf(map.get("page").toString());
Integer prescriptCategoryId = Integer.valueOf(map.get("prescriptCategoryId").toString());
Page<PrescriptEntity> prescriptList = prescriptService.getPrescriptList(prescriptCategoryId, limit, page);
return R.ok().put("page",prescriptList);
} }
/** /**
@@ -104,6 +100,34 @@ public class PrescriptController {
return R.ok().put("list",categoryByPid); return R.ok().put("list",categoryByPid);
} }
/**
* 获取方剂文章列表
* @param map
* @return
*/
@RequestMapping("/prescriptList")
public R prescriptList(@RequestBody Map<String,Object> map){
return getR(map);
}
/**
* 获取方剂文章列表(经方)
* @param map
* @return
*/
@RequestMapping("/prescriptListForJF")
public R prescriptListForJF(@RequestBody Map<String,Object> map){
return R.ok();
}
private R getR(@RequestBody Map<String, Object> map) {
Integer limit = Integer.valueOf(map.get("limit").toString());
Integer page = Integer.valueOf(map.get("page").toString());
Integer id = Integer.valueOf(map.get("prescriptCategoryId").toString());
Page<PrescriptEntity> prescriptList = prescriptService.getPrescriptList(id, limit, page);
return R.ok().put("page",prescriptList);
}
/** /**
* 获取方剂分类列表 * 获取方剂分类列表

View File

@@ -21,6 +21,9 @@ public class PrescriptCategoryEntity {
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
@TableField(exist = false)
private PrescriptCategoryEntity child;
@TableField(exist = false) @TableField(exist = false)
private List<PrescriptCategoryEntity> children; private List<PrescriptCategoryEntity> children;

View File

@@ -40,4 +40,7 @@ public class PrescriptEntity {
@TableField(exist = false) @TableField(exist = false)
private List<String> imageList; private List<String> imageList;
@TableField(exist = false)
private PrescriptCategoryEntity prescriptCategoryEntity;
} }

View File

@@ -1,7 +1,6 @@
package com.peanut.modules.book.service.impl; package com.peanut.modules.book.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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); Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (PrescriptEntity p : prescriptEntityPage.getRecords()){ for (PrescriptEntity p : prescriptEntityPage.getRecords()){
p.setImageList(JSON.parseArray(p.getImages(),String.class)); p.setImageList(JSON.parseArray(p.getImages(),String.class));
p.setPrescriptCategoryEntity(getTree(p.getPrescriptCategoryId()));
} }
return prescriptEntityPage; 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;
}
} }