- 添加获取默认地址
parent
22d736050d
commit
90416d5431
|
@ -65,8 +65,15 @@ public class UserAddressController {
|
|||
|
||||
@GetMapping("address")
|
||||
@ApiOperation(value = "获取地址")
|
||||
public CommonResult getAddress(@RequestParam("id") Integer id) {
|
||||
public CommonResult<UserAddressBO> getAddress(@RequestParam("id") Integer id) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
return userAddressService.getAddress(userId, id);
|
||||
}
|
||||
|
||||
@GetMapping("default_address")
|
||||
@ApiOperation(value = "获取默认地址")
|
||||
public CommonResult<UserAddressBO> getDefaultAddress() {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
return userAddressService.getDefaultAddress(userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,4 +24,6 @@ public interface UserAddressService {
|
|||
CommonResult<List<UserAddressBO>> addressList(Integer userId);
|
||||
|
||||
CommonResult<UserAddressBO> getAddress(Integer userId, Integer id);
|
||||
|
||||
CommonResult<UserAddressBO> getDefaultAddress(Integer userId);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ public class UserAddressServiceImpl implements UserAddressService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(
|
||||
DeletedStatusEnum.DELETED_NO.getValue(),
|
||||
userAddressAddDTO.getUserId(), UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue());
|
||||
|
@ -149,4 +148,15 @@ public class UserAddressServiceImpl implements UserAddressService {
|
|||
UserAddressBO userAddressBO = UserAddressConvert.INSTANCE.convert(userAddress);
|
||||
return CommonResult.success(userAddressBO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<UserAddressBO> getDefaultAddress(Integer userId) {
|
||||
|
||||
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(
|
||||
DeletedStatusEnum.DELETED_NO.getValue(),
|
||||
userId,
|
||||
UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue());
|
||||
|
||||
return CommonResult.success(UserAddressConvert.INSTANCE.convert(defaultUserAddress));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
<sql id="FIELDS">
|
||||
id, user_id, area_no, `name`, mobile, address,
|
||||
create_time, update_time, deleted
|
||||
create_time, update_time, has_default, deleted
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="UserAddressDO" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO user_address (
|
||||
user_id, area_no, `name`, mobile, address,
|
||||
create_time, update_time, deleted
|
||||
create_time, update_time, has_default, deleted
|
||||
) VALUES (
|
||||
#{userId}, #{areaNo}, #{name}, #{mobile}, #{address},
|
||||
#{createTime}, #{updateTime}, #{deleted}
|
||||
#{createTime}, #{updateTime}, #{hasDefault}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
@ -35,6 +35,9 @@
|
|||
<if test="userAddressDO.updateTime != null">
|
||||
, update_time = #{userAddressDO.updateTime}
|
||||
</if>
|
||||
<if test="userAddressDO.hasDefault != null">
|
||||
, has_default = #{userAddressDO.hasDefault}
|
||||
</if>
|
||||
<if test="userAddressDO.deleted != null">
|
||||
, deleted = #{userAddressDO.deleted}
|
||||
</if>
|
||||
|
|
Loading…
Reference in New Issue