提交 b533e6f4 authored 作者: 吴德鹏's avatar 吴德鹏

Merge branch 'dev'

......@@ -31,6 +31,9 @@ public class AddressController extends Controller {
@GetMapping
public Result<Iterable<TbCfAddress>> getUserInfoList() {
if (user.userId() == null) {
return new Result(ResultCodeEnum.UN_LOGIN.getCode(), "need login");
}
Iterable<TbCfAddress> tbCfAddressVoList = repository.findAllByUserId(user.userId(), Sort.by(Sort.Order.desc("defaultFlag"), Sort.Order.asc("createTime")));
return new Result<>(tbCfAddressVoList);
}
......
......@@ -26,7 +26,10 @@ public class CouponController {
//Get coupons list by authenticated user
@GetMapping
public Result getUserCoupons() {
Optional<String> userOptional = Optional.ofNullable(user.userId());
if (user.userId() == null) {
return new Result(ResultCodeEnum.UN_LOGIN.getCode(), "need login");
}
Optional<String> userOptional = Optional.of(user.userId());
if (userOptional.isPresent()) {
return queryCouponByUserId(user.userId());
}
......
......@@ -6,6 +6,7 @@ import com.example.afrishop_v3.models.*;
import com.example.afrishop_v3.repository.*;
import com.example.afrishop_v3.security.services.AuthenticationUser;
import com.example.afrishop_v3.util.OssUtil;
import com.example.afrishop_v3.util.PicUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -24,6 +25,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@RestController
@RequestMapping("/discover/post")
......@@ -271,7 +273,9 @@ public class PostController {
// "serveFile", store.getFileName().toString()).build().toUri().toString();
String string;
try {
string = OssUtil.upload(file,"discover");
byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 70);
string = uploadFile(bytes);
logger.info("缩略图:"+string);
} catch (Exception e) {
System.out.println(e.getMessage());
logger.debug(e.getMessage());
......@@ -291,7 +295,9 @@ public class PostController {
// "serveFile", store.getFileName().toString()).build().toUri().toString();
String string;
try {
string = OssUtil.upload(file,"discover");
byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 70);
string = uploadFile(bytes);
logger.info("图片:"+string);
} catch (Exception e) {
logger.warn(e.getMessage());
continue;
......@@ -406,4 +412,11 @@ public class PostController {
return list;
}
public String uploadFile(byte[] bytes) throws Exception {
long l = System.currentTimeMillis();
String urlName = UUID.randomUUID() + "-" + String.valueOf(l).substring(6) + ".jpg";
return OssUtil.upload(bytes, urlName, "discover");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论