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 lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.function.Supplier;

/**
 * 企业修改请求对象
 * @Author: zi run
 * @Date 2024/9/26 14:34
 * @Description 企业修改请求对象
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "企业修改请求对象", description = "企业信息修改")
public class EntUpdateReq {

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

    /**
     * 负责人
     */
    @Schema(title = "负责人", type = "String", defaultValue = "张三", description = "负责人")
    private String leader;

    /**
     * 联系电话
     */
    @Schema(title = "联系电话", type = "String", defaultValue = "18321974313", description = "联系电话")
    private String phone;

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

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

    /**
     * 企业修改构建者
     * @param req 企业修改请求对象
     * @param entId 企业ID
     * @return 企业管理实体
     */
    public static SysEnt updateBuild(EntUpdateReq req, Supplier<Long> entId) {
        return SysEnt.builder()
                .id(entId.get())
                .name(req.getEntName())
                .leader(req.getLeader())
                .phone(req.getPhone())
                .email(req.getEmail())
                .entCode(req.getEntCode())
                .build();
    }
}
