|
@@ -20,13 +20,12 @@ import com.qiniu.storage.UploadManager;
|
|
import com.qiniu.storage.model.DefaultPutRet;
|
|
import com.qiniu.storage.model.DefaultPutRet;
|
|
import com.qiniu.util.Auth;
|
|
import com.qiniu.util.Auth;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
-import org.springframework.context.annotation.PropertySource;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@RequestMapping("/setmeal")
|
|
@RequestMapping("/setmeal")
|
|
@RestController
|
|
@RestController
|
|
@@ -44,6 +43,9 @@ public class SetmealController {
|
|
@Value("${setmeal.upload.imageprefix}")
|
|
@Value("${setmeal.upload.imageprefix}")
|
|
private String uploadImagePrefix;
|
|
private String uploadImagePrefix;
|
|
|
|
|
|
|
|
+ @Value("setmeal.upload.delete.imageprefix")
|
|
|
|
+ private String uploadDeleteImagePrefix;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
RedisService redisService;
|
|
RedisService redisService;
|
|
|
|
|
|
@@ -53,6 +55,9 @@ public class SetmealController {
|
|
@PostMapping("/add.do")
|
|
@PostMapping("/add.do")
|
|
public Result add(@RequestBody TSetmeal setmeal, @RequestParam Integer[] travelgroupIds){
|
|
public Result add(@RequestBody TSetmeal setmeal, @RequestParam Integer[] travelgroupIds){
|
|
int i = setmealService.add( setmeal, travelgroupIds );
|
|
int i = setmealService.add( setmeal, travelgroupIds );
|
|
|
|
+
|
|
|
|
+ //我们在这里记录删除的图片
|
|
|
|
+ redisService.sAdd(uploadDeleteImagePrefix, setmeal.getImg());
|
|
return Result.ok();
|
|
return Result.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -69,7 +74,8 @@ public class SetmealController {
|
|
|
|
|
|
@PostMapping("/upload.do")
|
|
@PostMapping("/upload.do")
|
|
public Result upload(MultipartFile file){
|
|
public Result upload(MultipartFile file){
|
|
- String originalFilename = file.getOriginalFilename();
|
|
|
|
|
|
+ String fileName = UUID.randomUUID().toString();
|
|
|
|
+ String originalFilename = fileName + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
try {
|
|
try {
|
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,
|
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,
|
|
@@ -87,7 +93,7 @@ public class SetmealController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//把图片暂时存储在 Redis 中
|
|
//把图片暂时存储在 Redis 中
|
|
- redisService.lPush(uploadImagePrefix, originalFilename);
|
|
|
|
|
|
+ redisService.sAdd(uploadImagePrefix, originalFilename);
|
|
return Result.data(originalFilename);
|
|
return Result.data(originalFilename);
|
|
}
|
|
}
|
|
|
|
|