package com.yonge.cooleshow.auth.web.controller;

import com.dayaedu.cbs.common.enums.EAppKey;
import com.dayaedu.cbs.openfeign.client.SysExceptionLogFeignClientService;
import com.dayaedu.cbs.openfeign.wrapper.courseware.SysExceptionLogVo;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
public class ExceptionLogController extends BaseController {

	@Resource
	private SysExceptionLogFeignClientService sysExceptionLogFeignClientService;

	@PostMapping("sysExceptionLog/save")
	public HttpResponseResult save(@RequestBody List<SysExceptionLogVo.SysExceptionLog> sysExceptionLogVos) {
		if(CollectionUtils.isEmpty(sysExceptionLogVos)){
			return succeed();
		}
		sysExceptionLogVos.forEach(sysExceptionLogVo -> {
			sysExceptionLogVo.setAppKey(EAppKey.KLX);
		});
		sysExceptionLogFeignClientService.add(sysExceptionLogVos).feignData();
		return succeed();
	}

}
