|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.extra.validation.BeanValidationResult;
|
|
|
|
|
import cn.hutool.extra.validation.ValidationUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
|
import com.ibeetl.jlw.dao.StudentDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeSchoolClassDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninLogDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.Student;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeSchoolClass;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninLog;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninSetting;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.ManualClass;
|
|
|
|
|
import com.ibeetl.jlw.validator.TeacherOpenCourseStudentSigninLogSigninDTOValidator;
|
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static cn.jlw.util.IpUtils.getIpAddr;
|
|
|
|
|
import static cn.jlw.util.IpUtils.isRangeInner;
|
|
|
|
|
import static cn.jlw.util.ValidatorUtil.getFirstErrorMessage;
|
|
|
|
|
import static com.ibeetl.admin.core.util.servlet.ServletUtils.getRequest;
|
|
|
|
|
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
|
|
|
|
|
import static com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninSetting.ALL_SCHOOL_CLASS_IDS_SIGN;
|
|
|
|
|
import static com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum.*;
|
|
|
|
|
import static com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery.SignInTypeEnum.SIGN_IN;
|
|
|
|
|
import static com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery.SignInTypeEnum.UN_SIGN_IN;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生签到记录 Service
|
|
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional
|
|
|
|
|
@Validated
|
|
|
|
|
public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<TeacherOpenCourseStudentSigninLog>{
|
|
|
|
|
|
|
|
|
|
@Resource private TeacherOpenCourseStudentSigninLogDao teacherOpenCourseStudentSigninLogDao;
|
|
|
|
|
@Resource private TeacherOpenCourseStudentSigninSettingDao teacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
|
|
|
|
|
@Resource private StudentDao studentDao;
|
|
|
|
|
@Resource private TeacherOpenCourseMergeSchoolClassDao teacherOpenCourseMergeSchoolClassDao;
|
|
|
|
|
@Resource private TeacherOpenCourseStudentSigninLogSigninDTOValidator teacherOpenCourseStudentSigninLogSigninDTOValidator;
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByCondition(PageQuery query){
|
|
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByConditionQuery(PageQuery query){
|
|
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByConditionQuery(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list){
|
|
|
|
|
String ids = "";
|
|
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
|
|
for(int i=0;null != list && i<list.size();i++){
|
|
|
|
|
ids += list.get(i).toString()+(i==list.size()-1?"":",");
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteTeacherOpenCourseStudentSigninLog(String ids){
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new PlatformException("批量删除学生签到记录失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String addAll(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogList = JSON.parseArray(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogList.add(JSONObject.parseObject(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class));
|
|
|
|
|
} catch (Exception e1) {}
|
|
|
|
|
}
|
|
|
|
|
ToolUtils.deleteNullList(teacherOpenCourseStudentSigninLogList);
|
|
|
|
|
if(null != teacherOpenCourseStudentSigninLogList && teacherOpenCourseStudentSigninLogList.size()>0){
|
|
|
|
|
for(int i=0;i<teacherOpenCourseStudentSigninLogList.size();i++){
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogList.get(i);
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setUserId(teacherOpenCourseStudentSigninLogQuery.getUserId());
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setOrgId(teacherOpenCourseStudentSigninLogQuery.getOrgId());
|
|
|
|
|
}
|
|
|
|
|
insertBatch(teacherOpenCourseStudentSigninLogList);
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult add(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(new Date());
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.insert(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
|
|
jsonResult.setData(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());//自增的ID丢进去
|
|
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
|
|
jsonResult.setMsg(msg);
|
|
|
|
|
return jsonResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String edit(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.updateTemplateById(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String updateGivenByIds(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
if(StringUtils.isNotBlank(teacherOpenCourseStudentSigninLogQuery.get_given())){
|
|
|
|
|
boolean flag = teacherOpenCourseStudentSigninLogDao.updateGivenByIds(teacherOpenCourseStudentSigninLogQuery) > 0;
|
|
|
|
|
if(!flag){
|
|
|
|
|
msg = "更新指定参数失败";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
msg = "指定参数为空";
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValues (Object paras){
|
|
|
|
|
return sqlManager.select(SqlId.of("jlw.teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogValues"), TeacherOpenCourseStudentSigninLog.class, paras);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQuery (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
return teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQueryNotWithPermission (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
return teacherOpenCourseStudentSigninLogDao.getValuesByQueryNotWithPermission(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (Long teacherOpenCourseStudentSigninLogId){
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLogId);
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生端-教师端-签到
|
|
|
|
|
*
|
|
|
|
|
* @param signinDTO
|
|
|
|
|
*/
|
|
|
|
|
public void signin(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO) {
|
|
|
|
|
|
|
|
|
|
// 通过签到配置ID查询配置信息
|
|
|
|
|
List<TeacherOpenCourseStudentSigninSetting> signinSettingList =
|
|
|
|
|
teacherOpenCourseStudentSigninSettingDao.getByIds(signinDTO.getTeacherOpenCourseStudentSigninSettingId() + "");
|
|
|
|
|
Assert.notEmpty(signinSettingList, "签到配置ID无效!");
|
|
|
|
|
|
|
|
|
|
// 通过签到配置ID查询对应的参数信息。用于下面的验证。
|
|
|
|
|
TeacherOpenCourseStudentSigninSetting signinSetting = signinSettingList.get(0);
|
|
|
|
|
|
|
|
|
|
// 断言验证,学生某个课程只能签到一次。三种签到类型,都可以签到
|
|
|
|
|
TeacherOpenCourseStudentSigninLog entity = new TeacherOpenCourseStudentSigninLog();
|
|
|
|
|
entity.setStudentId(signinDTO.getStudentId());
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
Assert.isTrue(ObjectUtil.isEmpty(teacherOpenCourseStudentSigninLogDao.template(entity)), "该学生已经签到过了!");
|
|
|
|
|
|
|
|
|
|
Student student = studentDao.createLambdaQuery().andEq(Student::getStudentId, signinDTO.getStudentId()).single();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否加入到这个课程中
|
|
|
|
|
long teacherOpenCourseInCount = teacherOpenCourseMergeSchoolClassDao.createLambdaQuery()
|
|
|
|
|
.andEq(TeacherOpenCourseMergeSchoolClass::getSchoolClassId, signinDTO.getStudentId())
|
|
|
|
|
.andEq(TeacherOpenCourseMergeSchoolClass::getTeacherOpenCourseId, signinSetting.getTeacherOpenCourseId())
|
|
|
|
|
.count();
|
|
|
|
|
Assert.isTrue(teacherOpenCourseInCount > 0, "未加入到该课程中,开课ID或学生ID有误!");
|
|
|
|
|
|
|
|
|
|
switch (signinDTO.getTeacherOpenCourseStudentSigninLogType()) {
|
|
|
|
|
// IP签到
|
|
|
|
|
case ip_signin: {
|
|
|
|
|
ipSignInHandler(signinDTO, signinSetting);
|
|
|
|
|
}break;
|
|
|
|
|
// 手动签到。教师端操作
|
|
|
|
|
case manual_signin: {
|
|
|
|
|
manualSignInHandler(signinDTO, signinSetting);
|
|
|
|
|
}break;
|
|
|
|
|
// 验证码签到
|
|
|
|
|
case code_signin: {
|
|
|
|
|
codeSignInHandler(signinDTO, signinSetting);
|
|
|
|
|
}break;
|
|
|
|
|
default:
|
|
|
|
|
throw new RuntimeException("不支持的签到类型,请核对!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断班级ID是否在集合中
|
|
|
|
|
*
|
|
|
|
|
* @param schoolClassId
|
|
|
|
|
* @param signinSetting
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean schoolClassIdJudgment(@NotNull(message = "班级ID不能为空!") Long schoolClassId,
|
|
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
Assert.notEmpty(signinSetting.getSchoolClassIds(), "班级ID集合不能为空!");
|
|
|
|
|
|
|
|
|
|
if(signinSetting.getSchoolClassIds().equals(ALL_SCHOOL_CLASS_IDS_SIGN)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分割班级ID,逐一比对,只要有一个符合要求,就返回true
|
|
|
|
|
return Arrays.stream(signinSetting.getSchoolClassIds().split(","))
|
|
|
|
|
.anyMatch(item -> item.equals(schoolClassId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IP签到
|
|
|
|
|
*
|
|
|
|
|
* @param signinDTO
|
|
|
|
|
* @param signinSetting
|
|
|
|
|
*/
|
|
|
|
|
public void ipSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
|
|
|
|
// 获取登录用户,教师身份不支持IP签到,教师只能手动签到
|
|
|
|
|
CoreUser user = getUser();
|
|
|
|
|
Assert.isTrue(user.isStudent(), "IP签到方式,只允许学生进行操作!");
|
|
|
|
|
|
|
|
|
|
// 获取学生信息
|
|
|
|
|
Student student = studentDao.getByUserId(user.getId());
|
|
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
|
|
|
|
|
|
|
// 获取到真实的IP
|
|
|
|
|
String myIpAddress = getIpAddr(getRequest());
|
|
|
|
|
|
|
|
|
|
// 断言,如果IP不在指定的IP段内,则添加失败,异常信息丢给前台
|
|
|
|
|
Assert.isTrue(isRangeInner(myIpAddress, signinSetting.getTeacherOpenCourseStudentSigninSettingValue()),
|
|
|
|
|
"您的IP地址:{},不在指定的IP段内!", myIpAddress);
|
|
|
|
|
|
|
|
|
|
// 构建实体
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(ip_signin.name());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(myIpAddress);
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
|
|
signinLogQuery.setStudentId(signinDTO.getStudentId());
|
|
|
|
|
|
|
|
|
|
// 学生签到记录添加
|
|
|
|
|
add(signinLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手动签到
|
|
|
|
|
*
|
|
|
|
|
* @param signinDTO
|
|
|
|
|
* @param signinSetting
|
|
|
|
|
*/
|
|
|
|
|
public void manualSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
|
|
|
|
// 获取学生信息
|
|
|
|
|
List<Student> studentList = studentDao.getByIds(signinDTO.getStudentId() + "");
|
|
|
|
|
Assert.notEmpty(studentList, "学生ID未查询到学生信息!");
|
|
|
|
|
Student student = studentList.get(0);
|
|
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
|
|
|
|
|
|
|
// 构建实体
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(manual_signin.name());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(signinDTO.getIsAbsent() ? UN_SIGN_IN : SIGN_IN);
|
|
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
|
|
signinLogQuery.setStudentId(signinDTO.getStudentId());
|
|
|
|
|
|
|
|
|
|
// 是否缺勤
|
|
|
|
|
if(BooleanUtil.isTrue(signinDTO.getIsAbsent())) {
|
|
|
|
|
// 断言验证缺勤时候,必传的字段
|
|
|
|
|
BeanValidationResult isAbsentValidationResult = ValidationUtil.warpValidate(signinDTO, ManualClass.class);
|
|
|
|
|
Assert.isTrue(isAbsentValidationResult.isSuccess(), () -> getFirstErrorMessage(isAbsentValidationResult.getErrorMessages()));
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogRemark(signinDTO.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
|
|
}
|
|
|
|
|
// 学生签到记录添加
|
|
|
|
|
add(signinLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证码签到
|
|
|
|
|
*
|
|
|
|
|
* @param signinDTO
|
|
|
|
|
* @param signinSetting
|
|
|
|
|
*/
|
|
|
|
|
public void codeSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
|
|
|
|
// 获取登录用户,教师身份不支持IP签到,教师只能手动签到
|
|
|
|
|
CoreUser user = getUser();
|
|
|
|
|
Assert.isTrue(user.isStudent(), "验证码签到方式,只允许学生进行操作!");
|
|
|
|
|
|
|
|
|
|
// 获取学生信息
|
|
|
|
|
Student student = studentDao.getByUserId(user.getId());
|
|
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
|
|
|
|
|
|
|
// 断言,验证码验证
|
|
|
|
|
boolean verificationSuccess = signinSetting.getTeacherOpenCourseStudentSigninSettingValue().equals(signinDTO.getVerificationCode());
|
|
|
|
|
Assert.isTrue(verificationSuccess, "错误的验证码,签到失败!");
|
|
|
|
|
|
|
|
|
|
// 构建实体
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(code_signin.name());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
|
|
signinLogQuery.setStudentId(signinDTO.getStudentId());
|
|
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
|
|
|
|
|
|
|
// 学生签到记录添加
|
|
|
|
|
add(signinLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 签到日志查询
|
|
|
|
|
* TODO mlx 签到日志查询
|
|
|
|
|
* @param query
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Object signinLog(TeacherOpenCourseStudentSigninLogQuery query) {
|
|
|
|
|
|
|
|
|
|
throw new PlatformException("签到日志接口未实现!");
|
|
|
|
|
}
|
|
|
|
|
}
|