| | |
| | | import com.ruoyi.account.service.TAppUserAddressService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class TAppUserAddressController { |
| | | |
| | | private final TAppUserAddressService appUserAddressService; |
| | | private final TokenService tokenService; |
| | | |
| | | @Autowired |
| | | public TAppUserAddressController(TAppUserAddressService appUserAddressService) { |
| | | public TAppUserAddressController(TAppUserAddressService appUserAddressService, TokenService tokenService) { |
| | | this.appUserAddressService = appUserAddressService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @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))); |
| | | // 用户id |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | return AjaxResult.ok(appUserAddressService.list(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId))); |
| | | } |
| | | |
| | | |
| | |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "添加用户地址") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TAppUserAddress dto) { |
| | | // TODO 用户id |
| | | // 用户id |
| | | dto.setAppUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | // 修改用户默认地址 |
| | | appUserAddressService.updateDefaultAddress(dto.getDefaultAddress(),dto.getAppUserId()); |
| | | return AjaxResult.ok(appUserAddressService.save(dto)); |