| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.model.TAppUserAddress; |
| | | import com.ruoyi.account.service.TAppUserAddressService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-app-user-address") |
| | | public class TAppUserAddressController { |
| | | |
| | | private final TAppUserAddressService appUserAddressService; |
| | | |
| | | @Autowired |
| | | public TAppUserAddressController(TAppUserAddressService appUserAddressService) { |
| | | this.appUserAddressService = appUserAddressService; |
| | | } |
| | | |
| | | /** |
| | | * 查询用户地址列表 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "查询用户地址列表") |
| | | @GetMapping(value = "/queryAddress") |
| | | public AjaxResult<List<TAppUserAddress>> queryAddress() { |
| | | // TODO 用户id |
| | | return AjaxResult.ok(appUserAddressService.list(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, null))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加用户地址管理 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "添加用户地址") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TAppUserAddress dto) { |
| | | // TODO 用户id |
| | | // 修改用户默认地址 |
| | | appUserAddressService.updateDefaultAddress(dto.getDefaultAddress(),dto.getAppUserId()); |
| | | return AjaxResult.ok(appUserAddressService.save(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户地址 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "修改用户地址") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TAppUserAddress dto) { |
| | | // 修改用户默认地址 |
| | | appUserAddressService.updateDefaultAddress(dto.getDefaultAddress(),dto.getAppUserId()); |
| | | return AjaxResult.ok(appUserAddressService.updateById(dto)); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户地址 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "删除用户地址") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | | return AjaxResult.ok(appUserAddressService.removeById(id)); |
| | | } |
| | | |
| | | } |
| | | |