diff --git a/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressAddDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressAddDTO.java index 45afd95..c093c34 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressAddDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressAddDTO.java @@ -25,22 +25,13 @@ public class UserinfoShippingAddressAddDTO implements Serializable { Integer acquiesce; @ApiModelProperty(value = "省") - String provinceName; + Integer provinceId; @ApiModelProperty(value = "市") - String cityName; + Integer cityId; @ApiModelProperty(value = "区") - String districtName; - - @ApiModelProperty(value = "省编码") - String provinceCode; - - @ApiModelProperty(value = "市编码") - String cityCode; - - @ApiModelProperty(value = "区编码") - String districtCode; + Integer districtId; @ApiModelProperty(value = "收货人") String consignee; diff --git a/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressUpdateDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressUpdateDTO.java index 9fc00a6..8fea814 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressUpdateDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/userinfo/UserinfoShippingAddressUpdateDTO.java @@ -30,22 +30,13 @@ public class UserinfoShippingAddressUpdateDTO implements Serializable { Integer acquiesce; @ApiModelProperty(value = "省") - String provinceName; + Integer provinceId; @ApiModelProperty(value = "市") - String cityName; + Integer cityId; @ApiModelProperty(value = "区") - String districtName; - - @ApiModelProperty(value = "省编码") - String provinceCode; - - @ApiModelProperty(value = "市编码") - String cityCode; - - @ApiModelProperty(value = "区编码") - String districtCode; + Integer districtId; @ApiModelProperty(value = "收货人") String consignee; diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/UserinfoShippingAddress.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserinfoShippingAddress.java index 3d67f58..eb73b92 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/UserinfoShippingAddress.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserinfoShippingAddress.java @@ -40,22 +40,13 @@ public class UserinfoShippingAddress extends JPABasePojo { private String userId; @ApiModelProperty(value = "省") - private String provinceName; + private Integer provinceId; @ApiModelProperty(value = "市") - private String cityName; + private Integer cityId; @ApiModelProperty(value = "区") - private String districtName; - - @ApiModelProperty(value = "省编码") - private String provinceCode; - - @ApiModelProperty(value = "市编码") - private String cityCode; - - @ApiModelProperty(value = "区编码") - private String districtCode; + private Integer districtId; @ApiModelProperty(value = "收货人") private String consignee; diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserinfoShippingAddressService.java b/luoo_user/src/main/java/com/luoo/user/service/UserinfoShippingAddressService.java index ca09889..7fdc627 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserinfoShippingAddressService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserinfoShippingAddressService.java @@ -56,19 +56,24 @@ public class UserinfoShippingAddressService { QUserinfoShippingAddress qUserinfoShippingAddress = QUserinfoShippingAddress.userinfoShippingAddress; - return jpaQueryFactory.select(Projections.constructor(UserinfoShippingAddressAppVO.class, + List fetch = jpaQueryFactory.select(Projections.constructor(UserinfoShippingAddressAppVO.class, qUserinfoShippingAddress.id, qUserinfoShippingAddress.address, qUserinfoShippingAddress.acquiesce, - qUserinfoShippingAddress.provinceName, - qUserinfoShippingAddress.cityName, - qUserinfoShippingAddress.districtName, - qUserinfoShippingAddress.provinceCode, - qUserinfoShippingAddress.cityCode, - qUserinfoShippingAddress.districtCode + qUserinfoShippingAddress.provinceId, + qUserinfoShippingAddress.cityId, + qUserinfoShippingAddress.districtId, + qUserinfoShippingAddress.consignee, + qUserinfoShippingAddress.phone )).from(qUserinfoShippingAddress). where(qUserinfoShippingAddress.userId.eq(user.getUserId())) .fetch(); + fetch.forEach(item -> { + item.setProvinceRegion(item.getProvinceId() != null ? regionDao.getOne(item.getProvinceId()) : null); + item.setCityRegion(item.getCityId() != null ? regionDao.getOne(item.getCityId()) : null); + item.setDistrictRegion(item.getDistrictId() != null ? regionDao.getOne(item.getDistrictId()) : null); + }); + return fetch; } @Transactional(rollbackFor = Exception.class) diff --git a/luoo_user/src/main/java/com/luoo/user/vo/userinfo/UserinfoShippingAddressAppVO.java b/luoo_user/src/main/java/com/luoo/user/vo/userinfo/UserinfoShippingAddressAppVO.java index a767c18..bcfaa13 100644 --- a/luoo_user/src/main/java/com/luoo/user/vo/userinfo/UserinfoShippingAddressAppVO.java +++ b/luoo_user/src/main/java/com/luoo/user/vo/userinfo/UserinfoShippingAddressAppVO.java @@ -28,22 +28,13 @@ public class UserinfoShippingAddressAppVO implements Serializable { Integer acquiesce; @ApiModelProperty(value = "省") - String provinceName; + Integer provinceId; @ApiModelProperty(value = "市") - String cityName; + Integer cityId; @ApiModelProperty(value = "区") - String districtName; - - @ApiModelProperty(value = "省编码") - String provinceCode; - - @ApiModelProperty(value = "市编码") - String cityCode; - - @ApiModelProperty(value = "区编码") - String districtCode; + Integer districtId; @ApiModelProperty(value = "收货人") String consignee; @@ -51,4 +42,23 @@ public class UserinfoShippingAddressAppVO implements Serializable { @ApiModelProperty(value = "联系电话") String phone; + @ApiModelProperty(value = "省") + Region provinceRegion; + + @ApiModelProperty(value = "市") + Region cityRegion; + + @ApiModelProperty(value = "区") + Region districtRegion; + + public UserinfoShippingAddressAppVO(String id, String address, Integer acquiesce, Integer provinceId, Integer cityId, Integer districtId, String consignee, String phone) { + this.id = id; + this.address = address; + this.acquiesce = acquiesce; + this.provinceId = provinceId; + this.cityId = cityId; + this.districtId = districtId; + this.consignee = consignee; + this.phone = phone; + } } diff --git a/luoo_user/src/main/resources/sql/20241104.sql b/luoo_user/src/main/resources/sql/20241104.sql new file mode 100644 index 0000000..03d6aa3 --- /dev/null +++ b/luoo_user/src/main/resources/sql/20241104.sql @@ -0,0 +1,27 @@ +alter table tb_userinfo_shipping_address + drop column province_name; + +alter table tb_userinfo_shipping_address + drop column city_name; + +alter table tb_userinfo_shipping_address + drop column district_name; + +alter table tb_userinfo_shipping_address + add province_id int null comment '省id'; + +alter table tb_userinfo_shipping_address + add city_id int null comment '市id'; + +alter table tb_userinfo_shipping_address + drop column province_code; + +alter table tb_userinfo_shipping_address + drop column city_code; + +alter table tb_userinfo_shipping_address + add district_id int null comment '区id'; + +alter table tb_userinfo_shipping_address + drop column district_code; +