package com.schisandra.auth.infra.rpc;


import com.schisandra.auth.infra.entity.SmsConfigInfo;
import com.schisandra.system.api.SchisandraSystemFeignService;
import com.schisandra.system.entity.Result;
import com.schisandra.system.entity.SchisandraSysConfigDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Classname SmsConfigRpc
 * @BelongsProject: schisandra-cloud-storage
 * @BelongsPackage: com.schisandra.auth.application.rpc
 * @Author: landaiqing
 * @CreateTime: 2024-05-11  23:44
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class SmsConfigRpc {
    @Resource
    private SchisandraSystemFeignService schisandraSystemFeignService;

    public SmsConfigInfo getConfigInfo(String key) {
        Result<SchisandraSysConfigDTO> result = schisandraSystemFeignService.getConfigByKey(key);
        SmsConfigInfo smsConfigInfo = new SmsConfigInfo();
        if (!result.getSuccess()) {
            return smsConfigInfo;
        }
        SchisandraSysConfigDTO data = result.getData();
        smsConfigInfo.setConfigKey(data.getConfigKey());
        smsConfigInfo.setConfigName(data.getConfigName());
        smsConfigInfo.setConfigValue(data.getConfigValue());
        smsConfigInfo.setRemarks(data.getRemarks());
        smsConfigInfo.setConfigType(data.getConfigType());
        return smsConfigInfo;
    }

}
