package com.yeejoin.precontrol.common.feign;

import com.github.pagehelper.PageInfo;
import com.yeejoin.precontrol.common.dto.feign.CreatExamDto;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel;

import java.util.List;
import java.util.Map;

/**
 * 考试feign
 * 
 * @author Admin
 */
@FeignClient(name = "AMOS-TRAININGEXAM", configuration = { ExamFeign.Configuration.class,		FeignRequestInterceptor.class })
//@FeignClient(name = "AMOS-TRAININGEXAM", configuration = { ExamFeign.Configuration.class,		FeignRequestInterceptor.class }, url = "http://39.100.239.237:10005")
//@FeignClient(name = "AMOS-TRAININGEXAM", configuration = { ExamFeign.Configuration.class,		FeignRequestInterceptor.class }, url = "http://47.92.234.253:10005")
public interface ExamFeign {

	@RequestMapping(value = "/trainingexam/examTemplate/templateSelectSubject", method = RequestMethod.POST)
	ResponseModel<Long> doTemplateExam(@RequestBody CreatExamDto creatExamDto);

	class Configuration {
		@Bean
		Encoder feignFormEncoder(ObjectFactory<HttpMessageConverters> converters) {
			return new SpringFormEncoder(new SpringEncoder(converters));
		}
	}

	@RequestMapping(value = "/trainingexam/examTemplate/findExamTemplateBySubjectBankType", method = RequestMethod.GET)
	ResponseModel<List<Map<String, Object>>> getTemplateInSubjectBankType(@RequestParam String subjectBankType);

	/**
	 * 考试状态统计
	 * @param userId 用户
	 * @return List<Map<String, Object>>
	 */
	@GetMapping("/trainingexam/v1/examination/examStatistics/{userId}")
	ResponseModel<Map<String, Object>> getExamStatisticsData(@PathVariable String userId);

	/**
	 * 查询考试列表
	 * @return
	 */
	@GetMapping("/trainingexam/v1/examination/onlineExamPage?pageSize=10&pageNum=1&flag=online&examinationName=")
	ResponseModel<PageInfo> getExamStatisticsList();

	/**
	 * 查询考试列表
	 * @return
	 */
	@GetMapping("/trainingexam/examTemplate/findSameCategoryTemps/{examinationTempId}")
	ResponseModel<List<Map<String, Object>>> getSameCategoryTemps(@PathVariable Long examinationTempId);
}
