对比新文件 |
| | |
| | | package com.vci.ubcs.log.controller; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.vci.ubcs.log.vo.LocalLogVO; |
| | | import com.vci.ubcs.log.service.ILogLocalService; |
| | | import com.vci.ubcs.log.entity.LocalLog; |
| | | import com.vci.ubcs.resource.utils.FileDownloadUtil; |
| | | import com.vci.ubcs.starter.web.util.ControllerUtil; |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.rmi.ServerException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 鏈湴绯荤粺鏃ュ織 |
| | | * @author ludc |
| | | * @date 2023/10/31 15:37 |
| | | */ |
| | | @NonDS |
| | | @Slf4j |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/localLog") |
| | | public class LogLocalController { |
| | | |
| | | private final ILogLocalService logLocalService; |
| | | |
| | | /** |
| | | * 鑾峰彇鏃ュ織鏂囦欢鍒楄〃 |
| | | * @param localLog |
| | | * @return |
| | | */ |
| | | @PostMapping("/lazy-list") |
| | | public R<List<LocalLog>> getSystemLogList(@RequestBody LocalLog localLog){ |
| | | return R.data(logLocalService.getSystemLogList(localLog.getLogPath())); |
| | | } |
| | | |
| | | /** |
| | | * 涓嬭浇鏃ュ織鏂囦欢 |
| | | * @param localLogVO 涓嬭浇鏃ュ織鐨勫叏璺緞闆嗗悎 |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/downLoadLog",method = {RequestMethod.GET,RequestMethod.POST}) |
| | | public void downloadLogByServiceName(@RequestBody LocalLogVO localLogVO, HttpServletResponse response) throws IOException { |
| | | try { |
| | | //ControllerUtil.writeFileToResponse(response,excelName); |
| | | FileDownloadUtil.downloadFileLocal(response, logLocalService.downloadLogByServiceNameAndFileName(localLogVO),true); |
| | | } catch (Throwable e) { |
| | | //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | if(StringUtils.isBlank(msg)){ |
| | | msg = "鏈煡閿欒"; |
| | | } |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 鍒犻櫎鏃ュ織鏂囦欢 |
| | | * @param localLogVO |
| | | * @return |
| | | * @throws ServerException |
| | | */ |
| | | @DeleteMapping("/deleteLogFile") |
| | | public R deleteLogFile(@RequestBody LocalLogVO localLogVO) throws ServerException { |
| | | return logLocalService.deleteLogFile(localLogVO); |
| | | } |
| | | |
| | | } |