订单管理图片上传改为sftp

This commit is contained in:
zhanghan11 2024-05-06 09:20:29 +08:00
parent c173418103
commit 287a602a2a
9 changed files with 55 additions and 42 deletions

View File

@ -8,8 +8,12 @@ import javax.servlet.http.HttpServletResponse;
import com.inspur.common.constant.OmConstants; import com.inspur.common.constant.OmConstants;
import com.inspur.common.utils.StringUtils; import com.inspur.common.utils.StringUtils;
import com.inspur.common.utils.file.SftpUtils;
import com.inspur.common.utils.uuid.IdUtils; import com.inspur.common.utils.uuid.IdUtils;
import org.mybatis.logging.LoggerFactory; import org.mybatis.logging.LoggerFactory;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -34,7 +38,8 @@ import org.springframework.web.multipart.MultipartFile;
public class OmTeamApplicationController extends BaseController { public class OmTeamApplicationController extends BaseController {
@Autowired @Autowired
private IOmTeamApplicationService omTeamApplicationService; private IOmTeamApplicationService omTeamApplicationService;
@Autowired
private SftpUtils sftpUtils;
/** /**
* 用户查询团队注册申请列表 * 用户查询团队注册申请列表
*/ */
@ -151,4 +156,16 @@ public class OmTeamApplicationController extends BaseController {
out.write(bytes); out.write(bytes);
} }
} }
/**
* 图片展示
*/
@GetMapping("/show")
public ResponseEntity<ByteArrayResource> show(@RequestParam(value = "saveName", required = true) String saveName) {
byte[] bytes = omTeamApplicationService.downLoadFile(OmConstants.SAVE_PATH_SEPARATOR + sftpUtils.getBasePath() + OmConstants.SAVE_PATH_SEPARATOR + OmConstants.SAVE_PATH, saveName);
ByteArrayResource resource = new ByteArrayResource(bytes);
return ResponseEntity.ok()
.contentType(MediaType.IMAGE_JPEG)
.body(resource);
}
} }

View File

@ -1654,13 +1654,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -1600,13 +1600,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -653,7 +653,7 @@
label="备注" label="备注"
prop="remark" prop="remark"
> >
<el-input <el-input
v-if="!isView" v-if="!isView"
v-model="formQuotation.remark" v-model="formQuotation.remark"
placeholder="请输入备注" placeholder="请输入备注"
@ -1622,13 +1622,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -1684,13 +1684,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -1557,13 +1557,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},
@ -1956,7 +1956,7 @@ export default {
this.formFeedback.omPerson = null; this.formFeedback.omPerson = null;
this.formFeedback.fileId = this.fileList this.formFeedback.fileId = this.fileList
.map((file) => { .map((file) => {
return file.response.fileName; return file.response.data.saveName;
}) })
.join(","); .join(",");
} }
@ -2077,26 +2077,22 @@ export default {
}, },
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
this.fileList = fileList; this.fileList = fileList;
console.log(this.fileList); // this.formFeedback.fileId = this.fileList
this.formFeedback.fileId = this.fileList // .map((file) => {
.map((file) => { // return file.response.data.saveName;
console.log(file); // })
return file.response.fileName; // .join(",");
})
.join(",");
this.$modal.msgSuccess("上传成功"); this.$modal.msgSuccess("上传成功");
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.fileList = fileList; this.fileList = fileList;
this.formFeedback.fileId = this.fileList // this.formFeedback.fileId = this.fileList
.map((file) => { // .map((file) => {
return file.response.fileName; // return file.response.data.saveName;
}) // })
.join(","); // .join(",");
},
handlePreview(file, fileList) {
console.log("--->>预览文件", file);
}, },
handlePreview(file, fileList) {},
// //
/** 查询备件基础维护列表 */ /** 查询备件基础维护列表 */
getSparePartsList() { getSparePartsList() {

View File

@ -1666,13 +1666,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -1642,13 +1642,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},

View File

@ -1643,13 +1643,13 @@ export default {
upload: { upload: {
// //
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// TODO //
url: process.env.VUE_APP_BASE_API + "/common/upload", url: process.env.VUE_APP_BASE_API + "/om/application/upload/file",
// //
imageUrl: "", imageUrl: "",
}, },
fileList: [], fileList: [],
prefix: process.env.VUE_APP_BASE_API, prefix: process.env.VUE_APP_BASE_API + "/om/application/show?saveName=",
path1: null, path1: null,
path2: null, path2: null,
formFeedback: {}, formFeedback: {},