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