123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- package com.yunzhi.demo.controller;
-
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.yunzhi.demo.common.BaseController;
- import com.yunzhi.demo.common.Constants;
- import com.yunzhi.demo.common.ResponseBean;
- import com.yunzhi.demo.common.StringUtils;
- import com.yunzhi.demo.entity.TaPerson;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import com.yunzhi.demo.service.ITaMedicalLogService;
- import com.yunzhi.demo.entity.TaMedicalLog;
-
- /**
- * <p>
- * 就诊记录 前端控制器
- * </p>
- *
- * @author yansen
- * @since 2021-04-15
- */
-
- @Api(tags = "就诊记录")
- @RestController
- @RequestMapping("/")
- public class TaMedicalLogController extends BaseController {
-
- private final Logger logger = LoggerFactory.getLogger(TaMedicalLogController.class);
-
- @Autowired
- public ITaMedicalLogService iTaMedicalLogService;
-
- @GetMapping("/ma/medical-log")
- @ApiOperation(value="我的就诊记录", notes = "我的就诊记录", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean maMedicalList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
- TaPerson taPerson = getCurrentPerson();
-
- IPage<TaMedicalLog> pg = new Page<>(pageNum, pageSize);
- QueryWrapper<TaMedicalLog> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("person_id", taPerson.getPersonId());
- queryWrapper.eq("status", Constants.STATUS_NORMAL);
- queryWrapper.orderByDesc("create_date");
-
- IPage<TaMedicalLog> result = iTaMedicalLogService.page(pg, queryWrapper);
- return ResponseBean.success(result);
- }
-
-
- /**
- * 分页查询列表
- * @param pageNum
- * @param pageSize
- * @return
- */
- @RequestMapping(value="/taMedicalLog",method= RequestMethod.GET)
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean taMedicalLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
-
- IPage<TaMedicalLog> pg = new Page<>(pageNum, pageSize);
- QueryWrapper<TaMedicalLog> queryWrapper = new QueryWrapper<>();
- queryWrapper.orderByDesc("create_date");
-
- IPage<TaMedicalLog> result = iTaMedicalLogService.page(pg, queryWrapper);
- return ResponseBean.success(result);
- }
-
- /**
- * 分页查询列表
- * @param pageNum
- * @param pageSize
- * @return
- */
- @RequestMapping(value="/admin/medicalLog",method= RequestMethod.GET)
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean medicalLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
- @ApiParam("学校ID") @RequestParam(value ="schoolId", required = false) String schoolId,
- @ApiParam("专业ID") @RequestParam(value ="specialtyId", required = false) String specialtyId,
- @ApiParam("学号") @RequestParam(value ="studentNo", required = false) String studentNo) throws Exception{
-
- IPage<TaMedicalLog> pg = new Page<>(pageNum, pageSize);
- IPage<TaMedicalLog> result = iTaMedicalLogService.getMedicalLogPagedBy(pg, schoolId, specialtyId, studentNo);
- return ResponseBean.success(result);
- }
-
- /**
- * 保存对象
- * @param taMedicalLog 实体对象
- * @return
- */
- @RequestMapping(value="/taMedicalLog",method= RequestMethod.POST)
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
- public ResponseBean taMedicalLogAdd(@ApiParam("保存内容") @RequestBody TaMedicalLog taMedicalLog) throws Exception{
-
- if (iTaMedicalLogService.save(taMedicalLog)){
- return ResponseBean.success(taMedicalLog);
- }else {
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
- /**
- * 保存对象
- * @param taMedicalLog 实体对象
- * @return
- */
- @RequestMapping(value="/admin/medicalLog",method= RequestMethod.POST)
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
- public ResponseBean medicalLogAdd(@ApiParam("保存内容") @RequestBody TaMedicalLog taMedicalLog) throws Exception{
-
- if (iTaMedicalLogService.save(taMedicalLog)){
- return ResponseBean.success(taMedicalLog);
- }else {
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
- /**
- * 根据id删除对象
- * @param id 实体ID
- */
- @RequestMapping(value="/taMedicalLog/{id}", method= RequestMethod.DELETE)
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
- public ResponseBean taMedicalLogDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
- if(iTaMedicalLogService.removeById(id)){
- return ResponseBean.success("success");
- }else {
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
- /**
- * 修改对象
- * @param id 实体ID
- * @param taMedicalLog 实体对象
- * @return
- */
- @RequestMapping(value="/taMedicalLog/{id}",method= RequestMethod.PUT)
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
- public ResponseBean taMedicalLogUpdate(@ApiParam("对象ID") @PathVariable Integer id,
- @ApiParam("更新内容") @RequestBody TaMedicalLog taMedicalLog) throws Exception{
-
- if (iTaMedicalLogService.updateById(taMedicalLog)){
- return ResponseBean.success(iTaMedicalLogService.getById(id));
- }else {
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
- }
- }
-
- /**
- * 根据id查询对象
- * @param id 实体ID
- */
- @RequestMapping(value="/{client}/medical-log/{id}",method= RequestMethod.GET)
- @ApiOperation(value="就诊详情", notes = "就诊详情", httpMethod = "GET", response = ResponseBean.class)
- public ResponseBean taMedicalLogGet(@ApiParam(value = "客户端", allowableValues = "admin,ma") @PathVariable String client,
- @ApiParam("就诊ID") @PathVariable Integer id) throws Exception{
- return ResponseBean.success(iTaMedicalLogService.getById(id));
- }
-
-
- }
|