package com.judong.chuanyiserver.controller;

import com.judong.chuanyiserver.enums.ResultEnum;
import com.judong.chuanyiserver.service.LogService;
import com.judong.chuanyiserver.util.Blank;
import com.judong.chuanyiserver.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("log")
@Slf4j
public class LogController {

    @Autowired
    private LogService logService;

    @GetMapping("/getLogPage")
    public Result getLogPage(int page, int limit, String serverName, String modelName, String content, String userId, String ipAddress, String methodName,String startDate,String endDate) {
        if (Blank.isEmpty(page, limit) || page < 1 || limit < 1) {
            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
        }
        return logService.getLogPage(page, limit, serverName, modelName, content, userId, ipAddress, methodName,startDate,endDate);
    }

    /**
     * 删除6个月之前数据
     */
    @GetMapping("/deleteByDate")
    public Result logDeleteByDate(){
        return logService.logDeleteByTime();
    }


}
