DoctorApi.java 7.9 KB

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