Compare commits
2 Commits
925817bb1e
...
989d1db754
Author | SHA1 | Date | |
---|---|---|---|
989d1db754 | |||
4d9812466a |
@ -12,6 +12,7 @@ import java.net.URLDecoder;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||||
@ -27,10 +28,7 @@ import org.jeecg.modules.aiol.entity.AiolHomework;
|
|||||||
import org.jeecg.modules.aiol.entity.AiolHomeworkSubmit;
|
import org.jeecg.modules.aiol.entity.AiolHomeworkSubmit;
|
||||||
import org.jeecg.modules.aiol.entity.AiolClass;
|
import org.jeecg.modules.aiol.entity.AiolClass;
|
||||||
import org.jeecg.modules.aiol.entity.AiolCourseSection;
|
import org.jeecg.modules.aiol.entity.AiolCourseSection;
|
||||||
import org.jeecg.modules.aiol.service.IAiolHomeworkService;
|
import org.jeecg.modules.aiol.service.*;
|
||||||
import org.jeecg.modules.aiol.service.IAiolEntityLinkService;
|
|
||||||
import org.jeecg.modules.aiol.service.IAiolClassService;
|
|
||||||
import org.jeecg.modules.aiol.service.IAiolCourseSectionService;
|
|
||||||
import org.jeecg.modules.aiol.constant.EntityLinkConst;
|
import org.jeecg.modules.aiol.constant.EntityLinkConst;
|
||||||
import org.jeecg.modules.aiol.mapper.AiolClassStudentMapper;
|
import org.jeecg.modules.aiol.mapper.AiolClassStudentMapper;
|
||||||
import org.jeecg.modules.aiol.mapper.AiolCourseSignupMapper;
|
import org.jeecg.modules.aiol.mapper.AiolCourseSignupMapper;
|
||||||
@ -43,7 +41,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.jeecg.modules.aiol.service.IAiolHomeworkSubmitService;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
@ -75,6 +74,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||||||
public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolHomeworkService> {
|
public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolHomeworkService> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAiolHomeworkService aiolHomeworkService;
|
private IAiolHomeworkService aiolHomeworkService;
|
||||||
|
@Autowired
|
||||||
|
private IAiolCourseSignupService aiolCourseSignupService;
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
@Autowired
|
||||||
|
private ISysBaseAPI sysBaseApi;
|
||||||
|
@Autowired
|
||||||
|
private IAiolEntityLinkService aiolEntityLinkService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
@ -100,6 +107,90 @@ public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolH
|
|||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "我的作业-作业查询")
|
||||||
|
@GetMapping(value = "/myHomeworkList")
|
||||||
|
public Result<?> queryMyHomeworkList(HttpServletRequest request,@RequestParam(name = "type" , defaultValue = "4" , required = false) Integer type) {
|
||||||
|
// 尝试获取token,判断用户id
|
||||||
|
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
|
||||||
|
List<AiolHomework> homeworkList = new ArrayList<>();
|
||||||
|
if (token != null && !token.trim().isEmpty()) {
|
||||||
|
try {
|
||||||
|
String username = JwtUtil.getUsername(token);
|
||||||
|
LoginUser sysUser = sysBaseApi.getUserByName(username);
|
||||||
|
if (sysUser != null) {
|
||||||
|
//获取课程id列表
|
||||||
|
List<AiolCourseSignup> courseSignupList = aiolCourseSignupMapper.selectList(
|
||||||
|
new QueryWrapper<AiolCourseSignup>()
|
||||||
|
.eq("user_id", sysUser.getId())
|
||||||
|
.select("course_id")
|
||||||
|
);
|
||||||
|
log.info("查询到课程数量: {}", courseSignupList.size());
|
||||||
|
// 获取课程章节id列表
|
||||||
|
List<AiolCourseSection> courseId = aiolCourseSectionService.list(
|
||||||
|
new QueryWrapper<AiolCourseSection>()
|
||||||
|
.in("course_id", courseSignupList.stream().map(AiolCourseSignup::getCourseId).collect(Collectors.toList()))
|
||||||
|
.select("id"));
|
||||||
|
List<String> courseIdList = courseId.stream()
|
||||||
|
.map(AiolCourseSection::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
log.info("查询到课程章节数量: {}", courseId.size());
|
||||||
|
//获取实体列表里的作业
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (!courseIdList.isEmpty()) {
|
||||||
|
list = aiolEntityLinkService.list(new QueryWrapper<AiolEntityLink>()
|
||||||
|
.eq("source_type", "course_section")
|
||||||
|
.in("source_id", courseIdList)
|
||||||
|
.eq("target_type", "homework")
|
||||||
|
.select("target_id")).stream().map(AiolEntityLink::getTargetId).collect(Collectors.toList());
|
||||||
|
}else return Result.ok();
|
||||||
|
log.info("查询到作业关联数量: {}", list.size());
|
||||||
|
|
||||||
|
// 查询作业
|
||||||
|
QueryWrapper<AiolHomework> queryWrapper = new QueryWrapper<>();
|
||||||
|
if(type != 4){
|
||||||
|
queryWrapper.eq("status", type);
|
||||||
|
}
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
queryWrapper.in("id", list);
|
||||||
|
}else return Result.ok();
|
||||||
|
// 查询作业列表并去重
|
||||||
|
homeworkList = aiolHomeworkService.list(queryWrapper)
|
||||||
|
.stream()
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 获取所有创建人ID
|
||||||
|
List<String> creatorIds = homeworkList.stream()
|
||||||
|
.map(AiolHomework::getCreateBy)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询创建人信息
|
||||||
|
List<SysUser> userList = sysUserService.list(
|
||||||
|
new QueryWrapper<SysUser>()
|
||||||
|
.in("username", creatorIds)
|
||||||
|
);
|
||||||
|
// 创建ID到用户名的映射
|
||||||
|
Map<String, String> userMap = userList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
SysUser::getUsername,
|
||||||
|
SysUser::getRealname
|
||||||
|
));
|
||||||
|
// 替换作业中的创建人ID为用户名
|
||||||
|
homeworkList.forEach(homework -> {
|
||||||
|
String creatorId = homework.getCreateBy();
|
||||||
|
if (creatorId != null && userMap.containsKey(creatorId)) {
|
||||||
|
homework.setCreateBy(userMap.get(creatorId));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.ok(homeworkList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
*
|
*
|
||||||
@ -218,8 +309,7 @@ public class AiolHomeworkController extends JeecgController<AiolHomework, IAiolH
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AiolCourseSignupMapper aiolCourseSignupMapper;
|
private AiolCourseSignupMapper aiolCourseSignupMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysBaseAPI sysBaseApi;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAiolClassService aiolClassService;
|
private IAiolClassService aiolClassService;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user