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

地址优化

上级 c3d30f3b
...@@ -12,6 +12,7 @@ import org.springframework.data.domain.Sort; ...@@ -12,6 +12,7 @@ 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.Date;
import java.util.List;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
...@@ -126,6 +127,10 @@ public class AddressController extends Controller { ...@@ -126,6 +127,10 @@ public class AddressController extends Controller {
} }
repository.delete(address); repository.delete(address);
Integer count = repository.countAllByUserId(user.getUserId());
if (count == 1) {
repository.updateAddress(user.getUserId());
}
} }
return new Result<>(); return new Result<>();
} }
......
...@@ -24,9 +24,14 @@ public interface TbCfAddressRepository extends PagingAndSortingRepository<TbCfAd ...@@ -24,9 +24,14 @@ public interface TbCfAddressRepository extends PagingAndSortingRepository<TbCfAd
boolean existsByUserId(String userId); boolean existsByUserId(String userId);
TbCfAddress findFirstByUserIdAndDefaultFlag(String userId,Integer flag); TbCfAddress findFirstByUserIdAndDefaultFlag(String userId, Integer flag);
Integer countAllByUserId(String userId); Integer countAllByUserId(String userId);
@Transactional
@Modifying
@Query(value = "update tb_cf_address set default_flag=1 where user_id=:user_id", nativeQuery = true)
int updateAddress(@Param("user_id") String userId);
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论