package com.muyu.system.domain.req;

import com.muyu.common.system.domain.SysEnt;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 企业添加请求对象
 * @Author: zi run
 * @Date 2024/9/26 11:51
 * @Description 企业添加请求对象
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "企业添加请求对象", description = "企业信息添加")
public class EntAddReq {

    /**
     * 企业名称
     */
    @NotEmpty(message = "企业名称不能为空")
    @Schema(title = "企业名称", type = "String", defaultValue = "长安汽车", description = "企业名称")
    private String entName;

    /**
     * 负责人
     */
    @NotEmpty(message = "负责人不能为空")
    @Schema(title = "负责人", type = "String", defaultValue = "张三", description = "负责人")
    private String leader;

    /**
     * 联系电话
     */
    @NotBlank(message = "联系电话不能为空")
    @Schema(title = "联系电话", type = "String", defaultValue = "18321974313", description = "联系电话")
    private String phone;

    /**
     * 邮箱
     */
    @NotBlank(message = "邮箱不能为空")
    @Schema(title = "邮箱", type = "String", defaultValue = "12123@qq.com", description = "邮箱账号")
    private String email;

    /**
     * 企业编码
     */
    @NotBlank(message = "企业编码不能为空")
    @Schema(title = "企业编码", type = "String", defaultValue = "db", description = "连接的数据源")
    private String entCode;

    /**
     * 企业添加构建者
     * @param req 企业添加请求对象
     * @return 返回结果
     */
    public static SysEnt addBuild(EntAddReq req) {
        return SysEnt.builder()
                .name(req.getEntName())
                .leader(req.getLeader())
                .phone(req.getPhone())
                .email(req.getEmail())
                .entCode(req.getEntCode())
                .build();
    }
}
