prescript

This commit is contained in:
wangjinlei
2023-12-15 17:46:57 +08:00
parent 8d88be960e
commit 42cbc1155e
3 changed files with 24 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package com.peanut.modules.book.controller; package com.peanut.modules.book.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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;
@@ -48,6 +49,18 @@ public class PrescriptController {
return R.ok().put("prescript",prescript); return R.ok().put("prescript",prescript);
} }
/**
* 获取方剂文章详情
* @param map
* @return
*/
@RequestMapping("/prescriptDetail")
public R prescriptDetail(@RequestBody Map<String,Object> map){
Integer integer = Integer.valueOf(map.get("prescriptId").toString());
PrescriptEntity prescript = prescriptService.getById(integer);
return R.ok().put("prescript",prescript);
}
/** /**
* 添加方剂文章 * 添加方剂文章
* @param p * @param p
@@ -71,7 +84,7 @@ 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)) { } else if (StringUtils.isNotBlank(p.getImages()) &&(p.getImageList()==null||p.getImageList().size()==0)) {
p.setImages(""); p.setImages("");
} }
prescriptService.updateById(p); prescriptService.updateById(p);
@@ -114,15 +127,13 @@ public class PrescriptController {
/** /**
* 获取方剂文章列表(经方) * 获取方剂文章列表(经方)
* @param map * @param
* @return * @return
*/ */
@RequestMapping("/prescriptListForJF") @RequestMapping("/prescriptListForJF")
public R prescriptListForJF(@RequestBody Map<String,Object> map){ public R prescriptListForJF(){
Integer limit = Integer.valueOf(map.get("limit").toString()); List<PrescriptEntity> prescriptListForJF = prescriptService.getPrescriptListForJF();
Integer page = Integer.valueOf(map.get("page").toString()); return R.ok().put("list",prescriptListForJF);
Page<PrescriptEntity> prescriptListForJF = prescriptService.getPrescriptListForJF(limit, page);
return R.ok().put("page",prescriptListForJF);
} }
private R getR(@RequestBody Map<String, Object> map) { private R getR(@RequestBody Map<String, Object> map) {

View File

@@ -11,5 +11,5 @@ public interface PrescriptService extends IService<PrescriptEntity> {
Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page); Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page);
Page<PrescriptEntity> getPrescriptListForJF(int limit,int page); List<PrescriptEntity> getPrescriptListForJF();
} }

View File

@@ -42,13 +42,14 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
} }
@Override @Override
public Page<PrescriptEntity> getPrescriptListForJF(int limit, int page) { public List<PrescriptEntity> getPrescriptListForJF() {
QueryWrapper<PrescriptEntity> wrapper = new QueryWrapper<>(); QueryWrapper<PrescriptEntity> wrapper = new QueryWrapper<>();
wrapper.select("prescript.*","to_first_pinyin(title) letter"); wrapper.select("prescript_id","title","to_first_pinyin(title) letter");
wrapper.eq("prescript_category_id",3); wrapper.eq("prescript_category_id",3);
wrapper.orderByAsc("CONVERT(title USING gbk) COLLATE gbk_chinese_ci"); wrapper.orderByAsc("CONVERT(title USING gbk) COLLATE gbk_chinese_ci");
Page<PrescriptEntity> page1 = page(new Page<PrescriptEntity>(page, limit), wrapper); List<PrescriptEntity> list = list(wrapper);
return page1; // Page<PrescriptEntity> page1 = page(new Page<PrescriptEntity>(page, limit), wrapper);
return list;
} }
private PrescriptCategoryEntity getTree(int categoryId){ private PrescriptCategoryEntity getTree(int categoryId){