package com.lightinit.hsdataplatformresdir.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.lightinit.hsdataplatformresdir.json.pojo.ListResult;
import com.lightinit.hsdataplatformresdir.entity.MTLogInfo;
import com.lightinit.hsdataplatformresdir.service.IMTLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Mr.Yao on 2017/4/27.
 */
@Controller
@RequestMapping("/log")
public class LogController {
    @Autowired
    private IMTLogService logService;

    @RequestMapping(value = "view/mtlog.action", method = RequestMethod.GET)
    public String print_log_mtlog() {
        return "log/mtlog";
    }

    @ResponseBody
    @RequestMapping(value = "json/mtlogs.action", method = RequestMethod.GET)
    public ListResult<MTLogInfo> GetLogs(@RequestParam(required = false, defaultValue = "") String dateStr, @RequestParam(required = false, defaultValue = "") String keywords, @RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int rows) {
        ListResult<MTLogInfo> result = new ListResult<MTLogInfo>();
        if (dateStr.isEmpty()||dateStr=="") {
            SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
            try {
                dateStr=df.format(new Date());
            } catch (Exception e) {
            }
            System.out.print(dateStr + "\r\n");
        }
        /*result.setRows(logService.QueryLogList(dateStr, keywords, page, rows));
        result.setTotal(logService.QueryLogCount(dateStr, keywords));*/
        return result;
    }
}
