diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java new file mode 100644 index 0000000..4cb2516 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java @@ -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 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))); + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java new file mode 100644 index 0000000..4bfbc10 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java @@ -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 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))); + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java index 287fd87..7e5c017 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java @@ -24,6 +24,9 @@ public class Study extends MpBaseEntity /** 负责人id */ private Long leader; + /** 负责人姓名 */ + private String leaderName; + /** 试验状态1草稿,3试验中,5已锁定,7待归档,9归档,10待结档 */ private Integer status; @@ -61,6 +64,14 @@ public class Study extends MpBaseEntity return leader; } + public String getLeaderName() { + return leaderName; + } + + public void setLeaderName(String leaderName) { + this.leaderName = leaderName; + } + public void setStatus(Integer status) { this.status = status; diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubject.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubject.java new file mode 100644 index 0000000..d430b9d --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubject.java @@ -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; + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubjectUser.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubjectUser.java new file mode 100644 index 0000000..22b8daa --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudySubjectUser.java @@ -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; + } + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/study/StudyListDto.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/study/StudyListDto.java index 3406063..bf87640 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/study/StudyListDto.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/study/StudyListDto.java @@ -14,10 +14,6 @@ public class StudyListDto extends Study { * 试验完成表单数 */ private Integer formFinishCount; - /** - * 负责人姓名 - */ - private String leaderName; public Integer getFormCount() { return formCount; @@ -34,12 +30,4 @@ public class StudyListDto extends Study { public void setFormFinishCount(Integer formFinishCount) { this.formFinishCount = formFinishCount; } - - public String getLeaderName() { - return leaderName; - } - - public void setLeaderName(String leaderName) { - this.leaderName = leaderName; - } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java new file mode 100644 index 0000000..94e3c96 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java @@ -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 +{ + /** + * 查询所有的学科信息 + * @return + */ + List selectAllSubject(); +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectUserMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectUserMapper.java new file mode 100644 index 0000000..73c2f99 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectUserMapper.java @@ -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 +{ + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectService.java new file mode 100644 index 0000000..b6c5dfb --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectService.java @@ -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 +{ + /** + * 查询试验-学科列表 + * + * @param studySubject 试验-学科 + * @return 试验-学科集合 + */ + public List queryList(StudySubject studySubject); + + /** + * 获取试验下的学科设置信息(含未设置的学科) + * @param studyId + * @return + */ + List getAllListByStudyId(Long studyId); + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectUserService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectUserService.java new file mode 100644 index 0000000..891fdea --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudySubjectUserService.java @@ -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 +{ + /** + * 查询试验-学科-成员列表 + * + * @param studySubjectUser 试验-学科-成员 + * @return 试验-学科-成员集合 + */ + public List queryList(StudySubjectUser studySubjectUser); + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java new file mode 100644 index 0000000..34659fa --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java @@ -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 implements IStudySubjectService +{ + /** + * 查询试验-学科列表 + * + * @param studySubject 试验-学科 + * @return 试验-学科 + */ + @Override + public List queryList(StudySubject studySubject) + { + QueryWrapper queryWrapper = Wrappers.query(); + return this.list(queryWrapper); + } + + /** + * 获取试验下的学科设置信息(含未设置的学科) + * @param studyId + * @return + */ + @Override + public List getAllListByStudyId(Long studyId) { + List allSubject = baseMapper.selectAllSubject(); + List existsList = getListByStudyId(studyId); + + List allList = new ArrayList<>(); + for(StudySubject subject : allSubject){ + StudySubject info = new StudySubject(); + info.setDeptId(subject.getDeptId()); + info.setDeptName(subject.getDeptName()); + + + List 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 getListByStudyId(Long studyId){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("study_id",studyId); + return list(queryWrapper); + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java new file mode 100644 index 0000000..75d05df --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java @@ -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 implements IStudySubjectUserService +{ + /** + * 查询试验-学科-成员列表 + * + * @param studySubjectUser 试验-学科-成员 + * @return 试验-学科-成员 + */ + @Override + public List queryList(StudySubjectUser studySubjectUser) + { + QueryWrapper queryWrapper = Wrappers.query(); + return this.list(queryWrapper); + } + +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java index 0f1cd72..1efddb2 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java @@ -304,10 +304,6 @@ public class SysUserController extends BaseController { return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } - SysDept sysDept = deptService.selectDeptById(user.getDeptId()); - if(!sysDept.getType().equals(DeptTypeEnum.subject.getValue()) && !sysDept.getType().equals(DeptTypeEnum.team.getValue())){ - return error("新增用户'" + user.getUserName() + "'失败,部门必须选到学科或者小组"); - } user.setCreateBy(SecurityUtils.getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); return toAjax(userService.insertUser(user)); @@ -337,10 +333,6 @@ public class SysUserController extends BaseController { return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } - SysDept sysDept = deptService.selectDeptById(user.getDeptId()); - if(!sysDept.getType().equals(DeptTypeEnum.subject.getValue()) && !sysDept.getType().equals(DeptTypeEnum.team.getValue())){ - return error("修改用户'" + user.getUserName() + "'失败,部门必须选到学科或者小组"); - } user.setUpdateBy(SecurityUtils.getUsername()); return toAjax(userService.updateUser(user)); } diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml index 188d5c5..d78674e 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml @@ -4,8 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + SELECT dept_id,dept_name FROM `sys_dept` WHERE del_flag='0' AND `type`=3 + ORDER BY CONVERT(dept_name USING gbk) ASC + + \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectUserMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectUserMapper.xml new file mode 100644 index 0000000..ac736a4 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectUserMapper.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file