| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.constant.DictionariesConstants; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.usercenter.model.SysHospital; |
| | | import com.kidgrow.usercenter.service.ISysDepartmentService; |
| | | import com.kidgrow.usercenter.service.ISysHospitalService; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import com.kidgrow.usercenter.vo.HospitalListVo; |
| | |
| | | @Autowired |
| | | private ISysHospitalService sysHospitalService; |
| | | @Autowired |
| | | private ISysDepartmentService departmentService; |
| | | @Autowired |
| | | private ISysOrganizationService organizationService; |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult<HospitalListVo> list(@RequestParam Map<String, Object> params) { |
| | | public PageResult<HospitalListVo> list(@RequestParam Map<String, Object> params, @LoginUser SysUser user) { |
| | | if (params.size() == 0) { |
| | | params.put("page", 1); |
| | | params.put("limit", 10); |
| | | } |
| | | return sysHospitalService.findHospitalList(params); |
| | | return sysHospitalService.findHospitalList(params, user); |
| | | } |
| | | |
| | | @PostMapping("findAll") |
| | |
| | | @PostMapping("findAllByMap") |
| | | @ApiOperation(value = "查询所有列表") |
| | | public ResultBody<SysHospital> findAllByMap(@RequestBody Map<String, Object> params) { |
| | | return sysHospitalService.findAll(params); |
| | | return sysHospitalService.findAll(params); |
| | | } |
| | | |
| | | /** |
| | |
| | | SysHospital model = sysHospitalService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | |
| | | return ResultBody.ok().data(null).msg(""); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据SysHospital当做查询条件进行查询 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改医院logo |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping("/updateLogo") |
| | | public ResultBody updateLogo(@RequestBody Map<String, Object> params) { |
| | | return sysHospitalService.updateLogo(params); |
| | | } |
| | | |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysHospital sysHospital, BindingResult bindingResult) { |
| | | public ResultBody save(@Valid @RequestBody SysHospital sysHospital, BindingResult bindingResult, @LoginUser SysUser sysUser) { |
| | | List<String> errMsg = new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | //先检查该医院是否存在组织信息 |
| | | SysOrganization sysOrganization=new SysOrganization(); |
| | | if(sysHospital.getOrgId()!=null){ |
| | | sysOrganization.setId(sysHospital.getOrgId());} |
| | | else{ |
| | | SysOrganization sysOrganization = new SysOrganization(); |
| | | if (sysHospital.getOrgId() != null) { |
| | | sysOrganization.setId(sysHospital.getOrgId()); |
| | | } else { |
| | | sysOrganization.setOrgName(sysHospital.getHospitalName()); |
| | | sysOrganization.setOrgParentId(DictionariesConstants.ORG_PARENT_ID); |
| | | } |
| | | sysOrganization=organizationService.findByObject(sysOrganization); |
| | | if(sysOrganization==null) |
| | | { |
| | | sysOrganization = organizationService.findByObject(sysOrganization); |
| | | if (sysOrganization == null) { |
| | | //创建一个组织 |
| | | sysOrganization=new SysOrganization(); |
| | | sysOrganization = new SysOrganization(); |
| | | sysOrganization.setOrgName(sysHospital.getHospitalName()); |
| | | sysOrganization.setOrgAttr(1); |
| | | sysOrganization.setOrgLevel(1); |
| | | sysOrganization.setOrgParentId(DictionariesConstants.ORG_PARENT_ID); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sysOrganization.setOrgName(sysHospital.getHospitalName()); |
| | | } |
| | | boolean org=organizationService.saveOrUpdate(sysOrganization); |
| | | boolean org = organizationService.saveOrUpdateSer(sysOrganization); |
| | | sysHospital.setOrgId(sysOrganization.getId()); |
| | | List<SysOrganization> organizations = sysUser.getOrganizations(); |
| | | if (organizations.size() > 0) { |
| | | sysHospital.setCreateUserOrgCode(organizations.get(organizations.size() - 1).getOrgCode()); |
| | | } |
| | | //运营平台添加的医院默认就是正式的 |
| | | if (sysHospital.getHospitalState()==null) { |
| | | sysHospital.setHospitalState(1); |
| | | } |
| | | boolean v = sysHospitalService.saveOrUpdate(sysHospital); |
| | | if (v) { |
| | | return ResultBody.ok().data(sysHospital).msg("保存成功"); |
| | |
| | | } |
| | | return sysHospitalService.updateEnabled(params); |
| | | } |
| | | |
| | | /** |
| | | * 统计医院数量 |
| | | * @param datatype 医院类型 |
| | | * 0 试用医院 |
| | | * 1 正式医院 |
| | | * 11 筛查医院 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "统计医院数量") |
| | | @GetMapping("/chartHospital") |
| | | public ResultBody chartHospital(int datatype) { |
| | | return sysHospitalService.chartHospital(datatype); |
| | | } |
| | | } |