Commit 137ec680 authored by lee_mingzhu's avatar lee_mingzhu

Merge remote-tracking branch 'origin/master'

parents b4b412c6 cfb931d6
...@@ -248,8 +248,13 @@ public class InnerController { ...@@ -248,8 +248,13 @@ public class InnerController {
if (userId == null || provinceCode == null || cityCode == null) { if (userId == null || provinceCode == null || cityCode == null) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
Timestamp now = new Timestamp(System.currentTimeMillis()); Address addressObj = addressService.findByUserId(userId);
Address addressObj = new Address(); if (address == null) {
addressObj = new Address();
Timestamp now = new Timestamp(System.currentTimeMillis());
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
}
addressObj.setUserId(userId); addressObj.setUserId(userId);
addressObj.setProvinceCode(provinceCode); addressObj.setProvinceCode(provinceCode);
addressObj.setCityCode(cityCode); addressObj.setCityCode(cityCode);
...@@ -258,9 +263,7 @@ public class InnerController { ...@@ -258,9 +263,7 @@ public class InnerController {
addressObj.setDistrict(district); addressObj.setDistrict(district);
addressObj.setAddress(address); addressObj.setAddress(address);
addressObj.setProvince(province); addressObj.setProvince(province);
addressObj.setCreatedAt(now); addressObj = addressService.save(addressObj);
addressObj.setUpdateAt(now);
addressService.saveAddress(addressObj);
return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj)); return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj));
} }
......
...@@ -8,5 +8,7 @@ import cn.quantgroup.xyqb.entity.Address; ...@@ -8,5 +8,7 @@ import cn.quantgroup.xyqb.entity.Address;
public interface IAddressService { public interface IAddressService {
Address findByUserId(Long userId); Address findByUserId(Long userId);
Address save(Address addressObj);
Address saveAddress(Address address); Address saveAddress(Address address);
} }
...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.Address; ...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.repository.IAddressRepository; import cn.quantgroup.xyqb.repository.IAddressRepository;
import cn.quantgroup.xyqb.service.user.IAddressService; import cn.quantgroup.xyqb.service.user.IAddressService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -22,6 +23,13 @@ public class AddressServiceImpl implements IAddressService { ...@@ -22,6 +23,13 @@ public class AddressServiceImpl implements IAddressService {
return addressRepository.findByUserId(userId); return addressRepository.findByUserId(userId);
} }
@Override
@CacheEvict(value = "addresscache", key = "'address' + #addressObj.userId", cacheManager = "cacheManager")
public Address save(Address addressObj) {
return addressRepository.save(addressObj);
}
@Override @Override
public Address saveAddress(Address address) { public Address saveAddress(Address address) {
return addressRepository.save(address); return addressRepository.save(address);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment