| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | private final TCrmClinicService crmClinicService; |
| | | private final TokenService tokenService; |
| | | private final TSysOtherConfigService sysOtherConfigService; |
| | | private final ISysUserService sysUserService; |
| | | @Autowired |
| | | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, MsgUtils msgUtils, TSysMessageTemplateService sysMessageTemplateService, TCrmClinicService crmClinicService, TokenService tokenService, TSysOtherConfigService sysOtherConfigService) { |
| | | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, MsgUtils msgUtils, TSysMessageTemplateService sysMessageTemplateService, TCrmClinicService crmClinicService, TokenService tokenService, TSysOtherConfigService sysOtherConfigService, ISysUserService sysUserService) { |
| | | this.sysAppUserService = sysAppUserService; |
| | | this.sysInspectionService = sysInspectionService; |
| | | this.sysOrderService = sysOrderService; |
| | |
| | | this.crmClinicService = crmClinicService; |
| | | this.tokenService = tokenService; |
| | | this.sysOtherConfigService = sysOtherConfigService; |
| | | this.sysUserService = sysUserService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TSysAppUserVO>> pageList(@RequestBody TSysAppUserQuery query) { |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | query.setRoleType(roleType); |
| | | if(roleType == 5){ |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setClinicId(crmClinic.getId()); |
| | | } |
| | | return R.ok(sysAppUserService.pageList(query)); |
| | | } |
| | | |
| | |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, clinicUserId) |
| | | .last("LIMIT 1")); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | SysUser sysUser = sysUserService.selectUserById(clinicUserId); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | if(crmClinic == null){ |
| | | return R.fail("未找到该诊所信息"); |
| | | } |
| | |
| | | @Log(title = "用户管理信息-新增用户管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加用户管理") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@Validated @RequestBody TSysAppUser dto) { |
| | | public R<String> add(@Validated @RequestBody TSysAppUser dto) { |
| | | if (sysAppUserService.isExit(dto)) { |
| | | return R.fail("用户管理信息已存在"); |
| | | } |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId)); |
| | | // --- |
| | | if(Objects.isNull(crmClinic)){ |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | crmClinic = crmClinicService.getById(sysUser.getObjectId()); |
| | | } |
| | | String identifierNumber = UUID.randomUUID().toString().replace("-", ""); |
| | | dto.setIdentifierNumber(identifierNumber); |
| | | dto.setClinicId(crmClinic.getId()); |
| | | return R.ok(sysAppUserService.save(dto)); |
| | | sysAppUserService.save(dto); |
| | | return R.ok(dto.getId()); |
| | | } |
| | | |
| | | /** |
| | |
| | | sysAppUserVO.setSysChronicDiseases(sysChronicDiseases); |
| | | } |
| | | // 查询检测信息 |
| | | List<TSysInspection> sysInspections = sysInspectionService.list(Wrappers.lambdaQuery(TSysInspection.class).eq(TSysInspection::getAppUserId, id)); |
| | | List<TSysInspection> sysInspections = sysInspectionService.list(Wrappers.lambdaQuery(TSysInspection.class) |
| | | .eq(TSysInspection::getAppUserId, id) |
| | | .orderByDesc(TSysInspection::getCreateTime)); |
| | | if(!CollectionUtils.isEmpty(sysInspections)){ |
| | | List<String> clinicIds = sysInspections.stream().map(TSysInspection::getClinicId).collect(Collectors.toList()); |
| | | List<TCrmClinic> clinicList = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getId, clinicIds)); |
| | |
| | | sysAppUserVO.setSysInspections(sysInspections); |
| | | // 订单信息 |
| | | List<TSysOrderVO> sysOrders = sysOrderService.queryListByAppUserId(id); |
| | | for (TSysOrderVO sysOrder : sysOrders) { |
| | | List<TSysInspection> tSysInspections = sysInspections.stream().filter(c -> c.getId().equals(sysOrder.getInspectionId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(tSysInspections)){ |
| | | TSysInspection sysInspection = tSysInspections.get(0); |
| | | sysOrder.setSysInspection(sysInspection); |
| | | } |
| | | } |
| | | sysAppUserVO.setSysOrders(sysOrders); |
| | | if(sysAppUserVO.getBirthTime() != null){ |
| | | long age = ChronoUnit.YEARS.between(sysAppUserVO.getBirthTime(), LocalDateTime.now()); |
| | |
| | | @ApiOperation(value = "根据用户id查询检测信息") |
| | | @GetMapping(value = "/getInspectionByAppUserId") |
| | | public R<List<TSysInspection>> getInspectionByAppUserId(@RequestParam String appUserId) { |
| | | // 订单信息 |
| | | // 检测信息 |
| | | List<TSysInspection> sysInspections = sysInspectionService.list(Wrappers.lambdaQuery(TSysInspection.class).eq(TSysInspection::getAppUserId, appUserId)); |
| | | return R.ok(sysInspections); |
| | | } |