提交 8456277e 编写于 作者: 别团等shy哥发育's avatar 别团等shy哥发育

查询排班接口开发实现

上级 e151f2ab
......@@ -2,7 +2,9 @@ package com.atguigu.yygu.hosp.controller.api;
import com.atguigu.yygh.model.hosp.Department;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.DepartmentQueryVo;
import com.atguigu.yygh.vo.hosp.ScheduleQueryVo;
import com.atguigu.yygu.common.exception.YyghException;
import com.atguigu.yygu.common.helper.HttpRequestHelper;
import com.atguigu.yygu.common.result.Result;
......@@ -189,7 +191,6 @@ public class ApiController {
Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap);
String hoscode= (String) paramMap.get("hoscode");
//签名校验
//1、获取医院系统传递过来的签名,签名是MD5加密之后的
String hospSign = (String) paramMap.get("sign");
......@@ -204,6 +205,44 @@ public class ApiController {
scheduleService.save(paramMap);
return Result.ok();
}
//查询排班接口
@PostMapping("schedule/list")
public Result findSchedule(HttpServletRequest request){
//获取传递过来的医院信息
Map<String, String[]> requestMap = request.getParameterMap();
Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap);
//医院编号
String hoscode= (String) paramMap.get("hoscode");
//科室编号
String depcode= (String) paramMap.get("depcode");
//当前页 和 每页记录数
int page = StringUtils.isEmpty(paramMap.get("page")) ? 1 : Integer.parseInt((String)paramMap.get("page"));
int limit = StringUtils.isEmpty(paramMap.get("limit")) ? 1 : Integer.parseInt((String)paramMap.get("limit"));
//签名校验
//1、获取医院系统传递过来的签名,签名是MD5加密之后的
String hospSign = (String) paramMap.get("sign");
//2、根据传递过来的医院编号,查询数据库,查询签名
String signKey=hospitalSetService.getSignKey(hoscode);
//3、把数据库查询出来的签名进行MD5加密
String signKeyMd5 = MD5.encrypt(signKey);
//4、判断签名是否一致
if(!hospSign.equals(signKeyMd5)){
throw new YyghException(ResultCodeEnum.SIGN_ERROR);
}
ScheduleQueryVo scheduleQueryVo=new ScheduleQueryVo();
scheduleQueryVo.setHoscode(hoscode);
scheduleQueryVo.setDepcode(depcode);
//调用service方法
Page<Schedule> pageModel=scheduleService.findPageSchedule(page,limit,scheduleQueryVo);
return Result.ok(pageModel);
}
......
package com.atguigu.yygu.hosp.service;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleQueryVo;
import org.springframework.data.domain.Page;
import java.util.Map;
public interface ScheduleService {
//上传排班接口
void save(Map<String, Object> paramMap);
//查询排班接口
Page<Schedule> findPageSchedule(int page, int limit, ScheduleQueryVo scheduleQueryVo);
}
......@@ -2,9 +2,12 @@ package com.atguigu.yygu.hosp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleQueryVo;
import com.atguigu.yygu.hosp.repository.ScheduleRepository;
import com.atguigu.yygu.hosp.service.ScheduleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -40,4 +43,25 @@ public class ScheduleServiceImpl implements ScheduleService {
scheduleRepository.save(schedule);
}
}
//查询排班接口
@Override
public Page<Schedule> findPageSchedule(int page, int limit, ScheduleQueryVo scheduleQueryVo) {
// 创建Pageable对象,设置当前页和每页记录数
//0是第一页
Pageable pageable = PageRequest.of(page-1,limit);
// 创建Example对象
Schedule schedule = new Schedule();
BeanUtils.copyProperties(scheduleQueryVo,schedule);
schedule.setIsDeleted(0);
schedule.setStatus(1);
ExampleMatcher matcher = ExampleMatcher.matching()
.withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)
.withIgnoreCase(true);
Example<Schedule> example = Example.of(schedule,matcher);
Page<Schedule> all = scheduleRepository.findAll(example, pageable);
return all;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册