| @ -0,0 +1,65 @@ | |||
| package com.hxhq.business.controller; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.hxhq.business.domain.StudySubject; | |||
| import com.hxhq.business.service.IStudySubjectService; | |||
| import com.hxhq.common.core.web.controller.BaseController; | |||
| import com.hxhq.common.core.web.domain.AjaxResult; | |||
| import com.hxhq.common.core.web.page.TableDataInfo; | |||
| /** | |||
| * 试验-学科Controller | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/business/studySubject") | |||
| public class StudySubjectController extends BaseController | |||
| { | |||
| @Autowired | |||
| private IStudySubjectService studySubjectService; | |||
| /** | |||
| * 查询试验-学科列表 | |||
| */ | |||
| @GetMapping("/list") | |||
| public TableDataInfo list(StudySubject studySubject) | |||
| { | |||
| startPage(); | |||
| List<StudySubject> list = studySubjectService.queryList(studySubject); | |||
| return getDataTable(list); | |||
| } | |||
| /** | |||
| * 获取试验-学科详细信息 | |||
| */ | |||
| @GetMapping(value = "/info") | |||
| public AjaxResult getInfo(Long id) | |||
| { | |||
| return AjaxResult.success(studySubjectService.getById(id)); | |||
| } | |||
| /** | |||
| * 新增试验-学科信息 | |||
| */ | |||
| @PostMapping("/save") | |||
| public AjaxResult save(@RequestBody StudySubject studySubject) | |||
| { | |||
| return toAjax(studySubjectService.saveOrUpdate(studySubject)); | |||
| } | |||
| /** | |||
| * 删除试验-学科信息 | |||
| */ | |||
| @PostMapping("/delete") | |||
| public AjaxResult delete(@RequestBody Long[] ids) | |||
| { | |||
| return toAjax(studySubjectService.removeByIds(Arrays.asList(ids))); | |||
| } | |||
| } | |||
| @ -0,0 +1,65 @@ | |||
| package com.hxhq.business.controller; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.hxhq.business.domain.StudySubjectUser; | |||
| import com.hxhq.business.service.IStudySubjectUserService; | |||
| import com.hxhq.common.core.web.controller.BaseController; | |||
| import com.hxhq.common.core.web.domain.AjaxResult; | |||
| import com.hxhq.common.core.web.page.TableDataInfo; | |||
| /** | |||
| * 试验-学科-成员Controller | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/business/studySubjectUser") | |||
| public class StudySubjectUserController extends BaseController | |||
| { | |||
| @Autowired | |||
| private IStudySubjectUserService studySubjectUserService; | |||
| /** | |||
| * 查询试验-学科-成员列表 | |||
| */ | |||
| @GetMapping("/list") | |||
| public TableDataInfo list(StudySubjectUser studySubjectUser) | |||
| { | |||
| startPage(); | |||
| List<StudySubjectUser> list = studySubjectUserService.queryList(studySubjectUser); | |||
| return getDataTable(list); | |||
| } | |||
| /** | |||
| * 获取试验-学科-成员详细信息 | |||
| */ | |||
| @GetMapping(value = "/info") | |||
| public AjaxResult getInfo(Long id) | |||
| { | |||
| return AjaxResult.success(studySubjectUserService.getById(id)); | |||
| } | |||
| /** | |||
| * 新增试验-学科-成员信息 | |||
| */ | |||
| @PostMapping("/save") | |||
| public AjaxResult save(@RequestBody StudySubjectUser studySubjectUser) | |||
| { | |||
| return toAjax(studySubjectUserService.saveOrUpdate(studySubjectUser)); | |||
| } | |||
| /** | |||
| * 删除试验-学科-成员信息 | |||
| */ | |||
| @PostMapping("/delete") | |||
| public AjaxResult delete(@RequestBody Long[] ids) | |||
| { | |||
| return toAjax(studySubjectUserService.removeByIds(Arrays.asList(ids))); | |||
| } | |||
| } | |||
| @ -0,0 +1,96 @@ | |||
| package com.hxhq.business.domain; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.hxhq.common.core.domain.MpBaseEntity; | |||
| /** | |||
| * 试验-学科对象 t_study_subject | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @TableName("t_study_subject") | |||
| public class StudySubject extends MpBaseEntity | |||
| { | |||
| private static final long serialVersionUID = 1L; | |||
| /** 所属试验 */ | |||
| private Long studyId; | |||
| /** 所属学科 */ | |||
| private Long deptId; | |||
| /** 学科名称 */ | |||
| private String deptName; | |||
| /** 负责人id */ | |||
| private Long leader; | |||
| /** 负责人姓名 */ | |||
| private String leaderName; | |||
| /** | |||
| * 是否选中 | |||
| */ | |||
| private Boolean select; | |||
| public void setStudyId(Long studyId) | |||
| { | |||
| this.studyId = studyId; | |||
| } | |||
| public Long getStudyId() | |||
| { | |||
| return studyId; | |||
| } | |||
| public void setDeptId(Long deptId) | |||
| { | |||
| this.deptId = deptId; | |||
| } | |||
| public Long getDeptId() | |||
| { | |||
| return deptId; | |||
| } | |||
| public void setDeptName(String deptName) | |||
| { | |||
| this.deptName = deptName; | |||
| } | |||
| public String getDeptName() | |||
| { | |||
| return deptName; | |||
| } | |||
| public void setLeader(Long leader) | |||
| { | |||
| this.leader = leader; | |||
| } | |||
| public Long getLeader() | |||
| { | |||
| return leader; | |||
| } | |||
| public void setLeaderName(String leaderName) | |||
| { | |||
| this.leaderName = leaderName; | |||
| } | |||
| public String getLeaderName() | |||
| { | |||
| return leaderName; | |||
| } | |||
| public Boolean getSelect() { | |||
| return select; | |||
| } | |||
| public void setSelect(Boolean select) { | |||
| this.select = select; | |||
| } | |||
| } | |||
| @ -0,0 +1,58 @@ | |||
| package com.hxhq.business.domain; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.hxhq.common.core.domain.MpBaseEntity; | |||
| /** | |||
| * 试验-学科-成员对象 t_study_subject_user | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @TableName("t_study_subject_user") | |||
| public class StudySubjectUser extends MpBaseEntity | |||
| { | |||
| private static final long serialVersionUID = 1L; | |||
| /** 所属试验-学科 */ | |||
| private Long studySubjectId; | |||
| /** 用户id */ | |||
| private Long userId; | |||
| /** 用户姓名 */ | |||
| private String userName; | |||
| public void setStudySubjectId(Long studySubjectId) | |||
| { | |||
| this.studySubjectId = studySubjectId; | |||
| } | |||
| public Long getStudySubjectId() | |||
| { | |||
| return studySubjectId; | |||
| } | |||
| public void setUserId(Long userId) | |||
| { | |||
| this.userId = userId; | |||
| } | |||
| public Long getUserId() | |||
| { | |||
| return userId; | |||
| } | |||
| public void setUserName(String userName) | |||
| { | |||
| this.userName = userName; | |||
| } | |||
| public String getUserName() | |||
| { | |||
| return userName; | |||
| } | |||
| } | |||
| @ -0,0 +1,21 @@ | |||
| package com.hxhq.business.mapper; | |||
| import com.hxhq.business.domain.StudySubject; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import java.util.List; | |||
| /** | |||
| * 试验-学科Mapper接口 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| public interface StudySubjectMapper extends BaseMapper<StudySubject> | |||
| { | |||
| /** | |||
| * 查询所有的学科信息 | |||
| * @return | |||
| */ | |||
| List<StudySubject> selectAllSubject(); | |||
| } | |||
| @ -0,0 +1,14 @@ | |||
| package com.hxhq.business.mapper; | |||
| import com.hxhq.business.domain.StudySubjectUser; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| /** | |||
| * 试验-学科-成员Mapper接口 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| public interface StudySubjectUserMapper extends BaseMapper<StudySubjectUser> | |||
| { | |||
| } | |||
| @ -0,0 +1,30 @@ | |||
| package com.hxhq.business.service; | |||
| import java.util.List; | |||
| import com.hxhq.business.domain.StudySubject; | |||
| import com.baomidou.mybatisplus.extension.service.IService; | |||
| /** | |||
| * 试验-学科Service接口 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| public interface IStudySubjectService extends IService<StudySubject> | |||
| { | |||
| /** | |||
| * 查询试验-学科列表 | |||
| * | |||
| * @param studySubject 试验-学科 | |||
| * @return 试验-学科集合 | |||
| */ | |||
| public List<StudySubject> queryList(StudySubject studySubject); | |||
| /** | |||
| * 获取试验下的学科设置信息(含未设置的学科) | |||
| * @param studyId | |||
| * @return | |||
| */ | |||
| List<StudySubject> getAllListByStudyId(Long studyId); | |||
| } | |||
| @ -0,0 +1,23 @@ | |||
| package com.hxhq.business.service; | |||
| import java.util.List; | |||
| import com.hxhq.business.domain.StudySubjectUser; | |||
| import com.baomidou.mybatisplus.extension.service.IService; | |||
| /** | |||
| * 试验-学科-成员Service接口 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| public interface IStudySubjectUserService extends IService<StudySubjectUser> | |||
| { | |||
| /** | |||
| * 查询试验-学科-成员列表 | |||
| * | |||
| * @param studySubjectUser 试验-学科-成员 | |||
| * @return 试验-学科-成员集合 | |||
| */ | |||
| public List<StudySubjectUser> queryList(StudySubjectUser studySubjectUser); | |||
| } | |||
| @ -0,0 +1,77 @@ | |||
| package com.hxhq.business.service.impl; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
| import org.springframework.stereotype.Service; | |||
| import com.hxhq.business.mapper.StudySubjectMapper; | |||
| import com.hxhq.business.domain.StudySubject; | |||
| import com.hxhq.business.service.IStudySubjectService; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| /** | |||
| * 试验-学科Service业务层处理 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @Service | |||
| public class StudySubjectServiceImpl extends ServiceImpl<StudySubjectMapper, StudySubject> implements IStudySubjectService | |||
| { | |||
| /** | |||
| * 查询试验-学科列表 | |||
| * | |||
| * @param studySubject 试验-学科 | |||
| * @return 试验-学科 | |||
| */ | |||
| @Override | |||
| public List<StudySubject> queryList(StudySubject studySubject) | |||
| { | |||
| QueryWrapper<StudySubject> queryWrapper = Wrappers.query(); | |||
| return this.list(queryWrapper); | |||
| } | |||
| /** | |||
| * 获取试验下的学科设置信息(含未设置的学科) | |||
| * @param studyId | |||
| * @return | |||
| */ | |||
| @Override | |||
| public List<StudySubject> getAllListByStudyId(Long studyId) { | |||
| List<StudySubject> allSubject = baseMapper.selectAllSubject(); | |||
| List<StudySubject> existsList = getListByStudyId(studyId); | |||
| List<StudySubject> allList = new ArrayList<>(); | |||
| for(StudySubject subject : allSubject){ | |||
| StudySubject info = new StudySubject(); | |||
| info.setDeptId(subject.getDeptId()); | |||
| info.setDeptName(subject.getDeptName()); | |||
| List<StudySubject> exists = existsList.stream().filter(o->o.getDeptId().equals(subject.getDeptId())).collect(Collectors.toList()); | |||
| if(exists.size()>0){ | |||
| info.setSelect(true); | |||
| info.setLeader(exists.get(0).getLeader()); | |||
| info.setLeaderName(exists.get(0).getLeaderName()); | |||
| }else{ | |||
| info.setSelect(false); | |||
| } | |||
| allList.add(info); | |||
| } | |||
| return allList; | |||
| } | |||
| /** | |||
| * 获取已经设置的学科信息 | |||
| * @param studyId | |||
| * @return | |||
| */ | |||
| private List<StudySubject> getListByStudyId(Long studyId){ | |||
| QueryWrapper<StudySubject> queryWrapper = new QueryWrapper<>(); | |||
| queryWrapper.eq("study_id",studyId); | |||
| return list(queryWrapper); | |||
| } | |||
| } | |||
| @ -0,0 +1,34 @@ | |||
| package com.hxhq.business.service.impl; | |||
| import java.util.List; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
| import org.springframework.stereotype.Service; | |||
| import com.hxhq.business.mapper.StudySubjectUserMapper; | |||
| import com.hxhq.business.domain.StudySubjectUser; | |||
| import com.hxhq.business.service.IStudySubjectUserService; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| /** | |||
| * 试验-学科-成员Service业务层处理 | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-29 | |||
| */ | |||
| @Service | |||
| public class StudySubjectUserServiceImpl extends ServiceImpl<StudySubjectUserMapper, StudySubjectUser> implements IStudySubjectUserService | |||
| { | |||
| /** | |||
| * 查询试验-学科-成员列表 | |||
| * | |||
| * @param studySubjectUser 试验-学科-成员 | |||
| * @return 试验-学科-成员 | |||
| */ | |||
| @Override | |||
| public List<StudySubjectUser> queryList(StudySubjectUser studySubjectUser) | |||
| { | |||
| QueryWrapper<StudySubjectUser> queryWrapper = Wrappers.query(); | |||
| return this.list(queryWrapper); | |||
| } | |||
| } | |||
| @ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="UTF-8" ?> | |||
| <!DOCTYPE mapper | |||
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.hxhq.business.mapper.StudySubjectMapper"> | |||
| <select id="selectAllSubject" resultType="com.hxhq.business.domain.StudySubject"> | |||
| SELECT dept_id,dept_name FROM `sys_dept` WHERE del_flag='0' AND `type`=3 | |||
| ORDER BY CONVERT(dept_name USING gbk) ASC | |||
| </select> | |||
| </mapper> | |||
| @ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8" ?> | |||
| <!DOCTYPE mapper | |||
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.hxhq.business.mapper.StudySubjectUserMapper"> | |||
| </mapper> | |||