| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | @GetMapping("/getAddressList") |
| | | public R<?> getAddressList() { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | List<TbAddress> list = addressService.list(new LambdaQueryWrapper<TbAddress>().eq(TbAddress::getUserId, userId).eq(TbAddress::getIsDelete, 0).orderByDesc(TbAddress::getCreateTime)); |
| | | return R.ok(list); |
| | |
| | | @PostMapping("/updateUserAddress") |
| | | public R<?> updateUserAddress(@RequestBody @Valid TbAddress tbAddress) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | tbAddress.setUserId(userId.toString()); |
| | | tbAddress.setIsDelete(0); |