prescript
This commit is contained in:
@@ -75,6 +75,19 @@ public class R extends HashMap<String, Object> {
|
||||
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) {
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
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.PrescriptService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -22,6 +24,34 @@ public class PrescriptController {
|
||||
@Autowired
|
||||
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
|
||||
@@ -67,7 +97,7 @@ public class PrescriptController {
|
||||
if(b){
|
||||
return R.ok();
|
||||
}else{
|
||||
return R.error();
|
||||
return R.error(303,"删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
|
||||
import com.peanut.modules.book.entity.PrescriptEntity;
|
||||
@@ -8,4 +9,5 @@ import java.util.List;
|
||||
|
||||
public interface PrescriptService extends IService<PrescriptEntity> {
|
||||
|
||||
Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@ public class PrescriptCategoryServiceImpl extends ServiceImpl<PrescriptCategoryD
|
||||
public List<PrescriptCategoryEntity> getPrescriptCategoryList() {
|
||||
LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PrescriptCategoryEntity::getPid,0);
|
||||
wrapper.orderByDesc(PrescriptCategoryEntity::getSort);
|
||||
List<PrescriptCategoryEntity> list = list(wrapper);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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.peanut.modules.book.dao.PrescriptCategoryDao;
|
||||
import com.peanut.modules.book.dao.PrescriptDao;
|
||||
@@ -18,4 +20,13 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
|
||||
@Autowired
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user