教育资源修改

dev
zhaokai 2026-01-21 08:42:44 +08:00
parent 97a1117b41
commit 0649c935aa
24 changed files with 135 additions and 17 deletions

View File

@ -64,6 +64,11 @@ public class TeacherController {
public SingleResponse<TeacherCO> getInfoById(@PathVariable(value = "id") Long id) {
return teacherService.getInfoById(id);
}
@ApiOperation("根据用户id查询教师详情")
@GetMapping("/getTeacherInfoByUserId/{userId}")
public SingleResponse<TeacherCO> getTeacherInfoByUserId(@PathVariable(value = "userId") Long userId) {
return SingleResponse.of(teacherService.getTeacherInfoByUserId(userId));
}
@ApiOperation("删除")
@GetMapping("/remove/{id}")

View File

@ -69,5 +69,11 @@ public class TeacherQueryExe {
return SingleResponse.of(co);
}
public TeacherCO getTeacherInfoByUserId(Long userId) {
TeacherDO teacherDO = teacherRepository.getTeacherInfoByUserId(userId);
TeacherCO co = new TeacherCO();
BeanUtils.copyProperties(teacherDO, co);
return co;
}
}

View File

@ -2,6 +2,7 @@ package com.zcloud.edu.command.resource;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.cola.exception.BizException;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.edu.command.convertor.resource.CurriculumChapterCoConvertor;
import com.zcloud.edu.domain.enums.CatalogueLevelEnum;
import com.zcloud.edu.domain.enums.CurriculumSellFlagEnum;
@ -123,6 +124,7 @@ public class CurriculumUpdateExe {
}
public void editState(CurriculumUpdateStateCmd cmd) {
List<String> errorList = new ArrayList<>();
for (Long id : cmd.getId()) {
CurriculumDO curriculumDO = curriculumRepository.getById(id);
//企业端禁用:所属单位为股份的不能禁用
@ -139,10 +141,17 @@ public class CurriculumUpdateExe {
// 校验是否 被使用
Long count= classCurriculumRepository.getCountByCurriculumId(curriculumDO.getCurriculumId());
if(count>0){
throw new BizException("该课程已绑定班级,不能编辑");
errorList.add(curriculumDO.getCurriculumName()+"课程已绑定班级");
}
}
//判断是否是本人创建的
if(!AuthContext.getUserId().equals(curriculumDO.getCreateId())){
errorList.add(curriculumDO.getCurriculumName()+"课程不是本人创建的");
}
}
if(CollUtil.isNotEmpty(errorList)){
throw new BizException(errorList+"不能修改状态");
}
curriculumRepository.updateState(cmd.getId(), cmd.getSellFlag());

View File

@ -2,6 +2,7 @@ package com.zcloud.edu.command.resource;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.cola.exception.BizException;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.edu.domain.gateway.resource.ExamPaperGateway;
import com.zcloud.edu.dto.resource.ExamPaperRemoveCmd;
import com.zcloud.edu.persistence.dataobject.ExamPaperDO;
@ -13,6 +14,7 @@ import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -73,6 +75,7 @@ public class ExamPaperRemoveExe {
//获取试卷idlist
List<String> examPaperIdList = examPaperDOList.stream().map(ExamPaperDO::getExamPaperId).collect(Collectors.toList());
//判断是否被使用
List<String> errorList = new ArrayList<>();
for (ExamPaperDO examPaperDO : examPaperDOList) {
Boolean b = corpInfoRepository.checkSupper(examPaperDO.getCorpinfoId());
if (corpInfoRepository.isSupper() && !b) {
@ -86,9 +89,14 @@ public class ExamPaperRemoveExe {
// 是否被使用
Long count= classExamPaperRepository.getCountByExamPaperId(examPaperDO.getExamPaperId());
if(count>0){
throw new BizException("该试卷已绑定班级,不能删除");
errorList.add(examPaperDO.getExamName()+"已绑定班级");
}
if(AuthContext.getUserId().equals(examPaperDO.getCreateId())){
errorList.add(examPaperDO.getExamName()+"试卷不是本人创建的");
}
}
if(CollUtil.isNotEmpty(errorList)){
throw new BizException(errorList+"不能删除");
}

View File

@ -13,7 +13,9 @@ import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -31,7 +33,47 @@ public class TeacherAddExe {
@Transactional(rollbackFor = Exception.class)
public boolean execute(TeacherAddCmd cmd) {
TeacherE teacherE = new TeacherE();
List<TeacherE> teacherEList = teacherE.convertFromUserList(BeanUtil.copyToList(cmd.getUserList(), UserAddE.class));
List<UserAddE> userAddEList = BeanUtil.copyToList(cmd.getUserList(), UserAddE.class);
// 按 Id 去重,保留第一次出现的元素
// 按 userId 去重,保留第一次出现的元素
userAddEList = userAddEList.stream()
.collect(Collectors.toMap(
UserAddE::getId, // 使用正确的字段
Function.identity(),
(existing, replacement) -> existing
))
.values()
.stream()
.collect(Collectors.toList());
// 判断用户是否已经是教师
List<Long> userIdList = userAddEList.stream()
.map(UserAddE::getId) // 使用正确的字段
.collect(Collectors.toList());
List<TeacherDO> existTeacherList = teacherRepository.getListByUserIdList(userIdList);
if (CollUtil.isNotEmpty(existTeacherList)) {
// 构建用户映射以快速查找用户名
Map<Long, UserAddE> userMap = userAddEList.stream()
.collect(Collectors.toMap(
UserAddE::getId,
Function.identity()
));
// 获取重复用户的用户名
List<String> duplicateUserNames = existTeacherList.stream()
.map(teacher -> Optional.ofNullable(userMap.get(teacher.getUserId()))
.map(UserAddE::getUserName)
.orElse(null))
.filter(Objects::nonNull)
.distinct() // 确保用户名不重复
.collect(Collectors.toList());
String duplicateUsers = String.join("、", duplicateUserNames);
throw new BizException("用户 [" + duplicateUsers + "] 已经是教师");
}
List<TeacherE> teacherEList = teacherE.convertFromUserList(userAddEList);
boolean res = false;
try {

View File

@ -1,6 +1,7 @@
package com.zcloud.edu.command.resource;
import com.zcloud.edu.domain.enums.CommonFlagEnum;
import com.zcloud.edu.domain.enums.VideoCoursewareState;
import com.zcloud.edu.domain.gateway.resource.VideoCoursewareGateway;
import com.zcloud.edu.domain.model.resource.VideoCoursewareE;
import com.zcloud.edu.dto.resource.VideoCoursewareAddCmd;
@ -31,7 +32,7 @@ public class VideoCoursewareAddExe {
boolean res = false;
try {
videoCoursewareE.setState(CommonFlagEnum.NO.getCode());
videoCoursewareE.setState(VideoCoursewareState.UNENABLED.getCode());
res = videoCoursewareGateway.add(videoCoursewareE);
} catch (Exception e) {
throw new RuntimeException(e);

View File

@ -58,13 +58,13 @@ public class VideoCoursewareUpdateExe {
}
@Transactional(rollbackFor = Exception.class)
public void execute(VideoCoursewareUpdateStateCmd cmd) {
public void editState(VideoCoursewareUpdateStateCmd cmd) {
VideoCoursewareDO videoCoursewareDOInfo = videoCoursewareRepository.getById(cmd.getId());
if(videoCoursewareDOInfo==null){
throw new BizException("课件信息不存在");
}
if(VideoCoursewareState.UNENABLED.getCode().equals(cmd.getState())){
if(VideoCoursewareState.ENABLED.getCode().equals(cmd.getState())){
//如果是启用判断习题数量小于5
Long count = questionRepository.getCountByVideoCourseware(videoCoursewareDOInfo.getVideoCoursewareId());
if(count<5){

View File

@ -68,5 +68,10 @@ public class TeacherServiceImpl implements TeacherServiceI {
public void removeBatch(Long[] ids) {
teacherRemoveExe.execute(ids);
}
@Override
public TeacherCO getTeacherInfoByUserId(Long userId) {
return teacherQueryExe.getTeacherInfoByUserId(userId);
}
}

View File

@ -56,7 +56,7 @@ public class VideoCoursewareServiceImpl implements VideoCoursewareServiceI {
@Override
public void editState(VideoCoursewareUpdateStateCmd cmd) {
videoCoursewareUpdateExe.execute(cmd);
videoCoursewareUpdateExe.editState(cmd);
}
@Override

View File

@ -29,5 +29,7 @@ public interface TeacherServiceI {
void remove(Long id);
void removeBatch(Long[] ids);
TeacherCO getTeacherInfoByUserId(Long userId);
}

View File

@ -1,5 +1,6 @@
package com.zcloud.edu.dto.clientobject.resource;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -51,6 +52,7 @@ public class ExamPaperCO {
//创建时间
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;

View File

@ -39,8 +39,8 @@ public class ExamPaperAddCmd {
private Integer sellFlag;
@ApiModelProperty(value = "考试时长(分钟)", name = "examTime", required = true)
@NotEmpty(message = "考试时长(分钟)不能为空")
private String examTime;
@NotNull(message = "考试时长(分钟)不能为空")
private Integer examTime;
@ApiModelProperty(value = "试卷类型 1-自建试卷 2-班级中自动生成试卷", name = "type", required = true)
@NotNull(message = "试卷类型 1-自建试卷 2-班级中自动生成试卷不能为空")

View File

@ -41,8 +41,8 @@ public class ExamPaperUpdateCmd extends Command {
@NotNull(message = "是否上架0否 1是不能为空")
private Integer sellFlag;
@ApiModelProperty(value = "考试时长(分钟)", name = "examTime", required = true)
@NotEmpty(message = "考试时长(分钟)不能为空")
private String examTime;
@NotNull(message = "考试时长(分钟)不能为空")
private Integer examTime;
@ApiModelProperty(value = "试卷类型 1-自建试卷 2-班级中自动生成试卷", name = "type", required = true)
@NotNull(message = "试卷类型 1-自建试卷 2-班级中自动生成试卷不能为空")
private Integer type;

View File

@ -26,5 +26,10 @@ public class QuestionListQry extends PageQuery {
*/
@ApiModelProperty(value = "企业id", name = "eqCorpinfoId", required = true)
private String eqCorpinfoId;
@ApiModelProperty(value = "试题类型1单选题、2多选题、3判断题")
private Integer eqQuestionType;
//题干
@ApiModelProperty(value = "题干")
private String likeQuestionDry;
}

View File

@ -30,5 +30,12 @@ public class QuestionPageQry extends PageQuery {
@ApiModelProperty(value = "试卷id", name = "eqExamPaperId", required = true)
private String eqExamPaperId;
@ApiModelProperty(value = "试题类型1单选题、2多选题、3判断题")
private Integer eqQuestionType;
//题干
@ApiModelProperty(value = "题干")
private String likeQuestionDry;
}

View File

@ -1,5 +1,6 @@
package com.zcloud.edu.dto.resource;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -23,6 +24,8 @@ public class TeacherListQry {
* - `ne`: SQL!=
*/
private Long corpinfoId;
@ApiModelProperty(value = "教师状态, 启用传1, 禁用传0", name = "state", required = true)
private Long state;
}

View File

@ -16,6 +16,8 @@ public class UserAddCmd extends ClientObject {
@ApiModelProperty(value = "GBS用户id")
private Long id;
@ApiModelProperty(value = "用户名称")
private String userName;
//企业id
@ApiModelProperty(value = "企业id")

View File

@ -7,7 +7,7 @@ import lombok.Getter;
*/
@Getter
public enum VideoCoursewareState {
UNENABLED(0,"未启用"),
UNENABLED(0,"用"),
ENABLED(1,"启用"),
;

View File

@ -17,7 +17,8 @@ public class UserAddE extends ClientObject {
//GBS用户id
@ApiModelProperty(value = "GBS用户id")
private Long id;
@ApiModelProperty(value = "用户名称")
private String userName;
//企业id
@ApiModelProperty(value = "企业id")
private Long corpinfoId;

View File

@ -33,7 +33,6 @@ public class VideoCoursewareGatewayImpl implements VideoCoursewareGateway {
if(videoCoursewareE.getCorpinfoId() == null){
videoCoursewareE.setCorpinfoId(AuthContext.getTenantId());
}
videoCoursewareE.setState(CommonFlagEnum.YES.getCode());
VideoCoursewareDO d = new VideoCoursewareDO();
BeanUtils.copyProperties(videoCoursewareE, d);

View File

@ -52,5 +52,19 @@ public class TeacherRepositoryImpl extends BaseRepositoryImpl<TeacherMapper, Tea
public SingleResponse<TeacherDO> getInfoById(Long id) {
return SingleResponse.of(teacherMapper.getInfoById(id));
}
@Override
public TeacherDO getTeacherInfoByUserId(Long userId) {
QueryWrapper<TeacherDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
return getOne(queryWrapper);
}
@Override
public List<TeacherDO> getListByUserIdList(List<Long> userIdList) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.in("user_id", userIdList);
return list(queryWrapper);
}
}

View File

@ -23,5 +23,9 @@ public interface TeacherRepository extends BaseRepository<TeacherDO> {
List<TeacherDO> listByIds(List<Long> ids);
SingleResponse<TeacherDO> getInfoById(Long id);
TeacherDO getTeacherInfoByUserId(Long userId);
List<TeacherDO> getListByUserIdList(List<Long> userIdList);
}

View File

@ -43,6 +43,9 @@
<if test=" params.corpinfoId != null">
AND a.corpinfo_id = #{params.corpinfoId}
</if>
<if test=" params.state != null">
AND a.state = #{params.state}
</if>
GROUP BY a.teacher_id, a.id, a.user_id, a.corpinfo_id
ORDER BY a.create_time DESC
</select>

View File

@ -46,7 +46,7 @@
AND a.corpinfo_id = #{params.corpinfoId}
</if>
<if test="params.coursewareName != null and params.coursewareName!=''">
AND a.courseware_name = #{params.coursewareName}
AND a.courseware_name like concat('%',#{params.coursewareName},'%')
</if>
<if test="params.trainingTypeId != null and params.trainingTypeId!='' ">
AND a.training_type_id = #{params.trainingTypeId}