package com.hotent.portal.config;

import com.hotent.base.jms.JmsHandler;
import com.hotent.jms.model.JmsTableTypeConf;
import com.hotent.jms.model.JmsTableTypeFiledDetail;
import com.hotent.portal.jms.impl.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * jms消息处理器配置类
 *
 * @company 广州宏天软件股份有限公司
 * @author heyifan
 * @email heyf@jee-soft.cn
 * @date 2018年10月9日
 */
@Configuration
public class JmsHandlerConfig {
	@Resource
    MailHandler mailHandler;
    @Resource
    InnerHandler innerHandler;
    @Resource
    SmsHandler smsHandler;
    @Resource
    VoiceHandler voiceHandler;
    @Resource
    WxEnterpriseHandler wxEnterpriseHandler;
    @Resource
    DingTalkHandler dingTalkHandler;

	@Bean
    public List<JmsHandler> jmsHandList(){
        List<JmsHandler> list = new ArrayList<>();
        list.add(innerHandler);
        list.add(mailHandler);
        list.add(smsHandler);
        list.add(voiceHandler);
        list.add(wxEnterpriseHandler);
        list.add(dingTalkHandler);
        return list;
    }

//	@Bean
//	@ConditionalOnProperty(value="jms.enable", matchIfMissing = true)
//	public JmsMessageConsumer messageConsumer(List<JmsHandler> jmsHandList) {
//		JmsMessageConsumer jmsReceiverEventListener = new JmsMessageConsumer();
//		jmsReceiverEventListener.setJmsHandList(jmsHandList);
//		return jmsReceiverEventListener;
//	}

	@Bean("portalTableTypeConf")
	public JmsTableTypeConf TableTypeConf() {
		JmsTableTypeConf.AddTypeConf("FILE_TYPE",new JmsTableTypeFiledDetail("portal_sys_file","ID_", "", "TYPE_"));
        JmsTableTypeConf.AddTypeConf("DEF_TYPE",new JmsTableTypeFiledDetail("form_bo_def","ID_", "CATEGORY_ID_", "CATEGORY_NAME_"));
        JmsTableTypeConf.AddTypeConf("FORM_TYPE",new JmsTableTypeFiledDetail("form_definition","ID_", "TYPE_ID_", "TYPE_NAME_"));
        JmsTableTypeConf.AddTypeConf("FORM_TYPE",new JmsTableTypeFiledDetail("form_url_form","ID_", "TYPE_ID_", "TYPE_NAME_"));
        JmsTableTypeConf.AddTypeConf("FORM_TYPE",new JmsTableTypeFiledDetail("form_data_template","ID_", "TYPE_ID_", "TYPE_NAME_"));
        JmsTableTypeConf.AddTypeConf("PRINT_TEMPLATE",new JmsTableTypeFiledDetail("form_print_template","ID_", "TYPE_ID_", "TYPE_NAME_"));
        return null;
	}
}
