From 428f3c97856fbb3612ee8b971d55dc2ba362091f Mon Sep 17 00:00:00 2001 From: zhuqing Date: Wed, 10 Aug 2022 15:08:07 +0800 Subject: [PATCH] hosptial --- .../controller/pc/THospitalController.java | 15 +++- .../controller/system/SysLoginController.java | 8 +- .../system/domain/resp/THospitalPageResp.java | 76 +++++++++++++++++++ .../ruoyi/system/mapper/SysUserMapper.java | 6 ++ .../ruoyi/system/mapper/THospitalMapper.java | 8 ++ .../system/service/ITHospitalService.java | 16 ++++ .../service/impl/THospitalServiceImpl.java | 26 +++++++ .../resources/mapper/system/SysUserMapper.xml | 7 ++ .../mapper/system/THospitalMapper.xml | 15 ++++ 9 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/THospitalPageResp.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/THospitalController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/THospitalController.java index 4bffa50..de04639 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/THospitalController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/THospitalController.java @@ -3,6 +3,7 @@ package com.ruoyi.web.controller.pc; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.system.domain.resp.THospitalPageResp; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -42,10 +43,10 @@ public class THospitalController extends BaseController */ @ApiOperation("查询医院信息列表") @GetMapping("/list") - public TableDataInfo list(THospital tHospital) + public TableDataInfo list(@RequestBody THospital tHospital) { startPage(); - List list = tHospitalService.selectTHospitalList(tHospital); + List list = tHospitalService.queryByPage(tHospital); return getDataTable(list); } @@ -103,4 +104,14 @@ public class THospitalController extends BaseController { return toAjax(tHospitalService.deleteTHospitalByIds(ids)); } + + /** + * 获取管理员下拉接口 + */ + @ApiOperation("获取医院管理员下拉接口") + @GetMapping(value = "/getHosptialAdminList") + public AjaxResult getHosptialAdminList() + { + return AjaxResult.success(tHospitalService.getHosptialAdminList()); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index e6f4cc8..72e2c59 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -104,18 +104,22 @@ public class SysLoginController ajax.put("roles", roles); ajax.put("permissions", permissions); //添加医生和医院标识返回 + Long hospitalId = null; + Long doctorId = null; THospital tHospital = new THospital(); tHospital.setAdminId(user.getUserId()); List tHospitals = itHospitalService.selectTHospitalList(tHospital); if (!ObjectUtils.isEmpty(tHospitals)){ - ajax.put("hospitalId", tHospitals.get(0).getId()); + hospitalId = tHospitals.get(0).getId(); } + ajax.put("hospitalId", hospitalId); TDoctor tDoctor = new TDoctor(); tDoctor.setUserId(user.getUserId()); List selectTDoctorList = itDoctorService.selectTDoctorList(tDoctor); if (!ObjectUtils.isEmpty(selectTDoctorList)){ - ajax.put("doctorId", selectTDoctorList.get(0).getId()); + doctorId = selectTDoctorList.get(0).getId(); } + ajax.put("doctorId", doctorId); return ajax; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/THospitalPageResp.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/THospitalPageResp.java new file mode 100644 index 0000000..f9fbd90 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/THospitalPageResp.java @@ -0,0 +1,76 @@ +package com.ruoyi.system.domain.resp; + +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * @Author zhuqing + * @Date 2022/8/10 + */ +@ApiModel(value = "THospitalPageResp", description = "医院分页查询反参实体") +public class THospitalPageResp { + + /** ID */ + @ApiModelProperty("id") + private Long id; + + /** 名称 */ + @ApiModelProperty("名称") + @Excel(name = "名称") + private String name; + + /** 排序 */ + @ApiModelProperty("排序") + @Excel(name = "排序") + private Long num; + + /** 管理员ID */ + @ApiModelProperty("管理员ID") + @Excel(name = "管理员ID") + private Long adminId; + + @ApiModelProperty("管理员名称") + @Excel(name = "管理员名称") + private String adminName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getNum() { + return num; + } + + public void setNum(Long num) { + this.num = num; + } + + public Long getAdminId() { + return adminId; + } + + public void setAdminId(Long adminId) { + this.adminId = adminId; + } + + public String getAdminName() { + return adminName; + } + + public void setAdminName(String adminName) { + this.adminName = adminName; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index ed48e27..edf4773 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -126,4 +126,10 @@ public interface SysUserMapper * @return 结果 */ public SysUser checkEmailUnique(String email); + + /** + * 查询管理员集合(根据rolekey) + * @return + */ + List selectCommonList(@Param("common") String common); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/THospitalMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/THospitalMapper.java index 6ce3ca7..958c248 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/THospitalMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/THospitalMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.THospital; +import com.ruoyi.system.domain.resp.THospitalPageResp; /** * 医院信息Mapper接口 @@ -58,4 +59,11 @@ public interface THospitalMapper * @return 结果 */ public int deleteTHospitalByIds(Long[] ids); + + /** + * 分页查询 + * @param tHospital + * @return + */ + List queryByPage(THospital tHospital); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITHospitalService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITHospitalService.java index d813cf3..b2da841 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITHospitalService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITHospitalService.java @@ -1,7 +1,10 @@ package com.ruoyi.system.service; import java.util.List; + +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.domain.THospital; +import com.ruoyi.system.domain.resp.THospitalPageResp; /** * 医院信息Service接口 @@ -58,4 +61,17 @@ public interface ITHospitalService * @return 结果 */ public int deleteTHospitalById(Long id); + + /** + * 获取管理员下拉 + * @return + */ + List getHosptialAdminList(); + + /** + * 分页查询 + * @param tHospital + * @return + */ + List queryByPage(THospital tHospital); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THospitalServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THospitalServiceImpl.java index 28782f5..69a9bbd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THospitalServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THospitalServiceImpl.java @@ -1,11 +1,17 @@ package com.ruoyi.system.service.impl; import java.util.List; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.domain.resp.THospitalPageResp; +import com.ruoyi.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.THospitalMapper; import com.ruoyi.system.domain.THospital; import com.ruoyi.system.service.ITHospitalService; +import org.springframework.util.ObjectUtils; /** * 医院信息Service业务层处理 @@ -19,6 +25,9 @@ public class THospitalServiceImpl implements ITHospitalService @Autowired private THospitalMapper tHospitalMapper; + @Autowired + private SysUserMapper userMapper; + /** * 查询医院信息 * @@ -90,4 +99,21 @@ public class THospitalServiceImpl implements ITHospitalService { return tHospitalMapper.deleteTHospitalById(id); } + + @Override + public List getHosptialAdminList() { + List userList = userMapper.selectCommonList("common"); + List tHospitals = tHospitalMapper.selectTHospitalList(new THospital()); + //过滤出还没有所属医院的管理员 + List adminIds = tHospitals.stream().map(a -> a.getAdminId()).collect(Collectors.toList()); + if (!ObjectUtils.isEmpty(adminIds)){ + userList = userList.stream().filter(a -> !adminIds.contains(a.getUserId())).collect(Collectors.toList()); + } + return userList; + } + + @Override + public List queryByPage(THospital tHospital) { + return tHospitalMapper.queryByPage(tHospital); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 8484189..482e831 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -223,5 +223,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{userId} + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/THospitalMapper.xml b/ruoyi-system/src/main/resources/mapper/system/THospitalMapper.xml index 19e5709..0813ccd 100644 --- a/ruoyi-system/src/main/resources/mapper/system/THospitalMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/THospitalMapper.xml @@ -63,4 +63,19 @@ #{id} + + \ No newline at end of file