提交 ffe04e39 authored 作者: Whispa's avatar Whispa

commit commit

上级 813159b5
...@@ -8,8 +8,10 @@ import com.example.afrishop_v3.models.TbCfUserInfo; ...@@ -8,8 +8,10 @@ import com.example.afrishop_v3.models.TbCfUserInfo;
import com.example.afrishop_v3.repository.TbCfAddressRepository; import com.example.afrishop_v3.repository.TbCfAddressRepository;
import com.example.afrishop_v3.repository.UserRepository; import com.example.afrishop_v3.repository.UserRepository;
import com.example.afrishop_v3.security.services.AuthenticationUser; import com.example.afrishop_v3.security.services.AuthenticationUser;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
...@@ -27,7 +29,7 @@ public class AddressController extends Controller{ ...@@ -27,7 +29,7 @@ public class AddressController extends Controller{
@GetMapping @GetMapping
public Result<Iterable<TbCfAddress>> getUserInfoList() { public Result<Iterable<TbCfAddress>> getUserInfoList() {
Iterable<TbCfAddress> tbCfAddressVoList = repository.findAllByUserId(user.userId()); Iterable<TbCfAddress> tbCfAddressVoList = repository.findAllByUserId(user.userId(), Sort.by(Sort.Order.desc("defaultFlag"), Sort.Order.asc("createTime")));
return new Result<>(tbCfAddressVoList); return new Result<>(tbCfAddressVoList);
} }
...@@ -49,14 +51,13 @@ public class AddressController extends Controller{ ...@@ -49,14 +51,13 @@ public class AddressController extends Controller{
address.setAddressDetail(address.getAddressDetail().trim()); address.setAddressDetail(address.getAddressDetail().trim());
address.setUserId(userId); address.setUserId(userId);
address.setCreateTime(new Date());
address.setAddressId(uid()); address.setAddressId(uid());
TbCfAddress save = repository.save(address); TbCfAddress save = repository.save(address);
save.setDefaultFlag(StateConstant.VALID); //configDefaultAddress(save.getAddressId());
configDefaultAddress(save.getAddressId());
return new Result<>(save); return new Result<>(save);
} }
...@@ -83,6 +84,7 @@ public class AddressController extends Controller{ ...@@ -83,6 +84,7 @@ public class AddressController extends Controller{
address.setAddressDetail(address.getAddressDetail().trim()); address.setAddressDetail(address.getAddressDetail().trim());
address.setAddressId(addressId); address.setAddressId(addressId);
address.setUpdateTime(new Date());
address.setUserId(userId); address.setUserId(userId);
return new Result<>(repository.save(address)); return new Result<>(repository.save(address));
} }
......
...@@ -598,8 +598,8 @@ public class AuthController extends Controller { ...@@ -598,8 +598,8 @@ public class AuthController extends Controller {
Integer sentCount = user.getSentCount(); Integer sentCount = user.getSentCount();
if (sentCount == null) { if (sentCount == null) {
user.setSentCount(3); user.setSentCount(-1);
sentCount = 3; sentCount = 1;
} }
Date date = new Date(); Date date = new Date();
......
package com.example.afrishop_v3.repository; package com.example.afrishop_v3.repository;
import com.example.afrishop_v3.models.TbCfAddress; import com.example.afrishop_v3.models.TbCfAddress;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
...@@ -10,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -10,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
public interface TbCfAddressRepository extends PagingAndSortingRepository<TbCfAddress,String> { public interface TbCfAddressRepository extends PagingAndSortingRepository<TbCfAddress,String> {
List<TbCfAddress> findAllByUserId(String userId); List<TbCfAddress> findAllByUserId(String userId, Sort sort);
@Transactional @Transactional
@Modifying @Modifying
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论