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

就诊人管理的接口开发

上级 e240a8c6
......@@ -11,6 +11,12 @@
<artifactId>service_user</artifactId>
<dependencies>
<dependency>
<groupId>com.atguigu</groupId>
<artifactId>service_cmn_client</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.atguigu.yygh.user.api;
import com.atguigu.yygh.model.user.Patient;
import com.atguigu.yygh.user.service.PatientService;
import com.atguigu.yygu.common.result.Result;
import com.atguigu.yygu.common.utils.AuthContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Api(tags = "就诊人控制器")
@RestController
@RequestMapping("/api/user/patient")
public class PatientApiController {
@Autowired
private PatientService patientService;
//获取就诊人列表
@ApiOperation(value = "获取就诊人列表")
@GetMapping("auth/findAll")
public Result findAll(HttpServletRequest request){
//获取当前登录用户id
Long userId = AuthContextHolder.getUserId(request);
List<Patient> list=patientService.findAllUserId(userId);
return Result.ok(list);
}
//添加就诊人
@ApiOperation(value = "添加就诊人")
@PostMapping("auth/save")
public Result savePatient(@RequestBody Patient patient,HttpServletRequest request){
//获取当前登录用户id
Long userId = AuthContextHolder.getUserId(request);
patient.setUserId(userId);
patientService.save(patient);
return Result.ok();
}
//根据id获取就诊人信息
@ApiOperation(value = "根据id获取就诊人信息")
@GetMapping("auth/get/{id}")
public Result getPatient(@PathVariable Long id){
Patient patient=patientService.getPatientId(id);
return Result.ok(patient);
}
//修改就诊人
@ApiOperation(value = "修改就诊人")
@PostMapping("auth/update")
public Result updatePatient(@RequestBody Patient patient){
patientService.updateById(patient);
return Result.ok();
}
//删除就诊人
@ApiOperation(value = "删除就诊人")
@DeleteMapping("auth/remove/{id}")
public Result removePatient(@PathVariable Long id){
patientService.removeById(id);
return Result.ok();
}
}
package com.atguigu.yygh.user.mapper;
import com.atguigu.yygh.model.user.Patient;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface PatientMapper extends BaseMapper<Patient> {
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.atguigu.yygh.user.mapper.PatientMapper">
</mapper>
\ No newline at end of file
package com.atguigu.yygh.user.service;
import com.atguigu.yygh.model.user.Patient;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface PatientService extends IService<Patient> {
//获取就诊人列表
List<Patient> findAllUserId(Long userId);
//根据id获取就诊人信息
Patient getPatientId(Long id);
}
package com.atguigu.yygh.user.service.impl;
import com.atguigu.yygh.cmn.client.DictFeignClient;
import com.atguigu.yygh.enums.DictEnum;
import com.atguigu.yygh.model.user.Patient;
import com.atguigu.yygh.user.mapper.PatientMapper;
import com.atguigu.yygh.user.service.PatientService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PatientServiceImpl extends
ServiceImpl<PatientMapper, Patient> implements PatientService {
@Autowired
private DictFeignClient dictFeignClient;
//获取就诊人列表
@Override
public List<Patient> findAllUserId(Long userId) {
//根据userid查询所有就诊人信息列表
QueryWrapper<Patient> wrapper=new QueryWrapper<>();
wrapper.eq("user_id",userId);
List<Patient> patientList = baseMapper.selectList(wrapper);
//通过远程调用,得到编码对应具体内容,查询数据字典表内容
patientList.forEach(item->{
//其他参数封装
this.packPatient(item);
});
return patientList;
}
//根据id获取就诊人信息
@Override
public Patient getPatientId(Long id) {
Patient patient = baseMapper.selectById(id);
this.packPatient(patient);
return patient;
}
//Patient对象其他参数封装
private void packPatient(Patient patient) {
//根据证件类型编码,获取证件类型具体值
String certificatesTypeString=
dictFeignClient.getName(DictEnum.CERTIFICATES_TYPE.getDictCode(),patient.getCertificatesType());
//联系人证件类型
String contactsCertificatesTypeString =
dictFeignClient.getName(DictEnum.CERTIFICATES_TYPE.getDictCode(),patient.getContactsCertificatesType());
//省
String provinceString = dictFeignClient.getName(patient.getProvinceCode());
//市
String cityString = dictFeignClient.getName(patient.getCityCode());
//区
String districtString = dictFeignClient.getName(patient.getDistrictCode());
patient.getParam().put("certificatesTypeString", certificatesTypeString);
patient.getParam().put("contactsCertificatesTypeString", contactsCertificatesTypeString);
patient.getParam().put("provinceString", provinceString);
patient.getParam().put("cityString", cityString);
patient.getParam().put("districtString", districtString);
patient.getParam().put("fullAddress", provinceString + cityString + districtString + patient.getAddress());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册