|
@@ -18,6 +18,8 @@ public class AddressService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public boolean save(Address address) {
|
|
public boolean save(Address address) {
|
|
|
|
|
+ address.setIsDeleted(0);
|
|
|
|
|
+
|
|
|
if (address.getIsDefault() == 1) {
|
|
if (address.getIsDefault() == 1) {
|
|
|
// 如果将当前地址设为默认,则将该用户其他地址设为非默认
|
|
// 如果将当前地址设为默认,则将该用户其他地址设为非默认
|
|
|
Db.update("update t_address set is_default = 0 where user_id = ?", address.getUserId());
|
|
Db.update("update t_address set is_default = 0 where user_id = ?", address.getUserId());
|
|
@@ -43,6 +45,10 @@ public class AddressService {
|
|
|
return address.update();
|
|
return address.update();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Address findDefaultByUserId(Long userId) {
|
|
|
|
|
+ return dao.findFirst("select * from t_address where user_id = ? and is_default = 1 and is_deleted = 0", userId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public boolean setDefault(int id, Long userId) {
|
|
public boolean setDefault(int id, Long userId) {
|
|
|
// 开启事务
|
|
// 开启事务
|
|
|
return Db.tx(() -> {
|
|
return Db.tx(() -> {
|