Merge remote-tracking branch 'origin/beetlsql3-dev' into beetlsql3-dev

beetlsql3-dev
姚丹ab 2 years ago
commit 09240bf5f1

@ -19,7 +19,10 @@ public @interface Query {
public static final int TYPE_DICT = 5;
//用户自己定义
public static final int TYPE_CONTROL = 6;
// 指定离线的Enum枚举。如果是JAVA枚举类 食用方法:@Query(name="xxx", type=TYPE_ENUM)
// public static final int TYPE_ENUM = 7;
/**
*
@ -38,7 +41,7 @@ public @interface Query {
* @return
*/
public int type() default TYPE_GENERAL;
/**
*
* @return

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -29189,7 +29189,6 @@ CREATE TABLE `teacher_open_course_score_dashboard` (
-- ----------------------------
-- Records of teacher_open_course_score_dashboard
-- ----------------------------
drop table if exists teacher_open_course_student_signin_log;
/*==============================================================*/
@ -29198,13 +29197,15 @@ drop table if exists teacher_open_course_student_signin_log;
create table teacher_open_course_student_signin_log
(
teacher_open_course_student_signin_log_id bigint not null comment 'ID',
teacher_open_course_student_signin_setting_id bigint comment '签到配置ID',
student_id bigint comment '学生ID',
teacher_open_course_id bigint comment '开课ID',
school_class_id char(10) comment '班级ID',
school_class_id bigint comment '班级ID',
teacher_open_course_student_signin_log_add_time datetime comment '签到日期',
teacher_open_course_student_signin_log_type varchar(50) comment '签到方式 (数据字典 student_signin_type)',
teacher_open_course_student_signin_log_remark varchar(1000) comment '备注(缺勤理由)',
teacher_open_course_student_signin_log_ip varchar(50) comment '签到的IP',
teacher_open_course_student_signin_log_tag int(3) comment '标记 10签到 20缺席',
org_id bigint comment '组织ID',
user_id bigint comment '用户ID',
primary key (teacher_open_course_student_signin_log_id)
@ -29217,6 +29218,7 @@ COLLATE = utf8_general_ci;
alter table teacher_open_course_student_signin_log comment '教师-我的课程-开课-学生签到记录';
drop table if exists teacher_open_course_student_signin_setting;
/*==============================================================*/

@ -1,5 +1,7 @@
package cn.jlw.util;
import cn.hutool.core.lang.Assert;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.jlw.entity.IpAddress;
import com.ibeetl.jlw.service.IpAddressService;
import org.apache.commons.lang3.StringUtils;
@ -19,12 +21,14 @@ import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import static cn.hutool.core.net.NetUtil.ipv4ToLong;
import static cn.jlw.util.ToolUtils.subString;
import static com.ibeetl.jlw.web.IpAddressController.ipAddressMap;
@ -32,6 +36,11 @@ public class IpUtils {
private static TaskCallable taskCallable = new TaskCallable();
// 分隔符1
public static final String SEPARATOR = ",";
// 分隔符2
public static final String IP_SPLIT_MARK = "-";
private IpUtils() {
}
@ -104,6 +113,44 @@ public class IpUtils {
return macAddress;
}
/**
* IDIP
*
* @param myIpAddress
* @param ipAddressList x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.xIP
* @return
*/
public static Boolean isRangeInner(String myIpAddress, String ipAddressList) throws PlatformException {
try {
// 单独的验证字符串是否符合要求
Arrays.stream(ipAddressList.split(SEPARATOR)).forEach(item -> {
Assert.isTrue(item.split(IP_SPLIT_MARK).length == 2,
() -> new PlatformException("ipAddressList 参数格式化错误支持格式x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x"));
});
}catch(Exception e) {
throw new PlatformException("ipAddressList 参数格式化错误支持格式x.x.x.x-x.x.x.x,x.x.x.x-x.x.x.x");
}
// 我的IPv4转long类型
long myIpLong = ipv4ToLong(myIpAddress);
// 是否在IP段区间
Boolean isRangeInner = false;
// 处理IP段判断IP是否在这个区间内 192.168.1.1-192.168.1.100,192.168.2.1-192.168.2.100
for (String range : ipAddressList.split(SEPARATOR)) {
// 两个IP段。开始IP-结束IP
String[] ips = range.split(IP_SPLIT_MARK);
long startIpLong = ipv4ToLong(ips[0]);
long endIpLong = ipv4ToLong(ips[1]);
// 在区间内,则打标记
if((myIpLong >= startIpLong) && (myIpLong <= endIpLong)) {
isRangeInner = true;
}
}
return isRangeInner;
}
public static class TaskCallable implements Callable<Boolean> {

@ -0,0 +1,33 @@
package cn.jlw.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.validation.BeanValidationResult;
import com.ibeetl.admin.core.util.PlatformException;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author mlx
* @date 2022/10/13
* @modified
*/
public class ValidatorUtil {
/**
* ErrorMessage
* @param errorMessages
* @return
*/
public static RuntimeException getFirstErrorMessage(List<BeanValidationResult.ErrorMessage> errorMessages) {
if (ObjectUtil.isNotEmpty(errorMessages)) {
// 只取第一个返回给前端,前端解决问题以后,再报给他下一次错误,这样不会动返回的数据格式
return new PlatformException(errorMessages.get(0).getMessage());
}
return new PlatformException("系统开小差,请稍候再试吧!");
}
}

@ -0,0 +1,65 @@
package cn.jlw.validator;
import cn.hutool.core.lang.Assert;
import cn.hutool.extra.validation.BeanValidationResult;
import cn.hutool.extra.validation.ValidationUtil;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninSetting;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO;
import org.springframework.stereotype.Component;
import java.util.Objects;
import static cn.jlw.util.ValidatorUtil.getFirstErrorMessage;
import static com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum.manual_signin;
/**
* DTO
*
* @author mlx
**/
@Component
public class TeacherOpenCourseStudentSigninLogSigninDTOValidator {
private TeacherOpenCourseStudentSigninLogSigninDTO dto = null;
/**
*
* @param signinDTO
*/
public TeacherOpenCourseStudentSigninLogSigninDTOValidator validator(TeacherOpenCourseStudentSigninLogSigninDTO signinDTO) {
dto = Objects.requireNonNull(signinDTO, "参数不能为空!");
// 手动签到,如果是缺勤状态,需要验证备注不能为空
TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum signinLogType =
signinDTO.getTeacherOpenCourseStudentSigninLogType();
if(signinLogType.equals(manual_signin) && signinDTO.getIsAbsent()) {
Assert.notBlank(signinDTO.getTeacherOpenCourseStudentSigninLogRemark(),
() -> new PlatformException("缺勤状态,备注不能为空!"));
}
// 根据type类型 验证Bean
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(signinDTO, signinLogType.getClazz());
Assert.isTrue(beanValidationResult.isSuccess(), () -> getFirstErrorMessage(beanValidationResult.getErrorMessages()));
return this;
}
/**
*
* @param signinSetting
* @return
*/
public TeacherOpenCourseStudentSigninLogSigninDTOValidator validatorBySetting(TeacherOpenCourseStudentSigninSetting signinSetting) {
Objects.requireNonNull(dto, "参数不能为空!");
Objects.requireNonNull(signinSetting, "签到配置不能为空!");
TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum signinLogTypeEnum =
dto.getTeacherOpenCourseStudentSigninLogType();
// 传入的签到类型
String inputSignInType = signinLogTypeEnum.name();
// 通过签到配置ID查询到的类型是否与传入的参数一致
Assert.isTrue(signinSetting.getTeacherOpenCourseStudentSigninSettingType().equalsIgnoreCase(inputSignInType), "签到类型不匹配!");
return this;
}
}

@ -3,6 +3,7 @@ package com.ibeetl.jlw.entity;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
import org.beetl.sql.annotation.entity.AssignID;
import javax.validation.constraints.NotNull;
@ -20,7 +21,11 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
@AssignID(value = "maskAutoID",param = "com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninLog")
private Long teacherOpenCourseStudentSigninLogId ;
// 签到配置ID
private Long teacherOpenCourseStudentSigninSettingId ;
//学生ID
@Dict(type="student.student_name.student_status=1")
@ -34,7 +39,7 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
//班级ID
@Dict(type="school_class.class_name.class_status=1")
private String schoolClassId ;
private Long schoolClassId ;
//签到日期
@ -52,6 +57,10 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
//签到的IP
private String teacherOpenCourseStudentSigninLogIp ;
// 签到标签 10 签到20 缺勤
private TeacherOpenCourseStudentSigninLogQuery.SignInTypeEnum teacherOpenCourseStudentSigninLogTag;
//组织ID
@ -106,13 +115,13 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
/**ID
*@return
*/
public String getSchoolClassId(){
public Long getSchoolClassId(){
return schoolClassId;
}
/**ID
*@param schoolClassId
*/
public void setSchoolClassId(String schoolClassId){
public void setSchoolClassId(Long schoolClassId){
this.schoolClassId = schoolClassId;
}
@ -194,5 +203,20 @@ public class TeacherOpenCourseStudentSigninLog extends BaseEntity{
this.userId = userId;
}
public TeacherOpenCourseStudentSigninLogQuery.SignInTypeEnum getTeacherOpenCourseStudentSigninLogTag() {
return teacherOpenCourseStudentSigninLogTag;
}
public void setTeacherOpenCourseStudentSigninLogTag(TeacherOpenCourseStudentSigninLogQuery.SignInTypeEnum teacherOpenCourseStudentSigninLogTag) {
this.teacherOpenCourseStudentSigninLogTag = teacherOpenCourseStudentSigninLogTag;
}
public Long getTeacherOpenCourseStudentSigninSettingId() {
return teacherOpenCourseStudentSigninSettingId;
}
public void setTeacherOpenCourseStudentSigninSettingId(Long teacherOpenCourseStudentSigninSettingId) {
this.teacherOpenCourseStudentSigninSettingId = teacherOpenCourseStudentSigninSettingId;
}
}

@ -3,6 +3,7 @@ package com.ibeetl.jlw.entity.dto;
import lombok.Data;
import lombok.Getter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ -18,7 +19,7 @@ import javax.validation.constraints.NotNull;
@Data
public class TeacherOpenCourseStudentSigninLogSigninDTO {
@NotEmpty(message = "签到配置ID不能为空")
@NotNull(message = "签到配置ID不能为空")
// 签到配置ID
private Long teacherOpenCourseStudentSigninSettingId;
@ -31,15 +32,14 @@ public class TeacherOpenCourseStudentSigninLogSigninDTO {
// 签到类型
private TeacherOpenCourseStudentSigninLogTypeEnum teacherOpenCourseStudentSigninLogType;
@NotEmpty(message = "签到验证码不能为空", groups = { CodeClass.class })
@NotBlank(message = "签到验证码不能为空", groups = { CodeClass.class })
private String verificationCode;
@NotEmpty(message = "签到备注不能为空", groups = { ManualClass.class })
// 备注 (用于缺席记录)
private String teacherOpenCourseStudentSigninLogRemark;
@NotNull(message = "是否缺席不能为空", groups = { ManualClass.class })
private Boolean isAbsent;
// 是否缺席
private Boolean isAbsent = false;
/**
*

@ -2,10 +2,11 @@ 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.hutool.json.JSONUtil;
import cn.jlw.util.ToolUtils;
import cn.jlw.validator.TeacherOpenCourseStudentSigninLogSigninDTOValidator;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.entity.CoreUser;
@ -22,7 +23,6 @@ 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.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum;
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
import org.apache.commons.lang3.StringUtils;
import org.beetl.sql.core.SqlId;
@ -38,12 +38,15 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static cn.hutool.core.net.Ipv4Util.IP_SPLIT_MARK;
import static cn.hutool.core.net.NetUtil.ipv4ToLong;
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
@ -60,6 +63,7 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
@Resource private TeacherOpenCourseMergeStudentService teacherOpenCourseMergeStudentService;
@Resource private StudentDao studentDao;
@Resource private TeacherOpenCourseStudentSigninLogSigninDTOValidator teacherOpenCourseStudentSigninLogSigninDTOValidator;
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByCondition(PageQuery query){
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByCondition(query);
@ -194,6 +198,12 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
// 通过签到配置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)), "该学生已经签到过了!");
TeacherOpenCourseMergeStudent paras = new TeacherOpenCourseMergeStudent();
paras.setStudentId(signinDTO.getStudentId());
// 是否匹配指定的课程
@ -203,15 +213,20 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
Assert.isTrue(isMatchCourse, "未加入到该课程中开课ID或学生ID有误");
switch (signinDTO.getTeacherOpenCourseStudentSigninLogType()) {
case ip_signin: { // IP签到
// IP签到
case ip_signin: {
ipSignInHandler(signinDTO, signinSetting);
}break;
case manual_signin: { // 手动签到。教师端操作
// 手动签到。教师端操作
case manual_signin: {
manualSignInHandler(signinDTO, signinSetting);
}break;
case code_signin: { // 验证码签到
// 验证码签到
case code_signin: {
codeSignInHandler(signinDTO, signinSetting);
}break;
default:
throw new RuntimeException("不支持的签到类型,请核对!");
}
}
@ -244,6 +259,8 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
public void ipSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
// 获取登录用户教师身份不支持IP签到教师只能手动签到
CoreUser user = getUser();
Assert.isTrue(user.isStudent(), "IP签到方式只允许学生进行操作");
@ -252,45 +269,23 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
Student student = studentDao.getByUserId(user.getId());
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
// 传入的签到类型
TeacherOpenCourseStudentSigninLogTypeEnum signinLogTypeEnum = signinDTO.getTeacherOpenCourseStudentSigninLogType();
String inputSignInType = signinLogTypeEnum.name();
// 根据type类型 验证Bean
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(signinDTO, signinLogTypeEnum.getClazz());
Assert.isTrue(beanValidationResult.isSuccess(), JSONUtil.toJsonStr(beanValidationResult.getErrorMessages()));
// 通过签到配置ID查询到的类型是否与传入的参数一致
Assert.isTrue(signinSetting.getTeacherOpenCourseStudentSigninSettingType().equalsIgnoreCase(inputSignInType), "签到类型不匹配!");
// 获取到真实的IP
String myIpAddress = getIpAddr(getRequest());
// 我的IPv4转long类型
long myIpLong = ipv4ToLong(myIpAddress);
// 是否在IP段区间
Boolean isRangeInner = false;
// 处理IP段判断IP是否在这个区间内 192.168.1.1-192.168.1.100,192.168.2.1-192.168.2.100
for (String range : signinSetting.getTeacherOpenCourseStudentSigninSettingValue().split(",")) {
// 两个IP段。开始IP-结束IP
String[] ips = range.split(IP_SPLIT_MARK);
long startIpLong = ipv4ToLong(ips[0]);
long endIpLong = ipv4ToLong(ips[1]);
// 在区间内,则打标记
if((startIpLong >= myIpLong) && (myIpLong <= endIpLong)) {
isRangeInner = true;
}
}
// 断言如果IP不在指定的IP段内则添加失败异常信息丢给前台
Assert.isTrue(isRangeInner, "您的IP地址{}不在指定的IP段内");
Assert.isTrue(isRangeInner(myIpAddress, signinSetting.getTeacherOpenCourseStudentSigninSettingValue()),
"您的IP地址{}不在指定的IP段内", myIpAddress);
// 构建实体
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(inputSignInType);
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(ip_signin.name());
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(myIpAddress);
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
signinLogQuery.setSchoolClassId(student.getClassId());
signinLogQuery.setStudentId(signinDTO.getStudentId());
// 学生签到记录添加
add(signinLogQuery);
}
@ -304,29 +299,29 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
public void manualSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
TeacherOpenCourseStudentSigninLogTypeEnum signinLogTypeEnum = signinDTO.getTeacherOpenCourseStudentSigninLogType();
// 传入的签到类型
String inputSignInType = signinLogTypeEnum.name();
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
// 根据type类型 验证Bean
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(signinDTO, signinLogTypeEnum.getClazz());
Assert.isTrue(beanValidationResult.isSuccess(), JSONUtil.toJsonStr(beanValidationResult.getErrorMessages()));
// 通过签到配置ID查询到的类型是否与传入的参数一致
Assert.isTrue(signinSetting.getTeacherOpenCourseStudentSigninSettingType().equalsIgnoreCase(inputSignInType), "签到类型不匹配!");
// 获取学生信息
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.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(inputSignInType);
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(), JSONUtil.toJsonStr(isAbsentValidationResult.getErrorMessages()));
Assert.isTrue(isAbsentValidationResult.isSuccess(), () -> getFirstErrorMessage(isAbsentValidationResult.getErrorMessages()));
signinLogQuery.setTeacherOpenCourseStudentSigninLogRemark(signinDTO.getTeacherOpenCourseStudentSigninLogRemark());
}
// 学生签到记录添加
@ -342,6 +337,8 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
public void codeSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
// 获取登录用户教师身份不支持IP签到教师只能手动签到
CoreUser user = getUser();
Assert.isTrue(user.isStudent(), "验证码签到方式,只允许学生进行操作!");
@ -350,27 +347,19 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
Student student = studentDao.getByUserId(user.getId());
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
TeacherOpenCourseStudentSigninLogTypeEnum signinLogTypeEnum = signinDTO.getTeacherOpenCourseStudentSigninLogType();
// 传入的签到类型
String inputSignInType = signinLogTypeEnum.name();
// 根据type类型 验证Bean
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(signinDTO, signinLogTypeEnum.getClazz());
Assert.isTrue(beanValidationResult.isSuccess(), JSONUtil.toJsonStr(beanValidationResult.getErrorMessages()));
// 通过签到配置ID查询到的类型是否与传入的参数一致
Assert.isTrue(signinSetting.getTeacherOpenCourseStudentSigninSettingType().equalsIgnoreCase(inputSignInType), "签到类型不匹配!");
// 断言,验证码验证
boolean verificationSuccess = signinSetting.getTeacherOpenCourseStudentSigninSettingValue().equals(signinDTO.getVerificationCode());
Assert.isTrue(verificationSuccess, "错误的验证码,签到失败!");
// 构建实体
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(inputSignInType);
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(code_signin.name());
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
signinLogQuery.setStudentId(signinDTO.getStudentId());
signinLogQuery.setSchoolClassId(student.getClassId());
// 学生签到记录添加
add(signinLogQuery);

@ -4,6 +4,8 @@ import cn.jlw.validate.ValidateConfig;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninLog;
import lombok.Getter;
import org.beetl.sql.annotation.entity.EnumValue;
import javax.validation.constraints.NotNull;
import java.util.Date;
@ -15,12 +17,15 @@ public class TeacherOpenCourseStudentSigninLogQuery extends PageParam {
@NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
@Query(name = "ID", display = false)
private Long teacherOpenCourseStudentSigninLogId;
// 签到配置ID
private Long teacherOpenCourseStudentSigninSettingId;
@Query(name = "学生ID", display = true,type=Query.TYPE_DICT,dict="student.student_name.student_status=1")
private Long studentId;
@Query(name = "开课ID", display = true,type=Query.TYPE_DICT,dict="teacher_open_course.teacher_open_course_title.teacher_open_course_status=1")
private Long teacherOpenCourseId;
@Query(name = "班级ID", display = true,type=Query.TYPE_DICT,dict="school_class.class_name.class_status=1")
private String schoolClassId;
private Long schoolClassId;
@Query(name = "签到日期", display = false)
private Date teacherOpenCourseStudentSigninLogAddTime;
@Query(name = "签到方式 (数据字典 student_signin_type)", display = true,type=Query.TYPE_DICT,dict="student_signin_type")
@ -29,6 +34,23 @@ public class TeacherOpenCourseStudentSigninLogQuery extends PageParam {
private String teacherOpenCourseStudentSigninLogRemark;
@Query(name = "签到的IP", display = false)
private String teacherOpenCourseStudentSigninLogIp;
@Query(name = "签到标签", display = false)
// 10 签到20 缺勤
private SignInTypeEnum teacherOpenCourseStudentSigninLogTag;
public static enum SignInTypeEnum {
SIGN_IN(10),
UN_SIGN_IN(20);
SignInTypeEnum(Integer code) {
this.code = code;
}
@Getter
@EnumValue
private Integer code;
}
@Query(name = "组织ID", display = false)
private Long orgId;
@Query(name = "用户ID", display = false)
@ -62,10 +84,10 @@ public class TeacherOpenCourseStudentSigninLogQuery extends PageParam {
public void setTeacherOpenCourseId(Long teacherOpenCourseId ){
this.teacherOpenCourseId = teacherOpenCourseId;
}
public String getSchoolClassId(){
public Long getSchoolClassId(){
return schoolClassId;
}
public void setSchoolClassId(String schoolClassId ){
public void setSchoolClassId(Long schoolClassId ){
this.schoolClassId = schoolClassId;
}
public Date getTeacherOpenCourseStudentSigninLogAddTime(){
@ -115,6 +137,8 @@ public class TeacherOpenCourseStudentSigninLogQuery extends PageParam {
pojo.setTeacherOpenCourseStudentSigninLogType(this.getTeacherOpenCourseStudentSigninLogType());
pojo.setTeacherOpenCourseStudentSigninLogRemark(this.getTeacherOpenCourseStudentSigninLogRemark());
pojo.setTeacherOpenCourseStudentSigninLogIp(this.getTeacherOpenCourseStudentSigninLogIp());
pojo.setTeacherOpenCourseStudentSigninLogTag(this.getTeacherOpenCourseStudentSigninLogTag());
pojo.setTeacherOpenCourseStudentSigninSettingId(this.getTeacherOpenCourseStudentSigninSettingId());
pojo.setOrgId(this.getOrgId());
pojo.setUserId(this.getUserId());
return pojo;
@ -162,4 +186,20 @@ public class TeacherOpenCourseStudentSigninLogQuery extends PageParam {
public void set_given(String _given) {
this._given = _given;
}
public SignInTypeEnum getTeacherOpenCourseStudentSigninLogTag() {
return teacherOpenCourseStudentSigninLogTag;
}
public void setTeacherOpenCourseStudentSigninLogTag(SignInTypeEnum teacherOpenCourseStudentSigninLogTag) {
this.teacherOpenCourseStudentSigninLogTag = teacherOpenCourseStudentSigninLogTag;
}
public Long getTeacherOpenCourseStudentSigninSettingId() {
return teacherOpenCourseStudentSigninSettingId;
}
public void setTeacherOpenCourseStudentSigninSettingId(Long teacherOpenCourseStudentSigninSettingId) {
this.teacherOpenCourseStudentSigninSettingId = teacherOpenCourseStudentSigninSettingId;
}
}

@ -13,6 +13,9 @@ queryByCondition
@if(!isEmpty(teacherOpenCourseStudentSigninLogId)){
and t.teacher_open_course_student_signin_log_id =#teacherOpenCourseStudentSigninLogId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninSettingId)){
and t.teacher_open_course_student_signin_setting_id =#teacherOpenCourseStudentSigninSettingId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogIdPlural)){
and find_in_set(t.teacher_open_course_student_signin_log_id,#teacherOpenCourseStudentSigninLogIdPlural#)
@}
@ -43,6 +46,9 @@ queryByCondition
@if(!isEmpty(teacherOpenCourseStudentSigninLogIp)){
and t.teacher_open_course_student_signin_log_ip =#teacherOpenCourseStudentSigninLogIp#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogTag)){
and t.teacher_open_course_student_signin_log_tag =#teacherOpenCourseStudentSigninLogTag#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@ -70,6 +76,9 @@ queryByConditionQuery
@if(!isEmpty(teacherOpenCourseStudentSigninLogId)){
and t.teacher_open_course_student_signin_log_id =#teacherOpenCourseStudentSigninLogId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninSettingId)){
and t.teacher_open_course_student_signin_setting_id =#teacherOpenCourseStudentSigninSettingId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogIdPlural)){
and find_in_set(t.teacher_open_course_student_signin_log_id,#teacherOpenCourseStudentSigninLogIdPlural#)
@}
@ -100,6 +109,9 @@ queryByConditionQuery
@if(!isEmpty(teacherOpenCourseStudentSigninLogIp)){
and t.teacher_open_course_student_signin_log_ip =#teacherOpenCourseStudentSigninLogIp#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogTag)){
and t.teacher_open_course_student_signin_log_tag =#teacherOpenCourseStudentSigninLogTag#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@ -187,6 +199,20 @@ updateGivenByIds
teacher_open_course_student_signin_log_ip = #teacherOpenCourseStudentSigninLogIp# ,
@}
@}
@if(contain("teacherOpenCourseStudentSigninLogTag",_given)){
@if(isEmpty(teacherOpenCourseStudentSigninLogTag)){
teacher_open_course_student_signin_log_tag = null ,
@}else{
teacher_open_course_student_signin_log_tag = #teacherOpenCourseStudentSigninLogTag# ,
@}
@}
@if(contain("teacherOpenCourseStudentSigninSettingId",_given)){
@if(isEmpty(teacherOpenCourseStudentSigninSettingId)){
teacher_open_course_student_signin_setting_id = null ,
@}else{
teacher_open_course_student_signin_setting_id = #teacherOpenCourseStudentSigninSettingId# ,
@}
@}
@if(contain("orgId",_given)){
@if(isEmpty(orgId)){
org_id = null ,
@ -217,6 +243,9 @@ getTeacherOpenCourseStudentSigninLogValues
@if(!isEmpty(teacherOpenCourseStudentSigninLogId)){
and t.teacher_open_course_student_signin_log_id =#teacherOpenCourseStudentSigninLogId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninSettingId)){
and t.teacher_open_course_student_signin_setting_id =#teacherOpenCourseStudentSigninSettingId#
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@ -238,6 +267,9 @@ getTeacherOpenCourseStudentSigninLogValues
@if(!isEmpty(teacherOpenCourseStudentSigninLogIp)){
and t.teacher_open_course_student_signin_log_ip =#teacherOpenCourseStudentSigninLogIp#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogTag)){
and t.teacher_open_course_student_signin_log_tag =#teacherOpenCourseStudentSigninLogTag#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@ -257,6 +289,9 @@ getValuesByQuery
@if(!isEmpty(teacherOpenCourseStudentSigninLogId)){
and t.teacher_open_course_student_signin_log_id =#teacherOpenCourseStudentSigninLogId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninSettingId)){
and t.teacher_open_course_student_signin_setting_id =#teacherOpenCourseStudentSigninSettingId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogIdPlural)){
and find_in_set(t.teacher_open_course_student_signin_log_id,#teacherOpenCourseStudentSigninLogIdPlural#)
@}
@ -287,6 +322,9 @@ getValuesByQuery
@if(!isEmpty(teacherOpenCourseStudentSigninLogIp)){
and t.teacher_open_course_student_signin_log_ip =#teacherOpenCourseStudentSigninLogIp#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogTag)){
and t.teacher_open_course_student_signin_log_tag =#teacherOpenCourseStudentSigninLogTag#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@ -312,6 +350,9 @@ getValuesByQueryNotWithPermission
@if(!isEmpty(teacherOpenCourseStudentSigninLogId)){
and t.teacher_open_course_student_signin_log_id =#teacherOpenCourseStudentSigninLogId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninSettingId)){
and t.teacher_open_course_student_signin_setting_id =#teacherOpenCourseStudentSigninSettingId#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogIdPlural)){
and find_in_set(t.teacher_open_course_student_signin_log_id,#teacherOpenCourseStudentSigninLogIdPlural#)
@}
@ -342,6 +383,9 @@ getValuesByQueryNotWithPermission
@if(!isEmpty(teacherOpenCourseStudentSigninLogIp)){
and t.teacher_open_course_student_signin_log_ip =#teacherOpenCourseStudentSigninLogIp#
@}
@if(!isEmpty(teacherOpenCourseStudentSigninLogTag)){
and t.teacher_open_course_student_signin_log_tag =#teacherOpenCourseStudentSigninLogTag#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}

@ -31,31 +31,38 @@ class TeacherOpenCourseStudentSigninLogControllerTest extends BaseTest {
@Test
void signin() throws Exception {
// 33 对应的用户ID和组织ID
putLoginInfoToEnv("135", "26");
// IP签到
TeacherOpenCourseStudentSigninLogSigninDTO ipSignInDTO = new TeacherOpenCourseStudentSigninLogSigninDTO();
ipSignInDTO.setTeacherOpenCourseStudentSigninLogType(ip_signin);
// 懒得写动态数据,直接取表数据 teacher_open_course_merge_student
ipSignInDTO.setStudentId(33L);
// teacher_open_course_student_signin_setting 查找teacher_open_course_id
ipSignInDTO.setTeacherOpenCourseStudentSigninSettingId(1580373576819843072L);
ipSignInDTO.setTeacherOpenCourseStudentSigninSettingId(1L);
signinAction(ipSignInDTO);
// 手动签到
// 验证码签到
TeacherOpenCourseStudentSigninLogSigninDTO manualSigninDTO = new TeacherOpenCourseStudentSigninLogSigninDTO();
manualSigninDTO.setTeacherOpenCourseStudentSigninLogType(manual_signin);
manualSigninDTO.setTeacherOpenCourseStudentSigninLogType(code_signin);
// 懒得写动态数据,直接取表数据 teacher_open_course_merge_student
ipSignInDTO.setStudentId(33L);
manualSigninDTO.setStudentId(33L);
manualSigninDTO.setVerificationCode("123qwe");
// teacher_open_course_student_signin_setting 查找teacher_open_course_id
ipSignInDTO.setTeacherOpenCourseStudentSigninSettingId(1580373576819843072L);
manualSigninDTO.setTeacherOpenCourseStudentSigninSettingId(2L);
signinAction(manualSigninDTO);
clearEnvLoginInfo();
// 验证码签到
// 手动签到
TeacherOpenCourseStudentSigninLogSigninDTO codeSignInDTO = new TeacherOpenCourseStudentSigninLogSigninDTO();
codeSignInDTO.setTeacherOpenCourseStudentSigninLogType(code_signin);
codeSignInDTO.setTeacherOpenCourseStudentSigninLogType(manual_signin);
// 懒得写动态数据,直接取表数据 teacher_open_course_merge_student
ipSignInDTO.setStudentId(33L);
codeSignInDTO.setStudentId(33L);
// teacher_open_course_student_signin_setting 查找teacher_open_course_id
ipSignInDTO.setTeacherOpenCourseStudentSigninSettingId(1580373576819843072L);
codeSignInDTO.setTeacherOpenCourseStudentSigninSettingId(3L);
codeSignInDTO.setIsAbsent(true);
codeSignInDTO.setTeacherOpenCourseStudentSigninLogRemark("这个同学说他不想来上课");
signinAction(codeSignInDTO);
}

Loading…
Cancel
Save