package org.xyzh.api.system.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.xyzh.common.vo.BaseVO;
import org.xyzh.common.dto.sys.TbSysConfigDTO;
import com.alibaba.fastjson2.JSONObject;

/**
 * @description    系统配置视图对象
 * @filename    SysConfigVO.java
 * @author    yslg
 * @copyright yslg
 * @since 2025-11-05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "系统配置视图对象")
public class SysConfigVO extends BaseVO {
    

    @Schema(description = "配置ID")
    private String configId;

    @Schema(description = "配置键")
    private String key;

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

    @Schema(description = "配置值")
    private String value;

    @Schema(description = "数据类型(String, Integer, Boolean, Float, Double)")
    private String configType;

    @Schema(description = "配置渲染类型(select, input, textarea, checkbox, radio, switch)")
    private String renderType;

    @Schema(description = "配置描述")
    private String description;

    @Schema(description = "正则表达式校验规则(JSON)")
    private JSONObject re;

    @Schema(description = "可选项(JSON)，render_type为select、checkbox、radio时使用")
    private JSONObject options;

    @Schema(description = "配置组")
    private String group;

    @Schema(description = "模块ID")
    private String moduleId;

    @Schema(description = "模块名称")
    private String moduleName;

    @Schema(description = "模块描述")
    private String moduleDescription;

    @Schema(description = "配置顺序")
    private Integer orderNum;

    @Schema(description = "状态")
    private Integer status;

    public static TbSysConfigDTO toDTO(SysConfigVO vo) {
        if (vo == null) {
            return null;
        }
        TbSysConfigDTO dto = new TbSysConfigDTO();
        dto.setConfigId(vo.getConfigId());
        dto.setKey(vo.getKey());
        dto.setName(vo.getName());
        dto.setValue(vo.getValue());
        dto.setConfigType(vo.getConfigType());
        dto.setRenderType(vo.getRenderType());
        dto.setDescription(vo.getDescription());
        dto.setRe(vo.getRe());
        dto.setOptions(vo.getOptions());
        dto.setGroup(vo.getGroup());
        dto.setModuleId(vo.getModuleId());
        dto.setOrderNum(vo.getOrderNum());
        dto.setStatus(vo.getStatus());
        // 基础字段
        dto.setOptsn(vo.getOptsn());
        dto.setCreator(vo.getCreator());
        dto.setUpdater(vo.getUpdater());
        dto.setDeptPath(vo.getDeptPath());
        dto.setRemark(vo.getRemark());
        dto.setCreateTime(vo.getCreateTime());
        dto.setUpdateTime(vo.getUpdateTime());
        dto.setDeleteTime(vo.getDeleteTime());
        dto.setDeleted(vo.getDeleted());
        return dto;
    }

}

