package com.jeesharp.business.modules.pay.paywechatconfig.service;

import cn.hutool.core.util.StrUtil;
import com.jeesharp.business.modules.pay.paywechatconfig.entity.PayWechatConfig;
import com.jeesharp.business.modules.pay.vo.PayWechatPublicConfigVO;
import org.springframework.stereotype.Component;

/**
 * 将 {@link PayWechatConfig} 转为对外公开 VO（不含密钥）。
 *
 * @author jeesharp
 * @since 2026-05-25
 */
@Component
public class PayWechatPublicConfigSupport {

    public PayWechatPublicConfigVO build(PayWechatConfig active) {
        PayWechatPublicConfigVO vo = new PayWechatPublicConfigVO();
        if (active == null) {
            vo.setWxEnabled(Boolean.FALSE);
            vo.setNotifyBaseUrl("");
            return vo;
        }
        vo.setNotifyBaseUrl(StrUtil.nullToDefault(active.getNotifyBaseUrl(), ""));
        vo.setWxEnabled(active.getWxEnabled() != null && active.getWxEnabled() == 1);
        return vo;
    }
}
