尚医通-用户业务 该业务由登录后的:实名认证和就诊人两个子业务组成
位置: service模块\service_user子模块\api包
实名认证 01 用户手机号登录接口 前端请求:
后端处理: 1 2 3 4 public Result login (@RequestBody LoginVo loginVo) { Map<String,Object> info = userInfoService.loginUser(loginVo); return Result.ok(info); }
02 用户认证接口 前端请求: 1 @PostMapping("auth/userAuth")
后端处理: 1 2 3 4 5 public Result userAuth (@RequestBody UserAuthVo userAuthVo, HttpServletRequest request) { userInfoService.userAuth(AuthContextHolder.getUserId(request),userAuthVo); return Result.ok(); }
userAuth方法具体实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 public void userAuth (Long userId, UserAuthVo userAuthVo) { UserInfo userInfo = baseMapper.selectById(userId); userInfo.setName(userAuthVo.getName()); userInfo.setCertificatesType(userAuthVo.getCertificatesType()); userInfo.setCertificatesNo(userAuthVo.getCertificatesNo()); userInfo.setCertificatesUrl(userAuthVo.getCertificatesUrl()); userInfo.setAuthStatus(AuthStatusEnum.AUTH_RUN.getStatus()); baseMapper.updateById(userInfo); }
03 获取用户id信息接口 前端请求: 1 @GetMapping("auth/getUserInfo")
后端处理: 1 2 3 4 5 public Result getUserInfo (HttpServletRequest request) { Long userId = AuthContextHolder.getUserId(request); UserInfo userInfo = userInfoService.getById(userId); return Result.ok(userInfo); }
04 用户列表(条件查询带分页) 前端请求: 1 @GetMapping("{page}/{limit}")
后端处理: 1 2 3 4 5 6 7 8 public Result list (@PathVariable Long page, @PathVariable Long limit, UserInfoQueryVo userInfoQueryVo) { Page<UserInfo> pageParam = new Page <>(page,limit); IPage<UserInfo> pageModel = userInfoService.selectPage(pageParam,userInfoQueryVo); return Result.ok(pageModel); }
selectPage方法具体实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 public IPage<UserInfo> selectPage (Page<UserInfo> pageParam, UserInfoQueryVo userInfoQueryVo) { String name = userInfoQueryVo.getKeyword(); Integer status = userInfoQueryVo.getStatus(); Integer authStatus = userInfoQueryVo.getAuthStatus(); String createTimeBegin = userInfoQueryVo.getCreateTimeBegin(); String createTimeEnd = userInfoQueryVo.getCreateTimeEnd(); QueryWrapper<UserInfo> wrapper = new QueryWrapper <>(); if (!StringUtils.isEmpty(name)) { wrapper.like("name" ,name); } if (!StringUtils.isEmpty(status)) { wrapper.eq("status" ,status); } if (!StringUtils.isEmpty(authStatus)) { wrapper.eq("auth_status" ,authStatus); } if (!StringUtils.isEmpty(createTimeBegin)) { wrapper.ge("create_time" ,createTimeBegin); } if (!StringUtils.isEmpty(createTimeEnd)) { wrapper.le("create_time" ,createTimeEnd); } IPage<UserInfo> pages = baseMapper.selectPage(pageParam, wrapper); pages.getRecords().stream().forEach(item -> { this .packageUserInfo(item); }); return pages; }
05 用户锁定 前端请求: 1 @GetMapping("lock/{userId}/{status}")
后端处理: 1 2 3 4 public Result lock (@PathVariable Long userId,@PathVariable Integer status) { userInfoService.lock(userId,status); return Result.ok(); }
lock方法具体实现
1 2 3 4 5 6 7 public void lock (Long userId, Integer status) { if (status.intValue()==0 || status.intValue()==1 ) { UserInfo userInfo = baseMapper.selectById(userId); userInfo.setStatus(status); baseMapper.updateById(userInfo); } }
06 用户详情 前端请求: 1 @GetMapping("show/{userId}")
后端处理: 1 2 3 4 public Result show (@PathVariable Long userId) { Map<String,Object> map = userInfoService.show(userId); return Result.ok(map); }
show方法具体实现
1 2 3 4 5 6 7 8 9 10 public Map<String, Object> show (Long userId) { Map<String,Object> map = new HashMap <>(); UserInfo userInfo = this .packageUserInfo(baseMapper.selectById(userId)); map.put("userInfo" ,userInfo); List<Patient> patientList = patientService.findAllUserId(userId); map.put("patientList" ,patientList); return map; }
07 认证审批 前端请求: 1 @GetMapping("approval/{userId}/{authStatus}")
后端处理: 1 2 3 4 public Result approval (@PathVariable Long userId,@PathVariable Integer authStatus) { userInfoService.approval(userId,authStatus); return Result.ok(); }
approval方法具体实现
1 2 3 4 5 6 7 public void approval (Long userId, Integer authStatus) { if (authStatus.intValue()==2 || authStatus.intValue()==-1 ) { UserInfo userInfo = baseMapper.selectById(userId); userInfo.setAuthStatus(authStatus); baseMapper.updateById(userInfo); } }
就诊人管理 01 获取就诊人列表 前端请求: 1 @GetMapping("auth/findAll")
后端处理: 1 2 3 4 5 6 public Result findAll (HttpServletRequest request) { Long userId = AuthContextHolder.getUserId(request); List<Patient> list = patientService.findAllUserId(userId); return Result.ok(list); }
findAllUserId方法具体实现
1 2 3 4 5 6 7 8 9 10 11 12 public List<Patient> findAllUserId (Long userId) { QueryWrapper<Patient> wrapper = new QueryWrapper <>(); wrapper.eq("user_id" ,userId); List<Patient> patientList = baseMapper.selectList(wrapper); patientList.stream().forEach(item -> { this .packPatient(item); }); return patientList; }
02 添加就诊人 前端请求: 1 @PostMapping("auth/save")
后端处理: 1 2 3 4 5 6 7 public Result savePatient (@RequestBody Patient patient, HttpServletRequest request) { Long userId = AuthContextHolder.getUserId(request); patient.setUserId(userId); patientService.save(patient); return Result.ok(); }
03 根据id获取就诊人信息 前端请求: 1 @GetMapping("auth/get/{id}")
后端处理: 1 2 3 4 public Result getPatient (@PathVariable Long id) { Patient patient = patientService.getPatientId(id); return Result.ok(patient); }
getPatientId方法具体实现
1 2 3 public Patient getPatientId (Long id) { return this .packPatient(baseMapper.selectById(id)); }
packPatient方法具体实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 private Patient 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()); return patient; }
04 修改就诊人 前端请求: 1 @PostMapping("auth/update")
后端处理: 1 2 3 4 public Result updatePatient (@RequestBody Patient patient) { patientService.updateById(patient); return Result.ok(); }
05 删除就诊人 前端请求: 1 @DeleteMapping("auth/remove/{id}")
后端处理: 1 2 3 4 public Result removePatient (@PathVariable Long id) { patientService.removeById(id); return Result.ok(); }
06 根据就诊人id获取就诊人信息 前端请求: 1 @GetMapping("inner/get/{id}")
后端处理: 1 2 3 4 public Patient getPatientOrder (@PathVariable Long id) { Patient patient = patientService.getPatientId(id); return patient; }