| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- package com.ruoyi.web.controller.info;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.List;
- import java.util.Set;
- import java.util.stream.Collectors;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.constraints.NotEmpty;
- import javax.validation.constraints.NotNull;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.ruoyi.common.annotation.Log;
- import com.ruoyi.common.annotation.RepeatSubmit;
- import com.ruoyi.common.core.controller.BaseController;
- import com.ruoyi.common.core.domain.PageQuery;
- import com.ruoyi.common.core.domain.R;
- import com.ruoyi.common.core.page.TableDataInfo;
- import com.ruoyi.common.core.validate.AddGroup;
- import com.ruoyi.common.core.validate.EditGroup;
- import com.ruoyi.common.core.validate.QueryGroup;
- import com.ruoyi.common.enums.BusinessType;
- import com.ruoyi.common.enums.FilePathSplicingType;
- import com.ruoyi.common.filepathsplicing.FilePathSplicing;
- import com.ruoyi.common.filepathsplicing.FilePathSplicingUtil;
- import com.ruoyi.common.utils.BeanCopyUtils;
- import com.ruoyi.common.utils.CollectionUtils;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import com.ruoyi.info.hospital.domain.vo.HospitalDepartmentVo;
- import com.ruoyi.info.hospital.domain.vo.HospitalVo;
- import com.ruoyi.info.hospital.service.IHospitalDepartmentService;
- import com.ruoyi.info.hospital.service.IHospitalService;
- import com.ruoyi.info.management.domain.TeacherDepartmentRel;
- import com.ruoyi.info.management.domain.bo.ManagementTeacherBo;
- import com.ruoyi.info.management.domain.bo.ManagementTeacherPageReqBo;
- import com.ruoyi.info.management.domain.vo.ManagementTeacherVo;
- import com.ruoyi.info.management.service.IManagementTeacherService;
- import com.ruoyi.info.management.service.ITeacherDepartmentRelService;
- import com.ruoyi.info.nursing.domain.bo.EnableStatusBo;
- import cn.dev33.satoken.annotation.SaCheckPermission;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.util.StrUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import lombok.RequiredArgsConstructor;
- import static com.ruoyi.common.utils.CollectionUtils.*;
- /**
- * 管理老师信息Controller
- *
- * @author baifc
- * @date 2025-09-30
- */
- @Validated
- @Api(value = "管理老师信息控制器", tags = {"管理老师信息管理"})
- @RequiredArgsConstructor
- @RestController
- @RequestMapping("/info/managementTeacher")
- public class ManagementTeacherController extends BaseController {
- private final IManagementTeacherService iManagementTeacherService;
- private final FilePathSplicingUtil filePathSplicingUtil;
- private final ITeacherDepartmentRelService iTeacherDepartmentRelService;
- private final IHospitalService iHospitalService;
- private final IHospitalDepartmentService iHospitalDepartmentService;
- /**
- * 分页查询管理老师信息列表
- */
- @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
- @ApiOperation("查询管理老师信息列表")
- @SaCheckPermission("info:managementTeacher:list")
- @GetMapping("/page")
- public TableDataInfo<ManagementTeacherVo> page(ManagementTeacherPageReqBo bo, PageQuery pageQuery) {
- return iManagementTeacherService.queryPageList(bo, pageQuery);
- }
- /**
- * 获取管理老师信息详细信息
- */
- @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
- @ApiOperation("获取管理老师信息详细信息")
- @SaCheckPermission("info:managementTeacher:query")
- @GetMapping("/info/{id}")
- public R<ManagementTeacherVo> getInfo(@ApiParam("主键")
- @NotNull(message = "主键不能为空")
- @PathVariable("id") Long id) {
- ManagementTeacherVo managementTeacherVo = iManagementTeacherService.queryById(id);
- // 获取管理老师关联的医院和科室信息
- List<TeacherDepartmentRel> teacherDepartmentRelList = iTeacherDepartmentRelService.queryByTeacherId(id);
- if (CollUtil.isEmpty(teacherDepartmentRelList)) {
- return R.ok(managementTeacherVo);
- }
- // 处理老师关联的医院和科室信息
- Set<Long> hospitalIds = convertSet(teacherDepartmentRelList, TeacherDepartmentRel::getHospitalId);
- List<HospitalVo> hospitalList = iHospitalService.queryListByIds(hospitalIds);
- List<ManagementTeacherVo.HospitalSimpleInfo> hospitalSimpleInfoList = BeanCopyUtils.copyList(hospitalList, ManagementTeacherVo.HospitalSimpleInfo.class);
- // 科室信息
- for (ManagementTeacherVo.HospitalSimpleInfo hospitalSimpleInfo : hospitalSimpleInfoList) {
- Set<Long> departmentIds = teacherDepartmentRelList.stream()
- .filter(rel -> rel.getHospitalId().equals(hospitalSimpleInfo.getId()))
- .map(TeacherDepartmentRel::getDepartmentId)
- .collect(Collectors.toSet());
- // 获取关联部门详情
- List<ManagementTeacherVo.DepartmentSimpleInfo> departmentSimpleInfoList =
- BeanCopyUtils.copyList(iHospitalDepartmentService.queryListByIds(departmentIds), ManagementTeacherVo.DepartmentSimpleInfo.class);
- hospitalSimpleInfo.setDepartmentList(departmentSimpleInfoList);
- }
- managementTeacherVo.setHospitalRelList(hospitalSimpleInfoList);
- return R.ok(managementTeacherVo);
- }
- /**
- * 新增管理老师信息
- */
- @FilePathSplicing(type = FilePathSplicingType.REQUEST)
- @ApiOperation("新增管理老师信息")
- @SaCheckPermission("info:managementTeacher:add")
- @Log(title = "管理老师信息", businessType = BusinessType.INSERT)
- @RepeatSubmit()
- @PostMapping("/add")
- public R<Void> add(@Validated(AddGroup.class) @RequestBody ManagementTeacherBo bo) {
- return toAjax(iManagementTeacherService.insertByBo(bo) ? 1 : 0);
- }
- /**
- * 修改管理老师信息
- */
- @FilePathSplicing(type = FilePathSplicingType.REQUEST)
- @ApiOperation("修改管理老师信息")
- @SaCheckPermission("info:managementTeacher:edit")
- @Log(title = "管理老师信息", businessType = BusinessType.UPDATE)
- @RepeatSubmit()
- @PostMapping("/edit")
- public R<Void> edit(@Validated(EditGroup.class) @RequestBody ManagementTeacherBo bo) {
- return toAjax(iManagementTeacherService.updateByBo(bo) ? 1 : 0);
- }
- /**
- * 启用/禁用 管理老师
- */
- @ApiOperation("启用/禁用 管理老师")
- @SaCheckPermission("info:managementTeacher:edit")
- @Log(title = "管理老师信息", businessType = BusinessType.UPDATE)
- @RepeatSubmit()
- @PostMapping("/update-status")
- public R<Void> updateStatus(@Validated @RequestBody EnableStatusBo bo) {
- iManagementTeacherService.updateStatus(bo);
- return R.ok();
- }
- /**
- * 删除管理老师信息
- */
- @ApiOperation("删除管理老师信息")
- @SaCheckPermission("info:managementTeacher:remove")
- @Log(title = "管理老师信息", businessType = BusinessType.DELETE)
- @PostMapping("/del/{ids}")
- public R<Void> remove(@ApiParam("主键串")
- @NotEmpty(message = "主键不能为空")
- @PathVariable Long[] ids) {
- return toAjax(iManagementTeacherService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
- }
- /**
- * 导出管理老师信息列表
- */
- @ApiOperation("导出管理老师信息列表")
- @SaCheckPermission("info:managementTeacher:export")
- @Log(title = "管理老师信息", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(ManagementTeacherPageReqBo bo, HttpServletResponse response) throws MalformedURLException {
- List<ManagementTeacherVo> list = iManagementTeacherService.queryList(bo);
- // 处理图片
- for (ManagementTeacherVo managementTeacherVo : list) {
- String url = managementTeacherVo.getPhotographUrl();
- if (StrUtil.isNotEmpty(url) && !url.startsWith("http")) {
- managementTeacherVo.setPhotograph(new URL(filePathSplicingUtil.getPrefix() + url));
- }
- }
- ExcelUtil.exportExcel(list, "管理老师信息", ManagementTeacherVo.class, response);
- }
- }
|