| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | 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.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; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 医院基础信息表 |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-04-02 18:32:36 <br> |
| | |
| | | public class SysHospitalController extends BaseController{ |
| | | @Autowired |
| | | private ISysHospitalService sysHospitalService; |
| | | @Autowired |
| | | private ISysDepartmentService departmentService; |
| | | @Autowired |
| | | private ISysOrganizationService organizationService; |
| | | |
| | | /** |
| | | * 列表 |
| | |
| | | } |
| | | return sysHospitalService.findList(params); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | |
| | | } |
| | | return sysHospitalService.findHospitalList(params); |
| | | } |
| | | |
| | | @PostMapping("findAll") |
| | | @ApiOperation(value = "查询所有列表") |
| | | public ResultBody<SysHospital> findAll(@RequestBody Map<String, Object> params) { |
| | | if (params.get("hospitalName") != null) { |
| | | return sysHospitalService.findAll(params); |
| | | } else { |
| | | return ResultBody.ok().data(null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | |
| | | SysHospital model = sysHospitalService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/findByName") |
| | | public ResultBody findByName(@RequestParam String hospitalName) { |
| | | if (!hospitalName.isEmpty()) { |
| | | return ResultBody.ok().data(sysHospitalService.findByName(hospitalName).getData()).msg("查询成功"); |
| | | } else { |
| | | return ResultBody.ok().data(null).msg(""); |
| | | } |
| | | } |
| | | /** |
| | | * 根据SysHospital当做查询条件进行查询 |
| | | */ |
| | |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } 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=new SysOrganization(); |
| | | sysOrganization.setOrgName(sysHospital.getHospitalName()); |
| | | sysOrganization.setOrgAttr(1); |
| | | sysOrganization.setOrgLevel(1); |
| | | sysOrganization.setOrgParentId(DictionariesConstants.ORG_PARENT_ID); |
| | | } |
| | | else |
| | | { |
| | | sysOrganization.setOrgName(sysHospital.getHospitalName()); |
| | | } |
| | | boolean org=organizationService.saveOrUpdate(sysOrganization); |
| | | sysHospital.setOrgId(sysOrganization.getId()); |
| | | boolean v= sysHospitalService.saveOrUpdate(sysHospital); |
| | | if(v) { |
| | | return ResultBody.ok().data(sysHospital).msg("保存成功"); |
| | | } |
| | | else { |
| | | } else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | } |
| | |
| | | @ApiImplicitParam(name = "departmentId", value = "departmentId", required = true, dataType = "Integer") |
| | | }) |
| | | public ResultBody delete(@RequestParam Map<String, Object> params) { |
| | | if (params.size()==0) |
| | | { |
| | | if (params.size() == 0) { |
| | | return ResultBody.failed().msg("参数异常!"); |
| | | } |
| | | return sysHospitalService.delete(params); |
| | | } |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * |
| | |
| | | @ApiImplicitParam(name = "enabled", value = "是否启用", required = true, dataType = "Boolean") |
| | | }) |
| | | public ResultBody updateEnabled(@RequestParam Map<String, Object> params) { |
| | | if (params.size()==0) |
| | | { |
| | | if (params.size() == 0) { |
| | | return ResultBody.failed().msg("参数异常!"); |
| | | } |
| | | return sysHospitalService.updateEnabled(params); |