package com.ruoyi.project.system.controller.front;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.QuoteLog;
import com.ruoyi.project.system.service.IQuoteLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/front/log")
public class FrontQuoteLogController extends BaseController {
    @Autowired
    private IQuoteLogService quoteLogService;

    @Log(title = "查询日志", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult saveLog(@RequestBody QuoteLog quoteLog) {
        quoteLog.setCreateBy(SecurityUtils.getUsername());
        quoteLog.setUpdateBy(SecurityUtils.getUsername());
        quoteLog.setIp(IpUtils.getIpAddr());
        quoteLog.setUserId(SecurityUtils.getUserId());
        quoteLog.setOs(ServletUtils.getRequest().getHeader("User-Agent"));
        return toAjax(quoteLogService.insertQuoteLog(quoteLog));
    }

}
