Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/bigdata/wxappserver/service/OrderService.java
This commit is contained in:
Cool 2024-09-04 23:28:51 +08:00
commit 5ea1915bae
2 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,9 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
if (order == null) {
return Result.error("参数错误");
}
List<User> userList = userService.list();
User userTemp = userList.stream().filter(e -> Objects.equals(e.getOpenId(), jsonObject.get("openId"))).findFirst().orElse(null);
order.setUserId(userTemp.getId());
if (!StringUtils.hasLength(order.getAddress())) {
User user = userService.getById(order.getUserId());
order.setAddress(user.getAddress());

View File

@ -26,7 +26,8 @@ import java.util.stream.Collectors;
@Service
public class UserService extends ServiceImpl<UserMapper, User> {
private static final String UPLOAD_DIR = "uploads/";
private static final String UPLOAD_DIR = "static/uploads/";
private static final String GET_URL = "uploads/";
@Transactional(rollbackFor = Exception.class)
public JSONObject addOrUpdate(JSONObject jsonObject) {
@ -88,6 +89,9 @@ public class UserService extends ServiceImpl<UserMapper, User> {
List<User> userList = list();
User user = userList.stream().filter(e -> Objects.equals(e.getOpenId(), openId)).findFirst().orElse(null);
if (user == null) {
return new JSONObject().fluentPut("success", false).fluentPut("message", "用户不存在");
}
return new JSONObject().fluentPut("data", user);
}
@ -105,10 +109,11 @@ public class UserService extends ServiceImpl<UserMapper, User> {
// 保存文件到服务器
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
Path path = Paths.get(UPLOAD_DIR + fileName);
Files.createDirectories(path.getParent());
Files.write(path, file.getBytes());
// 构建文件的访问URL
String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/" + UPLOAD_DIR)
.path("/" + GET_URL)
.path(fileName)
.toUriString();
return new JSONObject().fluentPut("success", true).fluentPut("fileDownloadUri", fileDownloadUri);