|
|
@@ -10,11 +10,11 @@ public class AddressService {
|
|
|
private final Address dao = new Address().dao();
|
|
|
|
|
|
public List<Address> findByUserId(Long userId) {
|
|
|
- return dao.find("select * from t_address where user_id = ? order by is_default desc, id desc", userId);
|
|
|
+ return dao.find("select * from t_address where user_id = ? and is_deleted = 0 order by is_default desc, id desc", userId);
|
|
|
}
|
|
|
|
|
|
public Address findById(int id, Long userId) {
|
|
|
- return dao.findFirst("select * from t_address where id = ? and user_id = ?", id, userId);
|
|
|
+ return dao.findFirst("select * from t_address where id = ? and user_id = ? and is_deleted = 0", id, userId);
|
|
|
}
|
|
|
|
|
|
public boolean save(Address address) {
|
|
|
@@ -46,10 +46,11 @@ public class AddressService {
|
|
|
public boolean setDefault(int id, Long userId) {
|
|
|
// 开启事务
|
|
|
return Db.tx(() -> {
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
// 先将该用户所有地址设为非默认
|
|
|
- Db.update("update t_address set is_default = 0 where user_id = ?", userId);
|
|
|
+ Db.update("update t_address set is_default = 0, update_time = ? where user_id = ?", currentTime, userId);
|
|
|
// 再将指定地址设为默认
|
|
|
- return Db.update("update t_address set is_default = 1 where id = ? and user_id = ?", id, userId) > 0;
|
|
|
+ return Db.update("update t_address set is_default = 1, update_time = ? where id = ? and user_id = ?", currentTime, id, userId) > 0;
|
|
|
});
|
|
|
}
|
|
|
}
|