|
@@ -1,5 +1,7 @@
|
|
|
package com.sqx.modules.file.app;
|
|
package com.sqx.modules.file.app;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.sqx.common.utils.IPUtils;
|
|
|
import com.sqx.common.utils.Result;
|
|
import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.app.annotation.Login;
|
|
import com.sqx.modules.app.annotation.Login;
|
|
|
import com.sqx.modules.file.service.NewFileService;
|
|
import com.sqx.modules.file.service.NewFileService;
|
|
@@ -7,11 +9,14 @@ import icu.xuyijie.secureapi.annotation.DecryptParam;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author codingliang
|
|
* @author codingliang
|
|
|
* @date 2025-10-21
|
|
* @date 2025-10-21
|
|
@@ -31,4 +36,17 @@ public class AppNewFileController {
|
|
|
String src = newFileService.upload(file);
|
|
String src = newFileService.upload(file);
|
|
|
return Result.success().put("data",src);
|
|
return Result.success().put("data",src);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "limit-upload")
|
|
|
|
|
+ public Result uploadWithToken(HttpServletRequest request, @DecryptParam("file") MultipartFile file){
|
|
|
|
|
+ String clientIp = IPUtils.getIpAddr(request);
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isBlank(clientIp)){
|
|
|
|
|
+ return Result.error("未获取到客户端IP地址");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String src = newFileService.upload(clientIp, file);
|
|
|
|
|
+ return Result.success().put("data", src);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|