package com.usky.meeting.annotation.aspect;



import com.usky.meeting.domain.MeetingFaceVefLog;
import com.usky.meeting.service.MeetingFaceVefLogService;
import com.usky.meeting.service.vo.FaceResultVO;
import com.usky.meeting.service.vo.MeetingFaceVO;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author tanyongpeng
 * <p>方法执行后，添加日志</p>
 **/
@Component
@Aspect
public class FaceAspect {

    @Autowired
    private MeetingFaceVefLogService faceVefLogService;

    @AfterReturning(value = "@annotation(com.usky.meeting.annotation.FaceLog)",returning = "res")
    public void addLog(JoinPoint joinPoint ,Object res){
        MeetingFaceVO result = (MeetingFaceVO)res;
        MeetingFaceVefLog faceVefLog = new MeetingFaceVefLog();
        faceVefLog.setVefTime(LocalDateTime.now());
        faceVefLog.setVefCode(result.getCode());
        faceVefLog.setVefMsg(result.getMsg());
        faceVefLog.setLoginName(result.getFaceName());
        faceVefLogService.save(faceVefLog);
    }


}
