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 1647582..62513f7 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 @@ -39,4 +39,13 @@ public class UserinfoShippingAddress extends JPABasePojo { @ApiModelProperty(value = "用户id") private String userId; + @ApiModelProperty(value = "省份id") + private Integer provinceId; + + @ApiModelProperty(value = "城市id") + private Integer cityId; + + @ApiModelProperty(value = "县区id") + private Integer districtId; + } 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 463155d..7145f7c 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 @@ -1,5 +1,6 @@ package com.luoo.user.service; +import com.luoo.user.dao.RegionDao; import com.luoo.user.dao.UserinfoShippingAddressDao; import com.luoo.user.dto.userinfo.UserinfoShippingAddressAddDTO; import com.luoo.user.dto.userinfo.UserinfoShippingAddressUpdateDTO; @@ -35,11 +36,14 @@ public class UserinfoShippingAddressService { private final JPAQueryFactory jpaQueryFactory; - public UserinfoShippingAddressService(JwtUtil jwtUtil, IdWorker idWorker, UserinfoShippingAddressDao userinfoShippingAddressDao, JPAQueryFactory jpaQueryFactory) { + private final RegionDao regionDao; + + public UserinfoShippingAddressService(JwtUtil jwtUtil, IdWorker idWorker, UserinfoShippingAddressDao userinfoShippingAddressDao, JPAQueryFactory jpaQueryFactory, RegionDao regionDao) { this.jwtUtil = jwtUtil; this.idWorker = idWorker; this.userinfoShippingAddressDao = userinfoShippingAddressDao; this.jpaQueryFactory = jpaQueryFactory; + this.regionDao = regionDao; } /** @@ -52,13 +56,22 @@ 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.acquiesce, + qUserinfoShippingAddress.provinceId, + qUserinfoShippingAddress.cityId, + qUserinfoShippingAddress.districtId )).from(qUserinfoShippingAddress). where(qUserinfoShippingAddress.userId.eq(user.getUserId())) .fetch(); + fetch.forEach(item -> { + item.setProvinceRegion(item.getProvinceId() == null ? null : regionDao.getOne(item.getProvinceId())); + item.setCityRegion(item.getCityId() == null ? null : regionDao.getOne(item.getCityId())); + item.setDistrictRegion(item.getDistrictRegion() == null ? null : regionDao.getOne(item.getDistrictId())); + }); + 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 5fbd8fe..6c4b029 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 @@ -1,5 +1,6 @@ package com.luoo.user.vo.userinfo; +import com.luoo.user.pojo.Region; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; @@ -26,4 +27,30 @@ public class UserinfoShippingAddressAppVO implements Serializable { @ApiModelProperty(value = "是否默认地址 1-是 2-否") Integer acquiesce; + @ApiModelProperty(value = "省份id") + Integer provinceId; + + @ApiModelProperty(value = "城市id") + Integer cityId; + + @ApiModelProperty(value = "县区id") + Integer districtId; + + @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) { + this.id = id; + this.address = address; + this.acquiesce = acquiesce; + this.provinceId = provinceId; + this.cityId = cityId; + this.districtId = districtId; + } } diff --git a/luoo_user/src/main/resources/sql/20241024.sql b/luoo_user/src/main/resources/sql/20241024.sql new file mode 100644 index 0000000..3b41aad --- /dev/null +++ b/luoo_user/src/main/resources/sql/20241024.sql @@ -0,0 +1,9 @@ +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 + add district_id int null comment '区id'; +