【查询教师列表、增加教师信息】

This commit is contained in:
weizhihong 2022-10-14 14:55:52 +08:00
parent d9828671c7
commit 6f17d72983
3 changed files with 98 additions and 38 deletions

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*组织成员管理接口
* 组织成员管理接口
*/
@RestController
@RequestMapping("/api/company")
@ -39,7 +39,7 @@ public class OrgController {
private IOrgExamService iOrgExamService;
/**
*创建顶级组织
* 创建顶级组织
*/
@PostMapping
public CompanyVO create(@RequestBody @Validated CompanyVO company, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
@ -47,7 +47,7 @@ public class OrgController {
}
/**
*获取公司列表
* 获取公司列表
*/
@GetMapping
public List<CompanyVO> queryAll() {
@ -55,7 +55,7 @@ public class OrgController {
}
/**
*分页获取公司列表
* 分页获取公司列表
*/
@GetMapping("paging")
public PageVO<CompanyVO> pagingQueryAll(OrgQueryVO queryVO) {
@ -63,7 +63,7 @@ public class OrgController {
}
/**
*查询公司信息
* 查询公司信息
*/
@GetMapping("{id}")
public CompanyVO get(@PathVariable Long id) {
@ -71,7 +71,7 @@ public class OrgController {
}
/**
*更新公司信息
* 更新公司信息
*/
@PutMapping("{id}")
public CompanyVO updateCompany(@PathVariable Long id, @RequestBody @Validated CompanyVO company, @RequestAttribute AccountVO user) {
@ -79,7 +79,7 @@ public class OrgController {
}
/**
*微信小程用户绑定为单位管理员
* 微信小程用户绑定为单位管理员
*/
@PutMapping(path = "/bind/company")
public CompanyVO userScanCodeBindCompany(Long userId, Long companyId) {
@ -87,7 +87,7 @@ public class OrgController {
}
/**
*添加部门信息
* 添加部门信息
*/
@PostMapping(path = "/dept")
public DepartmentVO createDepart(@RequestBody @Validated DepartmentVO departmentVO) {
@ -95,7 +95,7 @@ public class OrgController {
}
/**
*获取单位所有部门
* 获取单位所有部门
*/
@GetMapping(path = "{companyId}/dept")
public List<DepartmentVO> queryCompanyDepart(@PathVariable Long companyId) {
@ -103,7 +103,7 @@ public class OrgController {
}
/**
*获取部门及其子树
* 获取部门及其子树
*/
@GetMapping(path = "{companyId}/dept/{deptId}/tree")
public DepartmentVO queryDepartTree(@PathVariable Long deptId, @PathVariable Long companyId) {
@ -111,7 +111,7 @@ public class OrgController {
}
/**
*获取部门及其子部门
* 获取部门及其子部门
*/
@GetMapping(path = "{companyId}/dept/{deptId}")
public List<DepartmentVO> queryDepart(@PathVariable Long deptId, @PathVariable Long companyId) {
@ -119,7 +119,7 @@ public class OrgController {
}
/**
*删除部门信息
* 删除部门信息
*/
@DeleteMapping("/dept/{deptId}")
public void deleteDepart(@PathVariable Long deptId) {
@ -127,7 +127,7 @@ public class OrgController {
}
/**
*查询部门信息
* 查询部门信息
*/
@GetMapping("/dept/{deptId}")
public DepartmentVO getDepart(@PathVariable Long deptId) {
@ -135,7 +135,7 @@ public class OrgController {
}
/**
*更新部门信息
* 更新部门信息
*/
@PutMapping("/dept/{id}")
public void updateDepartInfo(@PathVariable Long id, @RequestBody @Validated DepartmentVO departmentVO) {
@ -143,7 +143,7 @@ public class OrgController {
}
/**
*添加单位成员关系信息
* 添加单位成员关系信息
*/
@PostMapping("refUserInfo")
public void addCompanyUserInfo(@RequestAttribute AccountVO user, @RequestBody UserDepartRelVO userDepartRelVO) {
@ -151,7 +151,7 @@ public class OrgController {
}
/**
*更新单位成员关系信息
* 更新单位成员关系信息
*/
@PutMapping("refUserInfo")
public void updateCompanyUserInfo(@RequestAttribute AccountVO user, @RequestBody UserDepartRelVO userDepartRelVO) {
@ -159,7 +159,7 @@ public class OrgController {
}
/**
*取消单位的部门成员关系
* 取消单位的部门成员关系
*/
@DeleteMapping("departUserInfo")
public void deleteCompanyUserInfo(@RequestAttribute AccountVO user, @RequestBody @Validated UserDepartRelVO userDepartRelVO) {
@ -167,7 +167,7 @@ public class OrgController {
}
/**
*分页获取班级学生信息
* 分页获取班级学生信息
*/
@GetMapping("/dept/{clsId}/departUserInfo")
public PageVO<OrgUserVO> getCompanyUserInfo(@RequestAttribute AccountVO user, @PathVariable Integer clsId, CompanyUserQueryVO companyUserQueryVO) {
@ -175,7 +175,7 @@ public class OrgController {
}
/**
*导入单位成员信息
* 导入单位成员信息
*/
@PostMapping("{clsId}/departUserInfo/import")
public void importCompanyUserInfo(@RequestAttribute AccountVO user, @PathVariable Long clsId, @RequestBody List<ImportOrgUserVO> importOrgUsers) {
@ -183,7 +183,7 @@ public class OrgController {
}
/**
*获取单位用户的部门信息
* 获取单位用户的部门信息
*/
@GetMapping("{companyId}/userDeparts")
public List<OrgUserVO> getUserCompanyDeparts(@RequestAttribute AccountVO user, @PathVariable Integer companyId) {
@ -191,7 +191,7 @@ public class OrgController {
}
/**
*查询自己给该组织班级排的课
* 查询自己给该组织班级排的课
*/
@GetMapping("/orgLesson/{orgId}/list")
public List<LessonVO> queryOrgLessonICreated(@PathVariable Long orgId, @RequestAttribute AccountVO user) {
@ -199,7 +199,7 @@ public class OrgController {
}
/**
*修改班级-课程关系
* 修改班级-课程关系
*/
@PutMapping("/orgLesson/{clsId}/update")
public void updateOrgLesson(@PathVariable Long clsId, @RequestBody List<Long> lessonIds, @RequestAttribute LoginUserInfoVO loginInfo) {
@ -207,7 +207,7 @@ public class OrgController {
}
/**
*给班级添加学生
* 给班级添加学生
*/
@PostMapping("/orgUser/{clsId}/addStudent")
public void addStudent(@PathVariable Long clsId, @RequestBody ImportOrgUserVO importVO, @RequestAttribute AccountVO user) {
@ -215,7 +215,7 @@ public class OrgController {
}
/**
*创建班级
* 创建班级
*/
@PostMapping("/org/cls/create")
public void createCls(@RequestBody NonTopOrgCreateVO createVO, @RequestAttribute LoginUserInfoVO loginInfo) {
@ -231,7 +231,7 @@ public class OrgController {
}
/**
*查询当前登录项目所属组织下的班级
* 查询当前登录项目所属组织下的班级
*/
@GetMapping("/list/cls")
public List<DepartmentVO> queryCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
@ -239,7 +239,7 @@ public class OrgController {
}
/**
*创建评价规则
* 创建评价规则
*/
@PostMapping("/orgScoringRule")
public void createScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute LoginUserInfoVO loginInfo) {
@ -247,7 +247,7 @@ public class OrgController {
}
/**
*更新评价规则
* 更新评价规则
*/
@PutMapping("/orgScoringRule")
public void UpdateScoringRule(@RequestBody OrgScoringRuleVO orgScoringRuleVO, @RequestAttribute AccountVO user) {
@ -255,7 +255,7 @@ public class OrgController {
}
/**
*查询自己创建的评价规则基础信息
* 查询自己创建的评价规则基础信息
*/
@GetMapping("/orgScoringRule/basicInfo/self/paged")
public PageVO<OrgScoringRuleVO> queryOrgScoringRuleBasicInfo(OrgScoringRuleQueryVO queryVO, @RequestAttribute AccountVO user) {
@ -263,7 +263,7 @@ public class OrgController {
}
/**
*查询自己创建的指定评价规则详细信息
* 查询自己创建的指定评价规则详细信息
*/
@GetMapping("/orgScoringRule/details/self/{orgId}/{schoolYear}/{term}")
public OrgScoringRuleVO queryOrgScoringRuleDetails(@PathVariable Long orgId, @PathVariable String schoolYear,
@ -272,7 +272,7 @@ public class OrgController {
}
/**
*查询指定评价规则详细信息
* 查询指定评价规则详细信息
*/
@GetMapping("/orgScoringRule/details/self/{ruleId}")
public OrgScoringRuleVO queryOrgScoringRuleDetails(@PathVariable Long ruleId) {
@ -280,7 +280,7 @@ public class OrgController {
}
/**
*获取评价规则的评分结果
* 获取评价规则的评分结果
*/
@GetMapping("/orgScoringRule/score/{orgId}/{schoolYear}/{term}")
public List<OrgScoringResultVO> score(@PathVariable Long orgId, @PathVariable String schoolYear,
@ -289,7 +289,7 @@ public class OrgController {
}
/**
*删除评分规则
* 删除评分规则
*/
@DeleteMapping("/orgScoringRule/details/self/{ruleId}")
public void deleteScoringRule(@PathVariable Long ruleId, @RequestAttribute AccountVO user) {
@ -297,7 +297,7 @@ public class OrgController {
}
/**
*查询规则能够应用到的组织
* 查询规则能够应用到的组织
*/
@GetMapping("/orgScoringRule/{ruleId}/canApplyTo")
public List<DepartmentVO> queryRuleCanApplyTo(@PathVariable Long ruleId, @RequestAttribute AccountVO user) {
@ -305,7 +305,7 @@ public class OrgController {
}
/**
*将评价规则应用到
* 将评价规则应用到
*/
@PostMapping("/orgScoringRule/{ruleId}/apply")
public void applyOrgScoringRule(@PathVariable Long ruleId, @RequestBody List<Long> orgIds) {
@ -313,7 +313,7 @@ public class OrgController {
}
/**
*给班级安排考试
* 给班级安排考试
*/
@PostMapping("/orgExam/{clsId}")
public void createOrgExam(@PathVariable Long clsId, @RequestBody List<Long> examIds, @RequestAttribute AccountVO user) {
@ -321,7 +321,7 @@ public class OrgController {
}
/**
*查询班级安排的考试id
* 查询班级安排的考试id
*/
@GetMapping("/orgExam/{clsId}/list")
public List<String> queryOrgExam(@PathVariable Long clsId, @RequestAttribute AccountVO user) {
@ -329,7 +329,7 @@ public class OrgController {
}
/**
*管理员查看组织树
* 管理员查看组织树
*/
@Role(RoleEnum.Admin)
@GetMapping("/orgTree/{orgId}")
@ -338,7 +338,7 @@ public class OrgController {
}
/**
*获取学生实训使用时长
* 获取学生实训使用时长
*/
@GetMapping("/usage/students")
public List<StudentsUsageStatisticsVO> statisticUsage(@Validated UsageQueryVO queryVO) {
@ -353,4 +353,19 @@ public class OrgController {
return iOrgService.getBindQrCode(orgId, loginInfo.getProject());
}
/**
* 查询班级教师接口
*/
@GetMapping("/dept/{clsId}/teachers")
public PageVO<OrgUserVO> clsTeacherList(@PathVariable Integer clsId, CompanyUserQueryVO companyUserQueryVO) {
return iOrgUserService.clsTeacherList(clsId, companyUserQueryVO);
}
/**
* 添加教师接口
*/
@PostMapping("/dept/{clsId}/addTeacher")
public void addTeacher(@PathVariable Long clsId, @RequestBody ImportOrgUserVO importVO, @RequestAttribute AccountVO user) {
iOrgUserService.addTeacher(clsId, importVO, user);
}
}

View File

@ -79,4 +79,8 @@ public interface IOrgUserService {
List<StudentsUsageStatisticsVO> statisticUsage(UsageQueryVO queryVO);
List<OrgUser> findEntitiesByOrgId(Long orgId);
PageVO<OrgUserVO> clsTeacherList(Integer clsId, CompanyUserQueryVO companyUserQueryVO);
void addTeacher(Long clsId, ImportOrgUserVO importVO, AccountVO user);
}

View File

@ -12,6 +12,8 @@ import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.services.IUserUsageStatsService;
import club.joylink.rtss.services.completition.IRaceQuestionsRuleService;
import club.joylink.rtss.services.user.IUserSimulationStatService;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.LessonVO;
import club.joylink.rtss.vo.client.PageVO;
@ -431,6 +433,29 @@ public class OrgUserService implements IOrgUserService {
return orgUsers;
}
@Override
public PageVO<OrgUserVO> clsTeacherList(Integer clsId, CompanyUserQueryVO companyUserQueryVO) {
//根据部门id查询部门成员
companyUserQueryVO.setDepartmentId(clsId);
companyUserQueryVO.setOrgRole(BusinessConsts.OrgRole.Teacher);
PageHelper.startPage(companyUserQueryVO.getPageNum(), companyUserQueryVO.getPageSize());
Page<OrgUserVO> page = (Page<OrgUserVO>) orgUserDAO.getCompanyDepartUsers(companyUserQueryVO);
return PageVO.convert(page);
}
@Override
public void addTeacher(Long clsId, ImportOrgUserVO importVO, AccountVO user) {
Org cls = iOrgService.getEntity(clsId);
Org topOrg = iOrgService.getEntity(cls.getRootId());
if (topOrg == null) {
throw new SimulationException(SimulationExceptionType.System_Fault, "无顶级组织");
}
confirmIsTheRoleInThisOrg(user.getId(), cls.getRootId(), BusinessConsts.OrgRole.Admin);
Set<Long> teacherIdSet = findEntitiesByOrgId(clsId, BusinessConsts.OrgRole.Teacher)
.stream().map(OrgUser::getUserId).collect(Collectors.toSet());
this.importOrgTeacher(cls.getId(), teacherIdSet, importVO);
}
/**
* 导入组织用户
@ -453,4 +478,20 @@ public class OrgUserService implements IOrgUserService {
}
}
/**
* 导入老师信息
*/
private void importOrgTeacher(Long orgId, Set<Long> orgUserIdSet, ImportOrgUserVO importOrgUser) {
AccountVO user = iSysUserService.queryUserByAccount(importOrgUser.getAccount());
Long userId = null;
if (user == null) {
SysAccount account = importOrgUser.convert2DB();
iSysUserService.createUser(account);
userId = account.getId();
}
if (!orgUserIdSet.contains(userId)) {
create(orgId, userId, BusinessConsts.OrgRole.Teacher);
}
}
}