release: 收货地址新增省市区字段

release-2024-04-25
huangyw 1 month ago
parent da2be28821
commit 362ba6d642

@ -39,4 +39,13 @@ public class UserinfoShippingAddress extends JPABasePojo {
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private String userId; private String userId;
@ApiModelProperty(value = "省份id")
private Integer provinceId;
@ApiModelProperty(value = "城市id")
private Integer cityId;
@ApiModelProperty(value = "县区id")
private Integer districtId;
} }

@ -1,5 +1,6 @@
package com.luoo.user.service; package com.luoo.user.service;
import com.luoo.user.dao.RegionDao;
import com.luoo.user.dao.UserinfoShippingAddressDao; import com.luoo.user.dao.UserinfoShippingAddressDao;
import com.luoo.user.dto.userinfo.UserinfoShippingAddressAddDTO; import com.luoo.user.dto.userinfo.UserinfoShippingAddressAddDTO;
import com.luoo.user.dto.userinfo.UserinfoShippingAddressUpdateDTO; import com.luoo.user.dto.userinfo.UserinfoShippingAddressUpdateDTO;
@ -35,11 +36,14 @@ public class UserinfoShippingAddressService {
private final JPAQueryFactory jpaQueryFactory; 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.jwtUtil = jwtUtil;
this.idWorker = idWorker; this.idWorker = idWorker;
this.userinfoShippingAddressDao = userinfoShippingAddressDao; this.userinfoShippingAddressDao = userinfoShippingAddressDao;
this.jpaQueryFactory = jpaQueryFactory; this.jpaQueryFactory = jpaQueryFactory;
this.regionDao = regionDao;
} }
/** /**
@ -52,13 +56,22 @@ public class UserinfoShippingAddressService {
QUserinfoShippingAddress qUserinfoShippingAddress = QUserinfoShippingAddress.userinfoShippingAddress; QUserinfoShippingAddress qUserinfoShippingAddress = QUserinfoShippingAddress.userinfoShippingAddress;
return jpaQueryFactory.select(Projections.constructor(UserinfoShippingAddressAppVO.class, List<UserinfoShippingAddressAppVO> fetch = jpaQueryFactory.select(Projections.constructor(UserinfoShippingAddressAppVO.class,
qUserinfoShippingAddress.id, qUserinfoShippingAddress.id,
qUserinfoShippingAddress.address, qUserinfoShippingAddress.address,
qUserinfoShippingAddress.acquiesce qUserinfoShippingAddress.acquiesce,
qUserinfoShippingAddress.provinceId,
qUserinfoShippingAddress.cityId,
qUserinfoShippingAddress.districtId
)).from(qUserinfoShippingAddress). )).from(qUserinfoShippingAddress).
where(qUserinfoShippingAddress.userId.eq(user.getUserId())) where(qUserinfoShippingAddress.userId.eq(user.getUserId()))
.fetch(); .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) @Transactional(rollbackFor = Exception.class)

@ -1,5 +1,6 @@
package com.luoo.user.vo.userinfo; package com.luoo.user.vo.userinfo;
import com.luoo.user.pojo.Region;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -26,4 +27,30 @@ public class UserinfoShippingAddressAppVO implements Serializable {
@ApiModelProperty(value = "是否默认地址 1-是 2-否") @ApiModelProperty(value = "是否默认地址 1-是 2-否")
Integer acquiesce; 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;
}
} }

@ -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';
Loading…
Cancel
Save