package com.czg.product.dto;

import com.alibaba.fastjson2.annotation.JSONField;
import com.czg.utils.TreeNode;
import com.czg.validator.group.DefaultGroup;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
* 商品规格
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ShopProdSpecDTO extends TreeNode<ShopProdSpecDTO> implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Null(message = "ID必须为空", groups = InsertGroup.class)
    @NotNull(message = "ID不能为空", groups = UpdateGroup.class)
    private Long id;
    /**
     * 规格名称
     */
    @NotBlank(message = "规格名称不能为空", groups = DefaultGroup.class)
    private String name;
    /**
     * 完整规格名称
     */
    private String fullName;
    /**
     * 规格级别
     */
    @NotNull(message = "规格级别不能为空", groups = DefaultGroup.class)
    @Min(value = 1, message = "规格级别不能小于1", groups = DefaultGroup.class)
    @Max(value = 3, message = "规格级别不能大于3", groups = DefaultGroup.class)
    private Integer level;
    /**
     * 排序
     */
    @NotNull(message = "排序值不能为空", groups = DefaultGroup.class)
    @Min(value = 0, message = "排序值不能小于0", groups = DefaultGroup.class)
    private Integer sort;
    /**
     * 上级id
     */
    @NotNull(message = "请选择上级规格", groups = DefaultGroup.class)
    private Long pid;
    /**
     * 所有上级id，用逗号分隔
     */
    private String pids;
    /**
     * 店铺 id
     */
    private Long shopId;
    /**
     * 状态 0-禁用 1-启用
     */
    private Integer status;
    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 更新时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    /**
     * 受影响的规格id列表
     */
    @JSONField(serialize = false)
    private List<Long> affectedIdList;
}