| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public AjaxResult<TAppUserAddress> queryDefaultAddress() { |
| | | // 用户id |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | return AjaxResult.ok(appUserAddressService.getOne(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId) |
| | | .eq(TAppUserAddress::getDefaultAddress,1))); |
| | | TAppUserAddress appUserAddress = appUserAddressService.getOne(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId) |
| | | .eq(TAppUserAddress::getDefaultAddress, 1)); |
| | | if(Objects.isNull(appUserAddress)){ |
| | | return AjaxResult.success(); |
| | | } |
| | | appUserAddress.setUid(appUserAddress.getId().toString()); |
| | | return AjaxResult.success(appUserAddress); |
| | | } |
| | | |
| | | |
| | |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "修改用户地址") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TAppUserAddress dto) { |
| | | // 用户id |
| | | dto.setAppUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | // 修改用户默认地址 |
| | | appUserAddressService.updateDefaultAddress(dto.getDefaultAddress(),dto.getAppUserId()); |
| | | return AjaxResult.ok(appUserAddressService.updateById(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 通过地址id 查询地址信息 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "查询用户地址详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TAppUserAddress> getDetailById(@RequestParam(value = "id")Long id) { |
| | | TAppUserAddress byId = appUserAddressService.getById(id); |
| | | byId.setUid(byId.getId().toString()); |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "删除用户地址") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam("id") Integer id) { |
| | | public AjaxResult<Boolean> deleteById(@RequestParam("id") Long id) { |
| | | return AjaxResult.ok(appUserAddressService.removeById(id)); |
| | | } |
| | | |