1.修改求职者生日验证及参数验证
This commit is contained in:
@@ -111,6 +111,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--localDate-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.ruoyi.cms.domain.vo.AppUserLky;
|
import com.ruoyi.cms.domain.vo.AppUserLky;
|
||||||
|
import com.ruoyi.cms.util.DateValidateUtil;
|
||||||
import com.ruoyi.cms.util.RoleUtils;
|
import com.ruoyi.cms.util.RoleUtils;
|
||||||
import com.ruoyi.common.annotation.BussinessLog;
|
import com.ruoyi.common.annotation.BussinessLog;
|
||||||
import com.ruoyi.common.core.domain.entity.AppUserShow;
|
import com.ruoyi.common.core.domain.entity.AppUserShow;
|
||||||
@@ -194,6 +195,16 @@ public class CmsAppUserController extends BaseController
|
|||||||
@GetMapping("/userApplyList")
|
@GetMapping("/userApplyList")
|
||||||
public TableDataInfo userApplyList(AppUser appUser)
|
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();
|
startPage();
|
||||||
List<AppUserShow> list = appUserService.selectUserApplyList(appUser);
|
List<AppUserShow> list = appUserService.selectUserApplyList(appUser);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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'
|
INNER join company e on c.company_id=e.company_id and e.del_flag='0'
|
||||||
<where>
|
<where>
|
||||||
<if test="name != null and name != ''"> and a.name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
|
<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="education != null and education != ''"> and a.education = #{education}</if>
|
||||||
<if test="politicalAffiliation != null and politicalAffiliation != ''"> and a.political_affiliation = #{politicalAffiliation}</if>
|
<if test="politicalAffiliation != null and politicalAffiliation != ''"> and a.political_affiliation = #{politicalAffiliation}</if>
|
||||||
<if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
|
<if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP用户对象 app_user
|
* APP用户对象 app_user
|
||||||
* @author lishundong
|
* @author lishundong
|
||||||
@@ -43,6 +45,7 @@ public class AppUser extends BaseEntity
|
|||||||
@ApiModelProperty("用户性别(0男 1女)对应字典sex")
|
@ApiModelProperty("用户性别(0男 1女)对应字典sex")
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
@ApiModelProperty("生日")
|
@ApiModelProperty("生日")
|
||||||
|
|||||||
Reference in New Issue
Block a user