医案管理

This commit is contained in:
wuchunlei
2023-11-24 10:32:38 +08:00
parent 9687a73269
commit eee5f460f2
6 changed files with 208 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.peanut.common.utils.Query;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
import com.peanut.modules.book.service.BookMedicalRecordsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("book/bookMedicalRecords")
public class BookMedicalRecordsController {
@Autowired
private BookMedicalRecordsService bookMedicalRecordsService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
new Query<BookMedicalRecordsEntity>().getPage(params),
new QueryWrapper<BookMedicalRecordsEntity>()
.orderByDesc("sort")
.eq("del_flag","0"));
return R.ok().put("page", page);
}
/**
* 根据图书id查询列表
*/
@RequestMapping("/listByBookId")
public R listByBookId(Integer bookId){
List list = bookMedicalRecordsService.list(
new QueryWrapper<BookMedicalRecordsEntity>()
.eq("book_id", bookId)
.eq("del_flag","0")
.orderByDesc("sort"));
return R.ok().put("list", list);
}
/**
* 根据id查询医案
*/
@RequestMapping("/getById")
public R getById(Integer medicalRecordsId){
BookMedicalRecordsEntity entity = bookMedicalRecordsService.getOne(
new QueryWrapper<BookMedicalRecordsEntity>()
.eq("medical_records_id", medicalRecordsId)
.eq("del_flag","0"));
return R.ok().put("entity", entity);
}
/**
* 新增或修改
*/
@RequestMapping("/saveOrUpdate")
public R save(@RequestBody BookMedicalRecordsEntity entity){
try {
if (entity.getSort()==null){
entity.setSort(1);
}
if (entity.getDelFlag()==null){
entity.setDelFlag(0);
}
bookMedicalRecordsService.saveOrUpdate(entity);
return R.ok();
}catch (Exception e) {
return R.error("操作失败:"+e.getMessage());
}
}
/**
* 删除
*/
@RequestMapping("/del")
public R del(Integer medicalRecordsId){
try {
BookMedicalRecordsEntity entity = bookMedicalRecordsService.getOne(
new QueryWrapper<BookMedicalRecordsEntity>()
.eq("medical_records_id", medicalRecordsId));
entity.setDelFlag(1);
bookMedicalRecordsService.updateById(entity);
return R.ok();
}catch (Exception e) {
return R.error("删除失败:"+e.getMessage());
}
}
}