Commit efae1fd5 authored by zhouqian's avatar zhouqian

增加修改接口

parent 803d5ac4
......@@ -245,8 +245,13 @@ public class InnerController {
if (userId == null || provinceCode == null || cityCode == null) {
return JsonResult.buildErrorStateResult(null, null);
}
Address addressObj = addressService.findByUserId(userId);
if (address == null) {
addressObj = new Address();
Timestamp now = new Timestamp(System.currentTimeMillis());
Address addressObj = new Address();
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
}
addressObj.setUserId(userId);
addressObj.setProvinceCode(provinceCode);
addressObj.setCityCode(cityCode);
......@@ -255,8 +260,7 @@ public class InnerController {
addressObj.setDistrict(district);
addressObj.setAddress(address);
addressObj.setProvince(province);
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
addressObj = addressService.save(addressObj);
return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj));
}
......
......@@ -8,4 +8,6 @@ import cn.quantgroup.xyqb.entity.Address;
public interface IAddressService {
Address findByUserId(Long userId);
Address save(Address addressObj);
}
......@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.repository.IUserExtInfoRepository;
import cn.quantgroup.xyqb.service.user.IAddressService;
import cn.quantgroup.xyqb.service.user.IUserExtInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
......@@ -25,4 +26,11 @@ 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);
}
}
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