Compare commits
No commits in common. "86121952c5108b4193d7f520a6311d9efd0322f3" and "fccdb9c8edeac721098bc2a646f8fe88aa3a1507" have entirely different histories.
86121952c5
...
fccdb9c8ed
|
@ -46,21 +46,14 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
|
|||
if (order == null) {
|
||||
return new JSONObject().fluentPut("success", false).fluentPut("message", "参数错误");
|
||||
}
|
||||
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());
|
||||
}
|
||||
// TODO 判空
|
||||
boolean success = saveOrUpdate(order);
|
||||
|
||||
if (success) {
|
||||
return new JSONObject().fluentPut("message", "success").fluentPut("success", success).fluentPut("id", order.getId().toString());
|
||||
} else {
|
||||
return new JSONObject().fluentPut("message", "failure").fluentPut("success", success);
|
||||
} }
|
||||
return new JSONObject().fluentPut("message", "success").fluentPut("success", success);
|
||||
}
|
||||
|
||||
public JSONObject list(JSONObject jsonObject) {
|
||||
String openId = jsonObject.getString("openId");
|
||||
|
|
|
@ -26,8 +26,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
@Service
|
||||
public class UserService extends ServiceImpl<UserMapper, User> {
|
||||
private static final String UPLOAD_DIR = "static/uploads/";
|
||||
private static final String GET_URL = "uploads/";
|
||||
private static final String UPLOAD_DIR = "uploads/";
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject addOrUpdate(JSONObject jsonObject) {
|
||||
|
@ -89,9 +88,6 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -109,11 +105,10 @@ 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("/" + GET_URL)
|
||||
.path("/" + UPLOAD_DIR)
|
||||
.path(fileName)
|
||||
.toUriString();
|
||||
return new JSONObject().fluentPut("success", true).fluentPut("fileDownloadUri", fileDownloadUri);
|
||||
|
|
Loading…
Reference in New Issue