package com.ytpm.utils;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ytpm.dao.AgentMiddleEnterpriseMapper;
import com.ytpm.handle.CustomerException;
import com.ytpm.middle.model.YtMiddleEnterprise;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class GetTakuInfoUtil {

    @Resource
    private AgentMiddleEnterpriseMapper agentMiddleEnterpriseMapper;

    public String getTakuPublicKey(String userId){
        YtMiddleEnterprise enterprise = agentMiddleEnterpriseMapper.queryTakuPublicKey(userId);
        if (enterprise!=null && StrUtil.isNotBlank(enterprise.getTakuPublicKey())){
            return enterprise.getTakuPublicKey();
        }
        else {
            throw new CustomerException("请配置taku公钥");
        }
    }
}
