feat: 航线管理页面优化

This commit is contained in:
2025-11-04 11:53:35 +08:00
parent e106e09fa5
commit e23eecdbfd
21 changed files with 515 additions and 1070 deletions
@@ -1,8 +1,11 @@
package com.central.device.controller;
import cn.hutool.core.bean.BeanUtil;
import com.central.common.model.PageResult;
import com.central.common.model.Result;
import com.central.device.feign.FileCenterService;
import com.central.device.model.LineFile;
import com.central.device.model.vo.WaypointInfoVO;
import com.central.device.service.ILineFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -13,6 +16,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,6 +36,9 @@ import java.util.stream.Collectors;
public class LineFileController {
private final ILineFileService lineFileService;
@Resource
private FileCenterService fileCenterService;
/**
* 列表
*/
@@ -56,7 +63,11 @@ public class LineFileController {
if (model == null) {
return Result.failed("未找到对应的航线文件信息");
}
return Result.succeed(model, "查询成功");
String fileurl = fileCenterService.getFileViewUrl(model.getWaylineId());
WaypointInfoVO infoVO = new WaypointInfoVO();
BeanUtil.copyProperties(model,infoVO);
infoVO.setFileUrl(fileurl);
return Result.succeed(infoVO, "查询成功");
} catch (Exception e) {
log.error("查询航线文件失败,id: {}", id, e);
return Result.failed("查询航线文件失败:" + e.getMessage());
@@ -0,0 +1,73 @@
package com.central.device.feign;
import com.central.common.constant.ServiceNameConstants;
import com.central.common.model.FileInfo;
import com.central.common.model.Result;
import com.central.device.feign.fallback.FileCenterServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* user-center模块远程调用
*
* @author lsl
* @version 1.0
* @description user-center模块远程调用
* @create 2025/1/13
**/
@FeignClient(name = ServiceNameConstants.FILE_SERVICE, fallbackFactory = FileCenterServiceFallbackFactory.class, dismiss404 = true)
public interface FileCenterService {
/**
* 通过ID查询预览地址
*
* @param id 文件ID
* @return
*/
@GetMapping("/file/{id}")
String getFileViewUrl(@PathVariable("id") String id);
@GetMapping("/type/{id}")
String getFileContentType(@PathVariable("id") String id);
@GetMapping("/qrcode/{codeId}")
Result<Map> uploadQrCodeFile(@PathVariable("codeId") String codeId) throws Exception;
@PostMapping("/path")
FileInfo creatFileInfo(@RequestBody String path);
@GetMapping("/files/path")
String getViewUrlByPath(@RequestParam("path") String path) ;
@GetMapping("/files/path/style")
String getViewUrlByPathStyle(@RequestParam("params") Map<String,String> params) ;
@GetMapping("/list/files")
List<String> getListFiles(@RequestParam("prefix") String prefix) ;
/**
* 预热文件到CDN
*
* @param urls 需要预热的URL列表
* @param area 预热范围:domestic-仅中国内地,overseas-全球(不包含中国内地),不传-全球
* @return 预热任务ID
*/
@PostMapping("/cdn/prefetch")
Result<String> prefetchFiles(@RequestBody List<String> urls, @RequestParam(value = "area", required = false) String area);
/**
* 批量预热文件到CDN
*
* @param urls 需要预热的URL列表
* @param batchSize 每批次处理的URL数量
* @param area 预热范围
* @return 预热任务执行结果
*/
@PostMapping("/cdn/batch/prefetch")
Result<Boolean> batchPrefetchFiles(@RequestBody List<String> urls,
@RequestParam(value = "batchSize", defaultValue = "100") int batchSize,
@RequestParam(value = "area", required = false) String area);
}
@@ -0,0 +1,78 @@
package com.central.device.feign.fallback;
import com.central.common.model.FileInfo;
import com.central.common.model.Result;
import com.central.device.feign.FileCenterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 文件中心调用失败回调
*
* @author lsl
* @version 1.0
* @description 用户中心调用失败回调
* @create 2025/1/17 11:33
**/
@Slf4j
@Component
public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCenterService> {
@Override
public FileCenterService create(Throwable cause) {
return new FileCenterService() {
@Override
public String getFileViewUrl(String id) {
return "";
}
@Override
public String getFileContentType(String id) {
return "";
}
@Override
public Result<Map> uploadQrCodeFile(String codeId) throws Exception {
return null;
}
@Override
public FileInfo creatFileInfo(String path) {
return null;
}
@Override
public String getViewUrlByPath(String path) {
return "";
}
@Override
public String getViewUrlByPathStyle(Map<String, String> params) {
return "";
}
@Override
public List<String> getListFiles(String prefix) {
return List.of();
}
@Override
public Result<String> prefetchFiles(List<String> urls, String area) {
log.warn("CDN预热文件失败,URLs: {}, area: {}", urls, area, cause);
return Result.failed("CDN预热文件失败: " + cause.getMessage());
}
@Override
public Result<Boolean> batchPrefetchFiles(List<String> urls, int batchSize, String area) {
log.warn("CDN批量预热文件失败,URLs: {}, batchSize: {}, area: {}", urls, batchSize, area, cause);
return Result.failed("CDN批量预热文件失败: " + cause.getMessage());
}
};
}
}
@@ -38,4 +38,6 @@ public class LineFile extends SuperEntity {
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
private String tenantId;
}
@@ -0,0 +1,10 @@
package com.central.device.model.vo;
import com.central.device.model.LineFile;
import lombok.Data;
@Data
public class WaypointInfoVO extends LineFile {
private String fileUrl;
}
@@ -3,6 +3,22 @@
<mapper namespace="com.central.device.mapper.LineFileMapper">
<select id="findList" resultType="com.central.device.model.LineFile">
select * from wayline_file t
select * from wayline_file t where 1=1
<if test="p.name != null and p.name != ''">
and t.name like concat('%', #{p.name}, '%')
</if>
<if test="p.waylineId != null and p.waylineId != ''">
and t.wayline_id = #{p.waylineId}
</if>
<if test="p.workspaceId != null and p.workspaceId != ''">
and t.workspace_id = #{p.workspaceId}
</if>
<if test="p.droneModelKey != null and p.droneModelKey != ''">
and t.drone_model_key = #{p.droneModelKey}
</if>
<if test="p.userName != null and p.userName != ''">
and t.user_name like concat('%', #{p.userName}, '%')
</if>
order by t.create_time desc
</select>
</mapper>
@@ -95,7 +95,7 @@ public class RefundServiceImpl extends SuperServiceImpl<RefundMapper, Refund> im
result.put("reason", refund.getRefundReason());
result.put("refundReason", refund.getRefundReason());
result.put("approveReason", refund.getApproveReason());
result.put("createTime", refund.getCreateTime());
result.put("refundTime", refund.getRefundTime());
result.put("applyTime", refund.getCreateTime());
// 处理图片列表 - refundImgs 可能是逗号分隔的字符串或JSON