Merge remote-tracking branch 'origin/beetlsql3-dev' into beetlsql3-dev
commit
fe2b979315
@ -0,0 +1,28 @@
|
|||||||
|
package com.ibeetl.admin.core.validation;
|
||||||
|
|
||||||
|
import javax.validation.Constraint;
|
||||||
|
import javax.validation.Payload;
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({
|
||||||
|
ElementType.METHOD,
|
||||||
|
ElementType.FIELD,
|
||||||
|
ElementType.ANNOTATION_TYPE,
|
||||||
|
ElementType.CONSTRUCTOR,
|
||||||
|
ElementType.PARAMETER,
|
||||||
|
ElementType.TYPE_USE
|
||||||
|
})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(
|
||||||
|
validatedBy = EmailValidator.class
|
||||||
|
)
|
||||||
|
public @interface Email {
|
||||||
|
|
||||||
|
String message() default "电子邮箱格式不正确";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.ibeetl.admin.core.validation;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintValidator;
|
||||||
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注解 邮箱校验
|
||||||
|
* @author lx
|
||||||
|
*/
|
||||||
|
public class EmailValidator implements ConstraintValidator<Email, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(Email annotation) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||||
|
// 如果邮箱为空,默认不校验,即校验通过
|
||||||
|
if (StrUtil.isEmpty(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 校验邮箱
|
||||||
|
return Validator.isEmail(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,102 +0,0 @@
|
|||||||
package com.ibeetl.jlw.entity.dto;
|
|
||||||
|
|
||||||
import com.ibeetl.admin.core.util.excelGroupValidation.ExcelFile;
|
|
||||||
import com.ibeetl.admin.core.util.excelGroupValidation.ExcelValidation;
|
|
||||||
import com.ibeetl.jlw.entity.Teacher;
|
|
||||||
import com.ibeetl.jlw.enums.GenderEnum;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.experimental.FieldNameConstants;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import static cn.jlw.util.excel.ExcelUtil.longValuesOf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 功能描述: <br>
|
|
||||||
* 学生管理, 导入实体
|
|
||||||
*
|
|
||||||
* @Author: lx
|
|
||||||
* @Date: 2023/2/5 23:50
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@FieldNameConstants
|
|
||||||
@ToString
|
|
||||||
@ExcelFile(fileHeadTemplate = "universitiesCollegesId|universityFacultyId|universitySystemId|teacherName|teacherJobNumber|teacherMobile|teacherEmail",
|
|
||||||
fileMappingTemplate = "universitiesCollegesId=院校名称|universityFacultyId=院系名称|universitySystemId=专业名称|" +
|
|
||||||
"teacherName=教师姓名|teacherJobNumber=工号|teacherMobile=电话|teacherEmail=邮箱",
|
|
||||||
datasheetHidden = true, enableDataValidation = true)
|
|
||||||
public class TeacherBatchImportDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 院校名称
|
|
||||||
*/
|
|
||||||
@ExcelValidation(datasourceMethod = "com.ibeetl.jlw.service.UniversitiesCollegesService.getAllUniversitiesColleges")
|
|
||||||
private String universitiesCollegesId ;
|
|
||||||
/**
|
|
||||||
* 院系名称
|
|
||||||
*/
|
|
||||||
@ExcelValidation(datasourceMethod = "com.ibeetl.jlw.service.UniversityFacultyService.getAllUniversityFacultyWithColleges", beforeFieldName = "universitiesCollegesId")
|
|
||||||
private String universityFacultyId ;
|
|
||||||
/**
|
|
||||||
* 专业名称
|
|
||||||
*/
|
|
||||||
@ExcelValidation(datasourceMethod = "com.ibeetl.jlw.service.UniversitySystemService.getAllUniversitiesCollegesWithFaculty", beforeFieldName = "universityFacultyId")
|
|
||||||
private String universitySystemId ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 教师姓名
|
|
||||||
*/
|
|
||||||
private String teacherName ;
|
|
||||||
/**
|
|
||||||
* 工号
|
|
||||||
*/
|
|
||||||
private String teacherJobNumber ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电话
|
|
||||||
*/
|
|
||||||
private String teacherMobile ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱
|
|
||||||
*/
|
|
||||||
private String teacherEmail ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型转换
|
|
||||||
*
|
|
||||||
* @param importPojo 导入的数据
|
|
||||||
* @param function 二次加工
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Teacher pojo(TeacherBatchImportDTO importPojo, Function<Teacher, Teacher> function) {
|
|
||||||
Teacher build = Teacher.builder()
|
|
||||||
.universitiesCollegesId(longValuesOf(importPojo.getUniversitiesCollegesId()))
|
|
||||||
.universityFacultyId(longValuesOf(importPojo.getUniversityFacultyId()))
|
|
||||||
.universitySystemId(longValuesOf(importPojo.getUniversitySystemId()))
|
|
||||||
.teacherJobNumber(importPojo.getTeacherJobNumber())
|
|
||||||
.teacherName(importPojo.getTeacherName())
|
|
||||||
.teacherEmail(importPojo.getTeacherEmail())
|
|
||||||
.teacherMobile(importPojo.getTeacherMobile())
|
|
||||||
.teacherGender(GenderEnum.UN_KNOW)
|
|
||||||
.teacherPassword("123qwe")
|
|
||||||
.addTime(new Date())
|
|
||||||
.teacherStatus(1)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return function.apply(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型转换
|
|
||||||
*
|
|
||||||
* @param importPojo 导入的数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Teacher pojo(TeacherBatchImportDTO importPojo) {
|
|
||||||
return pojo(importPojo, e -> e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue