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 {
if (userId == null || provinceCode == null || cityCode == null) {
return JsonResult.buildErrorStateResult(null, null);
}
Timestamp now = new Timestamp(System.currentTimeMillis());
Address addressObj = new Address();
Address addressObj = addressService.findByUserId(userId);
if (address == null) {
addressObj = new Address();
Timestamp now = new Timestamp(System.currentTimeMillis());
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
}
addressObj.setUserId(userId);
addressObj.setProvinceCode(provinceCode);
addressObj.setCityCode(cityCode);
......@@ -258,9 +263,7 @@ public class InnerController {
addressObj.setDistrict(district);
addressObj.setAddress(address);
addressObj.setProvince(province);
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
addressService.saveAddress(addressObj);
addressObj = addressService.save(addressObj);
return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj));
}
......
......@@ -8,5 +8,7 @@ import cn.quantgroup.xyqb.entity.Address;
public interface IAddressService {
Address findByUserId(Long userId);
Address save(Address addressObj);
Address saveAddress(Address address);
}
......@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.repository.IAddressRepository;
import cn.quantgroup.xyqb.service.user.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
......@@ -22,6 +23,13 @@ public class AddressServiceImpl implements IAddressService {
return addressRepository.findByUserId(userId);
}
@Override
@CacheEvict(value = "addresscache", key = "'address' + #addressObj.userId", cacheManager = "cacheManager")
public Address save(Address addressObj) {
return addressRepository.save(addressObj);
}
@Override
public Address saveAddress(Address 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