DifyApiConfigDTO.java 1.2 KB
package com.aigeo.ai.dto;

import com.aigeo.ai.entity.DifyApiConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * Dify API配置DTO
 */
@Data
@Schema(description = "Dify API配置DTO")
public class DifyApiConfigDTO {

    @Schema(description = "配置ID")
    private Integer id;

    @Schema(description = "公司ID")
    private Integer companyId;

    @Schema(description = "配置名称")
    private String name;

    @Schema(description = "API Key")
    private String apiKey;

    @Schema(description = "API地址")
    private String apiUrl;

    @Schema(description = "是否启用")
    private Boolean isActive;

    @Schema(description = "备注")
    private String remark;

    /**
     * 将DTO转换为实体类
     */
    public DifyApiConfig toEntity() {
        DifyApiConfig entity = new DifyApiConfig();
        BeanUtils.copyProperties(this, entity);
        return entity;
    }

    /**
     * 将实体类转换为DTO
     */
    public static DifyApiConfigDTO fromEntity(DifyApiConfig entity) {
        DifyApiConfigDTO dto = new DifyApiConfigDTO();
        BeanUtils.copyProperties(entity, dto);
        return dto;
    }
}