package com.yn.bftl.thirdparty.modules.log.controller;

import com.yn.bftl.thirdparty.modules.log.dto.EasemobCallbackDTO;
import com.yn.bftl.thirdparty.modules.log.dto.LoggerDTO;
import com.yn.bftl.thirdparty.modules.log.service.LoggerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@Validated
@Api(value = "LoggerController", tags = "公共-日志操作")
@RestController
@RequestMapping("/logger")
public class LoggerController {

    @Resource
    LoggerService loggerService;

    /**
     * 用户日志
     *
     * @return
     */
    @ApiOperation(value = "用户日志")
    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public void user(@Valid @RequestBody LoggerDTO loggerDTO) {
        loggerService.user(loggerDTO.getMessage(), loggerDTO.getAttachment(), loggerDTO.getClassName(), loggerDTO.getFunctionName(), loggerDTO.getLogType());
    }

    /**
     * 订单日志
     *
     * @return
     */
    @ApiOperation(value = "订单日志")
    @RequestMapping(value = "/order", method = RequestMethod.POST)
    public void order(@Valid @RequestBody LoggerDTO loggerDTO) {
        loggerService.order(loggerDTO.getMessage(), loggerDTO.getAttachment(), loggerDTO.getClassName(), loggerDTO.getFunctionName(), loggerDTO.getLogType());
    }

    /**
     * 操作日志
     *
     * @return
     */
    @ApiOperation(value = "操作日志")
    @RequestMapping(value = "/operation", method = RequestMethod.POST)
    public void operation(@Valid @RequestBody LoggerDTO loggerDTO) {
        loggerService.operation(loggerDTO.getMessage(), loggerDTO.getAttachment(), loggerDTO.getClassName(), loggerDTO.getFunctionName(), loggerDTO.getLogType());
    }
}
