prescript

This commit is contained in:
wangjinlei
2023-12-14 11:47:47 +08:00
parent 3219a332e6
commit 508a260a5a
5 changed files with 59 additions and 2 deletions

View File

@@ -75,6 +75,19 @@ public class R extends HashMap<String, Object> {
return r; return r;
} }
public static R code(int code){
R r = new R();
r.put("code",code);
return r;
}
public static R code(int code,String msg){
R r = new R();
r.put("code",code);
r.put("msg",msg);
return r;
}
public static R ok(String msg) { public static R ok(String msg) {
R r = new R(); R r = new R();
r.put("msg", msg); r.put("msg", msg);

View File

@@ -1,7 +1,9 @@
package com.peanut.modules.book.controller; package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.PrescriptCategoryEntity; import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import com.peanut.modules.book.entity.PrescriptEntity;
import com.peanut.modules.book.service.PrescriptCategoryService; import com.peanut.modules.book.service.PrescriptCategoryService;
import com.peanut.modules.book.service.PrescriptService; import com.peanut.modules.book.service.PrescriptService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -22,6 +24,34 @@ public class PrescriptController {
@Autowired @Autowired
private PrescriptCategoryService prescriptCategoryService; private PrescriptCategoryService prescriptCategoryService;
/**
* 获取方剂文章列表
* @param map
* @return
*/
@RequestMapping("/getPrescriptList")
public R getPrescriptList(@RequestBody Map<String,Object> map){
Integer limit = Integer.valueOf(map.get("limit").toString());
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);
}
/**
* 获取方剂文章详情
* @param map
* @return
*/
@RequestMapping("/getPrescriptDetail")
public R getPrescriptDetail(@RequestBody Map<String,Object> map){
Integer integer = Integer.valueOf(map.get("prescriptId").toString());
PrescriptEntity prescript = prescriptService.getById(integer);
return R.ok().put("prescript",prescript);
}
/** /**
* 获取方剂分类列表 * 获取方剂分类列表
* @return * @return
@@ -67,7 +97,7 @@ public class PrescriptController {
if(b){ if(b){
return R.ok(); return R.ok();
}else{ }else{
return R.error(); return R.error(303,"删除失败");
} }
} }

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.service; package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.PrescriptCategoryEntity; import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import com.peanut.modules.book.entity.PrescriptEntity; import com.peanut.modules.book.entity.PrescriptEntity;
@@ -8,4 +9,5 @@ import java.util.List;
public interface PrescriptService extends IService<PrescriptEntity> { public interface PrescriptService extends IService<PrescriptEntity> {
Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page);
} }

View File

@@ -22,9 +22,10 @@ public class PrescriptCategoryServiceImpl extends ServiceImpl<PrescriptCategoryD
public List<PrescriptCategoryEntity> getPrescriptCategoryList() { public List<PrescriptCategoryEntity> getPrescriptCategoryList() {
LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PrescriptCategoryEntity::getPid,0); wrapper.eq(PrescriptCategoryEntity::getPid,0);
wrapper.orderByDesc(PrescriptCategoryEntity::getSort);
List<PrescriptCategoryEntity> list = list(wrapper); List<PrescriptCategoryEntity> list = list(wrapper);
for (PrescriptCategoryEntity p:list){ for (PrescriptCategoryEntity p:list){
p.setChildren(list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid,p.getPrescriptCategoryId()))); p.setChildren(list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid,p.getPrescriptCategoryId()).orderByDesc(PrescriptCategoryEntity::getSort)));
} }
return list; return list;
} }

View File

@@ -1,5 +1,7 @@
package com.peanut.modules.book.service.impl; package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.PrescriptCategoryDao; import com.peanut.modules.book.dao.PrescriptCategoryDao;
import com.peanut.modules.book.dao.PrescriptDao; import com.peanut.modules.book.dao.PrescriptDao;
@@ -18,4 +20,13 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
@Autowired @Autowired
private PrescriptCategoryDao prescriptCategoryDao; private PrescriptCategoryDao prescriptCategoryDao;
@Override
public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) {
LambdaQueryWrapper<PrescriptEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(prescriptCategoryId>0,PrescriptEntity::getPrescriptCategoryId,prescriptCategoryId);
wrapper.orderByDesc(PrescriptEntity::getSort);
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
return prescriptEntityPage;
}
} }