package lingtao.net.controller;

import java.util.List;

import lingtao.net.bean.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import lingtao.net.bean.QuoteLog;
import lingtao.net.service.QuoteLogService;

import javax.servlet.http.HttpServletRequest;

@RestController
public class QuoteLogController {

    @Autowired
    private QuoteLogService quoteLogService;

    /**
     * 获取操作日志列表
     *
     * @param page
     * @param limit
     * @param quoteLog
     * @return
     */
    @RequestMapping("/getQuoteLog")
    public PageInfo<QuoteLog> logList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                      @RequestParam(value = "limit", defaultValue = "10") Integer limit, QuoteLog quoteLog) {
        PageHelper.startPage(page, limit);
        List<QuoteLog> logList = quoteLogService.quoteLogs(quoteLog);
        PageInfo<QuoteLog> pageInfo = new PageInfo<QuoteLog>(logList);
        return pageInfo;
    }

    @RequestMapping("/addQuoteLog")
    public Msg addQuoteLog(QuoteLog quoteLog, HttpServletRequest request) {
		String log = quoteLogService.log(quoteLog, request);
        return Msg.success();
    }
}
