You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.0 KiB

package com.system.log.controller;
import com.alibaba.fastjson.JSONObject;
import com.google.inject.Inject;
import com.google.inject.servlet.RequestScoped;
import com.hypaas.db.JpaSupport;
import com.hypaas.rpc.ActionRequest;
import com.hypaas.rpc.ActionResponse;
import com.system.log.core.FileUtils;
import com.system.log.service.LogService;
import java.io.File;
import java.io.IOException;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
/**
* @author zhangqiyang
* @description LogManage
* @date 2024/3/12
*/
@RequestScoped
@Produces(MediaType.APPLICATION_JSON)
@Path("/log")
public class LogController extends JpaSupport {
@Inject LogService logService;
// 过滤查询日志接口
/*
* logType 日志类型
* startTime 需要过滤的日志的开始时间
* endTime 需要过滤的日志的结束时间
* keyWord 关键字
*/
@GET
@Path("/getDirContent")
public JSONObject getDirContent(
@QueryParam("logType") String logType,
@QueryParam("startTime") String startTime,
@QueryParam("endTime") String endTime,
@QueryParam("keyWord") String keyWord)
throws IOException {
return logService.getDirContent(logType, startTime, endTime, keyWord);
}
// 以zip形式导出日志文件,并设置解压密码
/*
* password 密码
* conditionPassword 确认密码
* logType 日志类型
* startTime 需要过滤的日志的开始时间
* endTime 需要过滤的日志的结束时间
* keyWord 关键字
*/
@POST
@Path("/getFileZip")
public void getFileZip(ActionRequest request, ActionResponse response) {
File file = logService.getFileZip(request, response);
FileUtils.downloadFile(response, file);
}
// @GET
// @Path("/getFile")
// public JSONObject getFileChange() {
// return logService.getFileChange();
// }
public void exportLog(ActionRequest request, ActionResponse response) throws IOException {
File file = logService.exportLog(request, response);
FileUtils.downloadFile(response, file);
}
}