prescript

This commit is contained in:
wangjinlei
2023-12-14 13:23:18 +08:00
parent 508a260a5a
commit 6a42c41ec2
3 changed files with 52 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
@@ -51,6 +52,46 @@ public class PrescriptController {
return R.ok().put("prescript",prescript);
}
/**
* 添加方剂文章
* @param p
* @return
*/
@RequestMapping("/addPrescript")
public R addPrescript(@RequestBody PrescriptEntity p){
if(p.getImages()!=null&&p.getImageList().size()>0){
p.setImages(JSON.toJSONString(p.getImageList()));
}
prescriptService.save(p);
return R.ok();
}
/**
* 修改方剂文章
* @param p
* @return
*/
@RequestMapping("/editPrescript")
public R editPrescript(@RequestBody PrescriptEntity p){
if(p.getImages()!=null&&p.getImageList().size()>0){
p.setImages(JSON.toJSONString(p.getImageList()));
}
prescriptService.updateById(p);
return R.ok();
}
/**
* 删除方剂文章
* @param map
* @return
*/
@RequestMapping("/delPrescript")
public R delPrescript(@RequestBody Map<String,Object> map){
Integer integer = Integer.valueOf(map.get("prescriptId").toString());
prescriptService.removeById(integer);
return R.ok();
}
/**
* 获取方剂分类列表
@@ -97,7 +138,7 @@ public class PrescriptController {
if(b){
return R.ok();
}else{
return R.error(303,"删除失败");
return R.code(303,"删除失败");
}
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@TableName("prescript")
@@ -35,4 +36,8 @@ public class PrescriptEntity {
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private List<String> imageList;
}

View File

@@ -1,5 +1,7 @@
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;
@@ -27,6 +29,9 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
wrapper.eq(prescriptCategoryId>0,PrescriptEntity::getPrescriptCategoryId,prescriptCategoryId);
wrapper.orderByDesc(PrescriptEntity::getSort);
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (PrescriptEntity p : prescriptEntityPage.getRecords()){
p.setImageList(JSON.parseArray(p.getImages(),String.class));
}
return prescriptEntityPage;
}
}