package com.caimei.controller.admin.auth; import com.alibaba.fastjson.JSONObject; import com.caimei.annotation.CurrentUser; import com.caimei.model.ResponseJson; import com.caimei.model.po.CmBrandDoctorPo; import com.caimei.model.po.SysUser; import com.caimei.model.vo.DoctorFormVo; import com.caimei.model.vo.DoctorListVo; import com.caimei.service.auth.DoctorService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; /** * 供应商API * * @author : Aslee * @date : 2021/5/11 */ @Api(tags = "医师API") @Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/doctor") public class DoctorApi { private final DoctorService doctorService; @ApiOperation("医师列表") @ApiImplicitParams({ @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1医师列表,2医师审核列表"), @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"), @ApiImplicitParam(name = "doctorName", required = false, value = "医师姓名"), @ApiImplicitParam(name = "certificateNo", required = false, value = "从业资格证编号"), @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"), @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @GetMapping("/list") public ResponseJson> getDoctorList(@CurrentUser SysUser sysUser, Integer listType, Integer doctorType, String doctorName, String certificateNo, Integer status, Integer auditStatus, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == sysUser) { return ResponseJson.error("用户信息异常", null); } // 获取供应商用户id Integer userIdentity = sysUser.getUserIdentity(); Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null; if (null == authUserId) { return ResponseJson.error("供应商用户id不能为空", null); } if (null == doctorType) { return ResponseJson.error("参数异常,医师类型不能为空", null); } return doctorService.getDoctorList(listType, authUserId, doctorType, doctorName, certificateNo, status, auditStatus, pageNum, pageSize); } /** * 更新医师状态 */ @ApiOperation("更新医师状态") @ApiImplicitParam(name = "params", value = "doctorId:医师id;status:医师状态:0停用 1启用;", required = true) @PostMapping("/update/status") public ResponseJson updateDoctorStatus(@RequestBody Map params) { Integer doctorId = params.get("doctorId"); Integer status = params.get("status"); return doctorService.updateDoctorStatus(doctorId, status); } /** * 删除医师 */ @ApiOperation("删除医师") @ApiImplicitParam(name = "params", value = "doctorId:医师id", required = true) @PostMapping("/delete") public ResponseJson deleteDoctor(@RequestBody Map params) { Integer doctorId = params.get("doctorId"); return doctorService.deleteDoctor(doctorId); } /** * 医师回显数据 */ @ApiOperation("医师回显数据") @ApiImplicitParam(name = "doctorId", required = true, value = "医师id") @GetMapping("/form/data") public ResponseJson getDoctorFormData(Integer doctorId) { return doctorService.getDoctorFormData(doctorId); } /** * 添加/编辑医师 */ @ApiOperation("添加/编辑医师") @ApiImplicitParam(name = "params", value = "doctorId:医师id;authId:机构id;doctorType:医师类型:1操作医师,2培训医师;" + "doctorName:医师姓名;" +"certificateNo:从业资格证编号;clubName:所在机构;createBy:创建人id;" + "bannerList:轮播图列表;" +"doctorImage:医师照片;equipmentList([{equipmentName:'',brand:'',image:''}]);" + "tagList(['标签1','标签2'];" + "paramList([{name:'参数1',content:'内容1'}..]))", required = true) @PostMapping("/save") public ResponseJson saveDoctor(@CurrentUser SysUser sysUser, @RequestBody String params) { if (null == sysUser) { return ResponseJson.error("用户信息异常", null); } // 获取供应商用户id Integer userIdentity = sysUser.getUserIdentity(); Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null; if (null == authUserId) { return ResponseJson.error("供应商用户id不能为空", null); } JSONObject paramsMap = JSONObject.parseObject(params); Integer doctorId = paramsMap.getInteger("doctorId"); Integer authId = paramsMap.getInteger("authId"); Integer doctorType = paramsMap.getInteger("doctorType"); String doctorName = paramsMap.getString("doctorName"); String certificateNo = paramsMap.getString("certificateNo"); String clubName = paramsMap.getString("clubName"); String doctorImage = paramsMap.getString("doctorImage"); Integer createBy = paramsMap.getInteger("createBy"); List bannerList = (List) paramsMap.get("bannerList"); List tagList = (List) paramsMap.get("tagList"); List> equipmentList = (List>) paramsMap.get("equipmentList"); List> paramList = (List>) paramsMap.get("paramList"); /* 组装医师数据 */ CmBrandDoctorPo doctor = new CmBrandDoctorPo(); doctor.setId(doctorId); doctor.setAuthUserId(authUserId); doctor.setAuthId(authId); doctor.setDoctorType(doctorType); doctor.setName(doctorName); doctor.setImage(doctorImage); doctor.setCertificateNo(certificateNo); doctor.setClubName(clubName); doctor.setCreateBy(createBy); return doctorService.saveDoctor(doctor, bannerList, equipmentList, tagList, paramList); } /** * 审核医师 */ @ApiOperation("审核医师") @ApiImplicitParam(name = "params", value = "doctorId:医师id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true) @PostMapping("/audit") public ResponseJson auditDoctor(@RequestBody String params) { JSONObject paramsMap = JSONObject.parseObject(params); Integer doctorId = paramsMap.getInteger("doctorId"); Integer auditStatus = paramsMap.getInteger("auditStatus"); String invalidReason = paramsMap.getString("invalidReason"); Integer auditBy = paramsMap.getInteger("auditBy"); return doctorService.auditDoctor(doctorId, auditStatus, invalidReason, auditBy); } @ApiOperation("更改查看标记") @ApiImplicitParam(name = "doctorId", required = true, value = "doctorId") @PostMapping("/check/{id}") public ResponseJson checkDoctor(@PathVariable("id") Integer doctorId) { return doctorService.checkDoctor(doctorId); } }