学生忘记密码

beetlsql3-dev
Mlxa0324 2 years ago
parent 762f9e8329
commit e35cd58672

@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.ibeetl.jlw.entity.CourseInfo;
import com.ibeetl.jlw.entity.Student;
import com.ibeetl.jlw.entity.StudentExtendSchoolInfo;
import com.ibeetl.jlw.entity.dto.StudentEditPasswordDTO;
import com.ibeetl.jlw.web.query.StudentQuery;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.mapper.BaseMapper;
@ -62,4 +63,12 @@ public interface StudentDao extends BaseMapper<Student>{
* @return
*/
List<StudentExtendSchoolInfo> getStudentExtendSchoolInfoListByUserIds(String userIds);
/**
* -
* @param dto
* @return
*/
Student getStudentByStudentEditPasswordDTO(StudentEditPasswordDTO dto);
}

@ -0,0 +1,56 @@
package com.ibeetl.jlw.entity.dto;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* <p>
* -
* </p>
*
* @author mlx
* @date 2022/11/20
* @modified
*/
@Data
public class StudentEditPasswordDTO {
// 验证院校的授权码
/**
* ID
*/
@NotNull(message = "院校不能为空!")
private Long universitiesCollegesId;
/**
*
*/
@NotEmpty(message = "院校授权码不能为空!")
private String universitiesCollegesAuthCode;
/**
*
*/
@NotEmpty(message = "院校不能为空!")
private String studentName;
/**
*
*/
@NotEmpty(message = "学生编号不能为空!")
private String studentSn;
/**
*
*/
@NotEmpty(message = "原密码不能为空!")
private String oldPwd;
/**
*
*/
@NotEmpty(message = "新密码不能为空!")
private String newPwd;
}

@ -19,21 +19,33 @@ import javax.validation.constraints.NotNull;
@Data
public class StudentRegisterDTO {
// 验证院校的授权码
/**
* ID
*/
@NotNull(message = "院校不能为空!")
private Long universitiesCollegesId;
/**
*
*/
@NotEmpty(message = "院校授权码不能为空!")
private String universitiesCollegesAuthCode;
// 其他信息,暂时没用到,可传可不传
/**
* ID
*/
@NotNull(message = "院校不能为空!")
@NotNull(message = "院不能为空!")
private Long universityFacultyId;
/**
* ID
*/
@NotNull(message = "专业不能为空!")
private Long universitySystemId;
// 学生信息 要求和Student一致用于Copy属性
/**
* ID
*/
@ -61,9 +73,5 @@ public class StudentRegisterDTO {
@Email
@NotEmpty(message = "邮箱不能为空!")
private String studentEmail;
/**
*
*/
@NotEmpty(message = "院校授权码不能为空!")
private String universitiesCollegesAuthCode;
}

@ -228,4 +228,10 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
.andEq(UniversitiesColleges::getUniversitiesCollegesAuthCode, universitiesCollegesAuthCode)
.count() > 0;
}
public void verifyUniAuthCodeThrows(@NotNull(message="院校ID不能为空") Long universitiesCollegesId,
@NotEmpty(message="院校授权码不能为空!") String universitiesCollegesAuthCode) {
boolean verifyUniAuthCode = verifyUniAuthCode(universitiesCollegesId, universitiesCollegesAuthCode);
Assert.isTrue(verifyUniAuthCode, "院校授权码,验证失败!");
}
}

@ -2,11 +2,14 @@ package com.ibeetl.jlw.service.api.student;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.ibeetl.admin.core.service.CorePlatformService;
import com.ibeetl.admin.core.conf.PasswordConfig;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeStudentDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.api.CurrentUserInfo;
import com.ibeetl.jlw.entity.api.student.StudentIndexData;
import com.ibeetl.jlw.entity.dto.StudentEditPasswordDTO;
import com.ibeetl.jlw.entity.dto.StudentRegisterDTO;
import com.ibeetl.jlw.service.*;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeStudentQuery;
@ -34,10 +37,12 @@ public class ApiStudentService {
@Autowired private IndexBaseService indexBaseService;
@Autowired private TeacherOpenCourseNoticeService teacherOpenCourseNoticeService;
@Autowired private StudentService studentService;
@Autowired private StudentDao studentDao;
@Autowired private ResourcesApplicationService resourcesApplicationService;
@Autowired private TeacherOpenCourseMergeStudentDao teacherOpenCourseMergeStudentDao;
@Autowired private UniversitiesCollegesService universitiesCollegesService;
@Autowired private CorePlatformService corePlatformService;
@Autowired private PasswordConfig.PasswordEncryptService passwordEncryptService;
@Autowired private CoreUserService coreUserService;
/**
* -
@ -89,10 +94,44 @@ public class ApiStudentService {
final Long universitiesCollegesId = dto.getUniversitiesCollegesId();
// 传入的院校授权码
final String universitiesCollegesAuthCode = dto.getUniversitiesCollegesAuthCode();
boolean verifyUniAuthCode = universitiesCollegesService.verifyUniAuthCode(universitiesCollegesId, universitiesCollegesAuthCode);
Assert.isTrue(verifyUniAuthCode, "院校授权码,验证失败!");
universitiesCollegesService.verifyUniAuthCodeThrows(universitiesCollegesId, universitiesCollegesAuthCode);
// 以上验证都通过的话,就可以注册用户
studentService.add(BeanUtil.copyProperties(dto, Student.class));
}
/**
* -
* @param dto
*/
public void editPwd(@NotNull(message = "修改密码信息不能为空!") StudentEditPasswordDTO dto) {
// 密码遵循加密算法
dto.setNewPwd(passwordEncryptService.password(dto.getNewPwd()));
dto.setOldPwd(passwordEncryptService.password(dto.getOldPwd()));
// 传入的院校ID
final Long universitiesCollegesId = dto.getUniversitiesCollegesId();
// 传入的院校授权码
final String universitiesCollegesAuthCode = dto.getUniversitiesCollegesAuthCode();
universitiesCollegesService.verifyUniAuthCodeThrows(universitiesCollegesId, universitiesCollegesAuthCode);
{
Student entity = new Student();
entity.setStudentStatus(1);
entity.setStudentSn(dto.getStudentSn());
Assert.isTrue(studentDao.templateCount(entity) > 0, "学生编号不存在!");
entity.setStudentSn(null);
entity.setStudentName(dto.getStudentName());
Assert.isTrue(studentDao.templateCount(entity) > 0, "学生姓名不存在!");
}
Student studentInfo = studentDao.getStudentByStudentEditPasswordDTO(dto);
Assert.notNull(studentInfo, "原始密码错误!");
// 根据旧密码修改新密码
Boolean updateSuccess = coreUserService.editPwdByOld(dto.getOldPwd(), dto.getNewPwd(), studentInfo.getUserId());
Assert.isTrue(updateSuccess, "密码修改失败!");
}
}

@ -2,6 +2,7 @@ package com.ibeetl.jlw.web.api.student;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.jlw.entity.api.student.StudentIndexData;
import com.ibeetl.jlw.entity.dto.StudentEditPasswordDTO;
import com.ibeetl.jlw.entity.dto.StudentRegisterDTO;
import com.ibeetl.jlw.service.api.student.ApiStudentService;
import lombok.extern.slf4j.Slf4j;
@ -44,4 +45,17 @@ public class ApiStudentController {
apiStudentService.register(dto);
return JsonResult.success();
}
/**
* -
*
* @date 2022/11/20
* @return
*/
@PostMapping("editPwd.do")
public JsonResult editPwd(StudentEditPasswordDTO dto) {
apiStudentService.editPwd(dto);
return JsonResult.success();
}
}

@ -1409,3 +1409,22 @@ getStudentExtendSchoolInfoListByUserIds
WHERE
1 = 1
AND FIND_IN_SET(t.user_id,#userIds#)
getStudentByStudentEditPasswordDTO
===
* 学生端-修改密码 验证信息
SELECT
t.*
FROM
student t
LEFT JOIN core_user ta ON ta.ID = t.user_id
WHERE
1 = 1
AND t.student_status = 1
AND ta.STATE = 'S1'
AND ta.DEL_FLAG = 0
AND t.student_name = #studentName#
AND t.student_sn = #studentSn#
AND ta.PASSWORD = #oldPwd#
Loading…
Cancel
Save