Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2022-10-14 14:58:21 +08:00
commit d099cbccf1
6 changed files with 185 additions and 43 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);
}
}
}

View File

@ -139,13 +139,77 @@ public class AcPermissionService {
List<SystemAbility> abilityList = findAbilitiesByPermissionId(permissionId);
return PermissionConvertor.convertWholePermissionRspVoFrom(permission, abilityList);
}
/**
* 分页获取权限
*/
@Transactional(readOnly = true)
public PageVO<PermissionBasicRspVo> findByPage(FindPermissionBasicByPageReqVo req) {
return null;
//查询条件
final boolean hasCondition = null != req.getName() || null != req.getDes();
final boolean multiConditions = null != req.getName() && null != req.getDes();
//多个条件与一个条件默认按与处理
final boolean makeAnd = hasCondition && (multiConditions && req.getLogicAnd() || !multiConditions);
//多个条件或
final boolean makeOr = multiConditions && !req.getLogicAnd();
//
PermissionExample permissionExample = new PermissionExample();
if (makeAnd) {
PermissionExample.Criteria pc = permissionExample.createCriteria();
if (null != req.getName()) {
if (req.getNameLike()) {
pc.andNameLike(String.format("%%%s%%", req.getName()));
} else {
pc.andNameEqualTo(req.getName());
}
}
if (null != req.getDes()) {
if (req.getDesLike()) {
pc.andDesLike(String.format("%%%s%%", req.getDes()));
} else {
pc.andDesEqualTo(req.getDes());
}
}
}
if (makeOr) {
PermissionExample.Criteria nc = permissionExample.or();
if (req.getNameLike()) {
nc.andNameLike(String.format("%%%s%%", req.getName()));
} else {
nc.andNameEqualTo(req.getName());
}
PermissionExample.Criteria dc = permissionExample.or();
if (req.getDesLike()) {
dc.andDesLike(String.format("%%%s%%", req.getDes()));
} else {
dc.andDesEqualTo(req.getDes());
}
}
//
PageVO<PermissionBasicRspVo> page = new PageVO<>();
long sum = this.permissionDAO.countByExample(permissionExample);
page.setTotal(sum);
page.setPageNum(req.getPageNum());
page.setPageSize(req.getPageSize());
page.setList(new ArrayList<>());
if (sum > 0) {
//
String orderBy = req.getOrderByType().with();
long startIndex = (req.getPageNum() - 1) * req.getPageSize();
//
if (req.getDesc()) {
permissionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize()));
} else {
permissionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize()));
}
List<Permission> pContent = this.permissionDAO.selectByExample(permissionExample);
if (!CollectionUtils.isEmpty(pContent)) {
page.setList(pContent.stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList()));
}
}
return page;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) {
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
psaExample.createCriteria().andPermissionIdEqualTo(permissionId);

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.vo.permission;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.paper.FindPuType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
@ -30,17 +29,25 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO {
* 按权限描述查询时默认true,true-模糊查询false-精确查询
*/
private Boolean desLike = true;
/**
* 当查询条件有多个时条件间关系true-false-默认值为true
*/
private Boolean logicAnd = true;
/**
* 是否降序true-降序false-升序默认值为true;
*/
private Boolean desc = true;
/**
* 排序类型
* 排序类型,默认按权限创建时间排序序列化为数值1-权限名称2-权限描述3-权限创建时间4-权限更新时间
*/
private OrderByType orderByType;
private OrderByType orderByType = OrderByType.OrderByCreateTime;
/////////////////////////////////////////////
public static enum OrderByType {
OrderByName(1, "name"),
OrderByDes(2, "des"),
OrderByCreateTime(3, "create_time"),
OrderByUpdateTime(4, "update_time"),
;
private Integer value;
private String orderBy;
@ -50,7 +57,7 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO {
this.orderBy = orderBy;
}
public String orderBy() {
public String with() {
return this.orderBy;
}

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.vo.permission.convertor;
import club.joylink.rtss.entity.permission.Permission;
import club.joylink.rtss.entity.permission.SystemAbility;
import club.joylink.rtss.vo.permission.PermissionBasicRspVo;
import club.joylink.rtss.vo.permission.WholePermissionRspVo;
import org.springframework.util.CollectionUtils;
@ -25,4 +26,14 @@ public class PermissionConvertor {
}
return rt;
}
public static PermissionBasicRspVo convertPermissionBasicRspVoFrom(Permission from){
PermissionBasicRspVo rt = new PermissionBasicRspVo();
rt.setId(from.getId());
rt.setDes(from.getDes());
rt.setName(from.getName());
rt.setCreateTime(from.getCreateTime());
rt.setUpdateTime(from.getUpdateTime());
rt.setCreatorId(from.getCreatorId());
return rt;
}
}