1.修改求职者生日验证及参数验证

This commit is contained in:
sh
2025-11-25 16:38:02 +08:00
parent a9822c34fe
commit 46c78f72a4
5 changed files with 59 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.cms.domain.vo.AppUserLky;
import com.ruoyi.cms.util.DateValidateUtil;
import com.ruoyi.cms.util.RoleUtils;
import com.ruoyi.common.annotation.BussinessLog;
import com.ruoyi.common.core.domain.entity.AppUserShow;
@@ -194,6 +195,16 @@ public class CmsAppUserController extends BaseController
@GetMapping("/userApplyList")
public TableDataInfo userApplyList(AppUser appUser)
{
String birthDateError = DateValidateUtil.validateBirthDate(appUser.getBirthDate());
if (birthDateError != null) {
TableDataInfo errorResult = new TableDataInfo();
errorResult.setCode(400);
errorResult.setMsg(birthDateError);
errorResult.setRows(null);
errorResult.setTotal(0);
return errorResult;
}
startPage();
List<AppUserShow> list = appUserService.selectUserApplyList(appUser);
return getDataTable(list);

View File

@@ -0,0 +1,39 @@
package com.ruoyi.cms.util;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
/**
* 日期校验工具类
*/
public class DateValidateUtil {
// 私有构造器:禁止实例化工具类
private DateValidateUtil() {}
// 生日格式yyyy-MM-dd静态常量统一维护
private static final DateTimeFormatter BIRTH_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final String BIRTH_DATE_ERROR_MSG = "生日格式错误!不为空时必须填写 yyyy-MM-dd 格式(如 2000-01-01";
/**
* 静态方法:校验生日格式(可为空,非空时需符合 yyyy-MM-dd
* @param birthDate 待校验的生日LocalDate 类型)
* @return 校验通过返回 null失败返回错误提示信息
*/
public static String validateBirthDate(LocalDate birthDate) {
// 空值直接放行,返回 null 表示校验通过
if (birthDate == null) {
return null;
}
try {
// 非空时校验格式LocalDate 格式化需符合 yyyy-MM-dd
BIRTH_DATE_FORMATTER.format(birthDate);
return null; // 格式正确,返回 null 表示校验通过
} catch (DateTimeParseException e) {
// 格式错误,返回具体提示信息
return BIRTH_DATE_ERROR_MSG;
}
}
}

View File

@@ -133,7 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INNER join company e on c.company_id=e.company_id and e.del_flag='0'
<where>
<if test="name != null and name != ''"> and a.name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="birthDate != null "> and a.birth_date = #{birthDate}</if>
<if test="birthDate != null "> and get_birth_date_from_id_card(a.id_card) = #{birthDate}</if>
<if test="education != null and education != ''"> and a.education = #{education}</if>
<if test="politicalAffiliation != null and politicalAffiliation != ''"> and a.political_affiliation = #{politicalAffiliation}</if>
<if test="phone != null and phone != ''"> and a.phone = #{phone}</if>