package cn.reghao.tnb.file.app.zoss.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.oss.api.dto.StoreNodeDto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

/**
 * @author reghao
 * @date 2024-02-23 11:29:14
 */
@NoArgsConstructor
@Getter
@Setter
public class StoreNode extends BaseObject<Integer> {
    @NotBlank
    @Pattern(regexp = "^((2((5[0-5])|([0-4]\\d)))|([0-1]?\\d{1,2}))(\\.((2((5[0-5])|([0-4]\\d)))|([0-1]?\\d{1,2}))){3}$", message = "节点地址格式不正确")
    private String nodeAddr;
    @NotNull
    private Integer httpPort;
    @NotNull
    private Integer rpcPort;
    @NotNull
    private Boolean enabled;

    public StoreNode(StoreNodeDto storeNodeDto) {
        this.nodeAddr = storeNodeDto.getNodeAddr();
        this.httpPort = storeNodeDto.getHttpPort();
        this.rpcPort = storeNodeDto.getRpcPort();
        this.enabled = false;
    }
}
