package com.persagy.calendar.aop;

import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.persagy.common.aop.CommonExceptionHandler;
import com.persagy.common.enums.ResponseCode;
import com.persagy.common.utils.ResponseResult;
import com.persagy.common.utils.ResponseUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * @description 
 * @author zhangqiankun
 * @since 2020年8月26日:	下午5:17:08
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler extends CommonExceptionHandler {
	
	@ExceptionHandler(DuplicateKeyException.class)
	public ResponseResult handleDuplicateKeyException(Exception e) {
		log.error(e.getMessage(), e);
		return ResponseUtil.errorResult(ResponseCode.C0341.getCode(), ResponseCode.C0341.getDesc());
	}
	
}
