master
zhuqing 2 years ago
parent 0627d2364a
commit 428f3c9785

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.pc;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.resp.THospitalPageResp;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -42,10 +43,10 @@ public class THospitalController extends BaseController
*/ */
@ApiOperation("查询医院信息列表") @ApiOperation("查询医院信息列表")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(THospital tHospital) public TableDataInfo list(@RequestBody THospital tHospital)
{ {
startPage(); startPage();
List<THospital> list = tHospitalService.selectTHospitalList(tHospital); List<THospitalPageResp> list = tHospitalService.queryByPage(tHospital);
return getDataTable(list); return getDataTable(list);
} }
@ -103,4 +104,14 @@ public class THospitalController extends BaseController
{ {
return toAjax(tHospitalService.deleteTHospitalByIds(ids)); return toAjax(tHospitalService.deleteTHospitalByIds(ids));
} }
/**
*
*/
@ApiOperation("获取医院管理员下拉接口")
@GetMapping(value = "/getHosptialAdminList")
public AjaxResult getHosptialAdminList()
{
return AjaxResult.success(tHospitalService.getHosptialAdminList());
}
} }

@ -104,18 +104,22 @@ public class SysLoginController
ajax.put("roles", roles); ajax.put("roles", roles);
ajax.put("permissions", permissions); ajax.put("permissions", permissions);
//添加医生和医院标识返回 //添加医生和医院标识返回
Long hospitalId = null;
Long doctorId = null;
THospital tHospital = new THospital(); THospital tHospital = new THospital();
tHospital.setAdminId(user.getUserId()); tHospital.setAdminId(user.getUserId());
List<THospital> tHospitals = itHospitalService.selectTHospitalList(tHospital); List<THospital> tHospitals = itHospitalService.selectTHospitalList(tHospital);
if (!ObjectUtils.isEmpty(tHospitals)){ 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 tDoctor = new TDoctor();
tDoctor.setUserId(user.getUserId()); tDoctor.setUserId(user.getUserId());
List<TDoctor> selectTDoctorList = itDoctorService.selectTDoctorList(tDoctor); List<TDoctor> selectTDoctorList = itDoctorService.selectTDoctorList(tDoctor);
if (!ObjectUtils.isEmpty(selectTDoctorList)){ if (!ObjectUtils.isEmpty(selectTDoctorList)){
ajax.put("doctorId", selectTDoctorList.get(0).getId()); doctorId = selectTDoctorList.get(0).getId();
} }
ajax.put("doctorId", doctorId);
return ajax; return ajax;
} }

@ -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;
}
}

@ -126,4 +126,10 @@ public interface SysUserMapper
* @return * @return
*/ */
public SysUser checkEmailUnique(String email); public SysUser checkEmailUnique(String email);
/**
* (rolekey)
* @return
*/
List<SysUser> selectCommonList(@Param("common") String common);
} }

@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.THospital; import com.ruoyi.system.domain.THospital;
import com.ruoyi.system.domain.resp.THospitalPageResp;
/** /**
* Mapper * Mapper
@ -58,4 +59,11 @@ public interface THospitalMapper
* @return * @return
*/ */
public int deleteTHospitalByIds(Long[] ids); public int deleteTHospitalByIds(Long[] ids);
/**
*
* @param tHospital
* @return
*/
List<THospitalPageResp> queryByPage(THospital tHospital);
} }

@ -1,7 +1,10 @@
package com.ruoyi.system.service; package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.THospital; import com.ruoyi.system.domain.THospital;
import com.ruoyi.system.domain.resp.THospitalPageResp;
/** /**
* Service * Service
@ -58,4 +61,17 @@ public interface ITHospitalService
* @return * @return
*/ */
public int deleteTHospitalById(Long id); public int deleteTHospitalById(Long id);
/**
*
* @return
*/
List<SysUser> getHosptialAdminList();
/**
*
* @param tHospital
* @return
*/
List<THospitalPageResp> queryByPage(THospital tHospital);
} }

@ -1,11 +1,17 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.List; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.THospitalMapper; import com.ruoyi.system.mapper.THospitalMapper;
import com.ruoyi.system.domain.THospital; import com.ruoyi.system.domain.THospital;
import com.ruoyi.system.service.ITHospitalService; import com.ruoyi.system.service.ITHospitalService;
import org.springframework.util.ObjectUtils;
/** /**
* Service * Service
@ -19,6 +25,9 @@ public class THospitalServiceImpl implements ITHospitalService
@Autowired @Autowired
private THospitalMapper tHospitalMapper; private THospitalMapper tHospitalMapper;
@Autowired
private SysUserMapper userMapper;
/** /**
* *
* *
@ -90,4 +99,21 @@ public class THospitalServiceImpl implements ITHospitalService
{ {
return tHospitalMapper.deleteTHospitalById(id); return tHospitalMapper.deleteTHospitalById(id);
} }
@Override
public List<SysUser> getHosptialAdminList() {
List<SysUser> userList = userMapper.selectCommonList("common");
List<THospital> tHospitals = tHospitalMapper.selectTHospitalList(new THospital());
//过滤出还没有所属医院的管理员
List<Long> 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<THospitalPageResp> queryByPage(THospital tHospital) {
return tHospitalMapper.queryByPage(tHospital);
}
} }

@ -223,5 +223,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<select id="selectCommonList" resultMap="SysUserResult">
SELECT a.*
from sys_user a INNER JOIN sys_user_role b on a.user_id = b.user_id
INNER JOIN sys_role c on b.role_id = c.role_id
WHERE c.role_key = #{common}
</select>
</mapper> </mapper>

@ -63,4 +63,19 @@
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="queryByPage" resultType="com.ruoyi.system.domain.resp.THospitalPageResp">
select
a.id,
a.name,
a.num,
a.admin_id as adminId,
b.user_name as adminName
from t_hospital a left join sys_user b on a.admin_id = b.user_id
<where>
1=1
<if test="name != null and name != ''"> and a.name like concat('%', #{name}, '%')</if>
</where>
order by a.num
</select>
</mapper> </mapper>
Loading…
Cancel
Save