feat: tool模块基础crud
This commit is contained in:
@@ -1,59 +1,59 @@
|
||||
////
|
||||
//// Source code recreated from a .class file by IntelliJ IDEA
|
||||
//// (powered by FernFlower decompiler)
|
||||
////
|
||||
//package org.nl.common.localStorage.controller;
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
package org.nl.common.localStorage.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.localStorage.service.LocalStorageService;
|
||||
import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.common.pojo.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/localStorage"})
|
||||
@SaIgnore
|
||||
public class LocalStorageController {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
|
||||
@GetMapping
|
||||
public CommonResult<Object> query(@RequestParam String annex) {
|
||||
List<LocalStorage> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(annex)){
|
||||
String[] split = annex.split(",");
|
||||
list = localStorageService.listByIds(Arrays.asList(split));
|
||||
}
|
||||
return CommonResult.data(list);
|
||||
}
|
||||
@PostMapping({"/upload"})
|
||||
public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
LocalStorage localStorage = localStorageService.upload(file);
|
||||
return CommonResult.data(localStorage);
|
||||
}
|
||||
@GetMapping({"/download"})
|
||||
public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public CommonResult delete(@RequestBody Long[] ids) {
|
||||
localStorageService.removeByIds(Arrays.asList(ids));
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
//import cn.dev33.satoken.annotation.SaIgnore;
|
||||
//import jakarta.servlet.http.HttpServletRequest;
|
||||
//import jakarta.servlet.http.HttpServletResponse;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.nl.common.localStorage.service.LocalStorageService;
|
||||
//import org.nl.common.localStorage.service.entity.LocalStorage;
|
||||
//import org.nl.common.pojo.CommonResult;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping({"/api/localStorage"})
|
||||
//@SaIgnore
|
||||
//public class LocalStorageController {
|
||||
//
|
||||
// @Autowired
|
||||
// private LocalStorageService localStorageService;
|
||||
//
|
||||
// @GetMapping
|
||||
// public CommonResult<Object> query(@RequestParam String annex) {
|
||||
// List<LocalStorage> list = new ArrayList<>();
|
||||
// if (StringUtils.isNotEmpty(annex)){
|
||||
// String[] split = annex.split(",");
|
||||
// list = localStorageService.listByIds(Arrays.asList(split));
|
||||
// }
|
||||
// return CommonResult.data(list);
|
||||
// }
|
||||
// @PostMapping({"/upload"})
|
||||
// public CommonResult<Object> upload(@RequestParam MultipartFile file) {
|
||||
// LocalStorage localStorage = localStorageService.upload(file);
|
||||
// return CommonResult.data(localStorage);
|
||||
// }
|
||||
// @GetMapping({"/download"})
|
||||
// public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
// this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @DeleteMapping
|
||||
// public CommonResult delete(@RequestBody Long[] ids) {
|
||||
// localStorageService.removeByIds(Arrays.asList(ids));
|
||||
// return CommonResult.ok();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user