|
@@ -28,7 +28,7 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean defaultAddress(TAddress tAddress) {
|
|
|
- if(StringUtils.isBlank(tAddress.getOpenid())){
|
|
|
+ if (StringUtils.isBlank(tAddress.getOpenid())) {
|
|
|
throw new RuntimeException("openid不能为空");
|
|
|
}
|
|
|
TAddress oldAddress = this.getByOpenId(tAddress.getOpenid());
|
|
@@ -39,5 +39,36 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
tAddress.setType(1);
|
|
|
return this.updateById(tAddress);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object insertAddress(TAddress tAddress) {
|
|
|
+ if (StringUtils.isBlank(tAddress.getOpenid())) {
|
|
|
+ throw new RuntimeException("openid不能为空");
|
|
|
+ }
|
|
|
+ //查询默认地址
|
|
|
+ TAddress oldAddress = this.getByOpenId(tAddress.getOpenid());
|
|
|
+ tAddress.setType(1);
|
|
|
+ if (oldAddress != null) {
|
|
|
+ tAddress.setType(0);
|
|
|
+ }
|
|
|
+ return this.save(tAddress);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object updateAddress(TAddress tAddress) {
|
|
|
+ if (StringUtils.isBlank(tAddress.getOpenid())) {
|
|
|
+ throw new RuntimeException("openid不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(tAddress.getId())) {
|
|
|
+ throw new RuntimeException("地址id不能为空");
|
|
|
+ }
|
|
|
+ //查询默认地址
|
|
|
+ TAddress oldAddress = this.getByOpenId(tAddress.getOpenid());
|
|
|
+ tAddress.setType(1);
|
|
|
+ if (oldAddress != null) {
|
|
|
+ tAddress.setType(0);
|
|
|
+ }
|
|
|
+ return this.updateById(tAddress);
|
|
|
+ }
|
|
|
}
|
|
|
|