package com.snack.server.module.user.dto.req;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * 创建/更新用户请求（管理端代为管理）
 */
@Data
@Schema(description = "创建/更新用户请求")
public class UserSaveReq implements Serializable {

    @Schema(description = "用户 ID（更新时必填）")
    private Long id;

    @NotBlank(message = "用户名不能为空")
    @Size(min = 3, max = 50, message = "用户名长度 3-50")
    @Schema(description = "登录用户名", example = "user099")
    private String username;

    /** 创建时必填；更新留空表示不修改密码 */
    @Schema(description = "密码（创建必填；更新时留空表示不修改）")
    private String password;

    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "头像 URL")
    private String avatar;

    @Pattern(regexp = "^$|^1[3-9]\\d{9}$", message = "手机号格式不正确")
    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "性别：0-未知 1-男 2-女", example = "0")
    private Integer gender = 0;

    @Schema(description = "生日")
    private LocalDate birthday;

    @Schema(description = "状态：0-禁用 1-启用", example = "1")
    private Integer status = 1;
}
