DoctorApi.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.caimei.controller.auth;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.po.CmBrandDoctorPo;
  5. import com.caimei.model.vo.DoctorFormVo;
  6. import com.caimei.model.vo.DoctorListVo;
  7. import com.caimei.service.auth.DoctorService;
  8. import com.github.pagehelper.PageInfo;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiImplicitParam;
  11. import io.swagger.annotations.ApiImplicitParams;
  12. import io.swagger.annotations.ApiOperation;
  13. import lombok.RequiredArgsConstructor;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * 供应商API
  20. *
  21. * @author : Aslee
  22. * @date : 2021/5/11
  23. */
  24. @Api(tags = "医师API")
  25. @Slf4j
  26. @RestController
  27. @RequiredArgsConstructor
  28. @RequestMapping("/doctor")
  29. public class DoctorApi {
  30. private final DoctorService doctorService;
  31. @ApiOperation("医师列表")
  32. @ApiImplicitParams({
  33. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1医师列表,2医师审核列表"),
  34. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  35. @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"),
  36. @ApiImplicitParam(name = "doctorName", required = false, value = "医师姓名"),
  37. @ApiImplicitParam(name = "certificateNo", required = false, value = "从业资格证编号"),
  38. @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
  39. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  40. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  41. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  42. })
  43. @GetMapping("/list")
  44. public ResponseJson<PageInfo<DoctorListVo>> getDoctorList(Integer listType, Integer authUserId, Integer doctorType, String doctorName, String certificateNo, Integer status, Integer auditStatus,
  45. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  46. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  47. return doctorService.getDoctorList(listType, authUserId, doctorType, doctorName, certificateNo, status, auditStatus, pageNum, pageSize);
  48. }
  49. /**
  50. * 更新医师状态
  51. */
  52. @ApiOperation("更新医师状态")
  53. @ApiImplicitParam(name = "params", value = "doctorId:医师id;status:医师状态:0停用 1启用;", required = true)
  54. @PostMapping("/update/status")
  55. public ResponseJson updateDoctorStatus(@RequestBody Map<String,Integer> params) {
  56. Integer doctorId = params.get("doctorId");
  57. Integer status = params.get("status");
  58. return doctorService.updateDoctorStatus(doctorId, status);
  59. }
  60. /**
  61. * 删除医师
  62. */
  63. @ApiOperation("删除医师")
  64. @ApiImplicitParam(name = "params", value = "doctorId:医师id", required = true)
  65. @PostMapping("/delete")
  66. public ResponseJson deleteDoctor(@RequestBody Map<String,Integer> params) {
  67. Integer doctorId = params.get("doctorId");
  68. return doctorService.deleteDoctor(doctorId);
  69. }
  70. /**
  71. * 医师回显数据
  72. */
  73. @ApiOperation("医师回显数据")
  74. @ApiImplicitParam(name = "doctorId", required = true, value = "医师id")
  75. @GetMapping("/form/data")
  76. public ResponseJson<DoctorFormVo> getDoctorFormData(Integer doctorId) {
  77. return doctorService.getDoctorFormData(doctorId);
  78. }
  79. /**
  80. * 添加/编辑医师
  81. */
  82. @ApiOperation("添加/编辑医师")
  83. @ApiImplicitParam(name = "params", value = "doctorId:医师id;authUserId:供应商用户id;authId:机构id;doctorType:医师类型:1操作医师,2培训医师;" +
  84. "doctorName:医师姓名;" +"certificateNo:从业资格证编号;clubName:所在机构;createBy:创建人id;" +
  85. "bannerList:轮播图列表;" +"doctorImage:医师照片;equipmentList([{equipmentName:'',brand:'',image:''}]);" +
  86. "tagList(['标签1','标签2'];" + "paramList([{name:'参数1',content:'内容1'}..]))", required = true)
  87. @PostMapping("/save")
  88. public ResponseJson saveDoctor(@RequestBody String params) {
  89. JSONObject paramsMap = JSONObject.parseObject(params);
  90. Integer doctorId = paramsMap.getInteger("doctorId");
  91. Integer authUserId = paramsMap.getInteger("authUserId");
  92. Integer authId = paramsMap.getInteger("authId");
  93. Integer doctorType = paramsMap.getInteger("doctorType");
  94. String doctorName = paramsMap.getString("doctorName");
  95. String certificateNo = paramsMap.getString("certificateNo");
  96. String clubName = paramsMap.getString("clubName");
  97. String doctorImage = paramsMap.getString("doctorImage");
  98. Integer createBy = paramsMap.getInteger("createBy");
  99. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  100. List<String> tagList = (List<String>) paramsMap.get("tagList");
  101. List<Map<String,Object>> equipmentList = (List<Map<String,Object>>) paramsMap.get("equipmentList");
  102. List<Map<String,String>> paramList = (List<Map<String,String>>) paramsMap.get("paramList");
  103. /*
  104. 组装医师数据
  105. */
  106. CmBrandDoctorPo doctor = new CmBrandDoctorPo();
  107. doctor.setId(doctorId);
  108. doctor.setAuthUserId(authUserId);
  109. doctor.setAuthId(authId);
  110. doctor.setDoctorType(doctorType);
  111. doctor.setName(doctorName);
  112. doctor.setImage(doctorImage);
  113. doctor.setCertificateNo(certificateNo);
  114. doctor.setClubName(clubName);
  115. doctor.setCreateBy(createBy);
  116. return doctorService.saveDoctor(doctor, bannerList, equipmentList, tagList, paramList);
  117. }
  118. /**
  119. * 审核医师
  120. */
  121. @ApiOperation("审核医师")
  122. @ApiImplicitParam(name = "params", value = "doctorId:医师id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
  123. @PostMapping("/audit")
  124. public ResponseJson auditDoctor(@RequestBody String params) {
  125. JSONObject paramsMap = JSONObject.parseObject(params);
  126. Integer doctorId = paramsMap.getInteger("doctorId");
  127. Integer auditStatus = paramsMap.getInteger("auditStatus");
  128. String invalidReason = paramsMap.getString("invalidReason");
  129. Integer auditBy = paramsMap.getInteger("auditBy");
  130. return doctorService.auditDoctor(doctorId, auditStatus, invalidReason, auditBy);
  131. }
  132. }