| | |
| | | package com.oying.modules.sh.rest; |
| | | |
| | | import com.oying.annotation.Log; |
| | | import com.oying.exception.BadRequestException; |
| | | import com.oying.modules.sh.domain.UserAddress; |
| | | import com.oying.modules.sh.service.UserAddressService; |
| | | import com.oying.modules.sh.domain.dto.UserAddressQueryCriteria; |
| | | import com.oying.utils.R; |
| | | import com.oying.utils.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | import java.util.List; |
| | |
| | | return new ResponseEntity<>(R.success(userAddressService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("mini") |
| | | @ApiOperation("小程序:查询用户地址") |
| | | public ResponseEntity<Object> miniQueryUserAddress(UserAddressQueryCriteria criteria) { |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | criteria.setUserId(SecurityUtils.getCurrentUserId()); |
| | | return new ResponseEntity<>(R.success(userAddressService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增用户地址") |
| | | @ApiOperation("新增用户地址") |
| | | @PreAuthorize("@el.check('userAddress:add')") |
| | | @Log("小程序:新增用户地址") |
| | | @ApiOperation("小程序:新增用户地址") |
| | | public ResponseEntity<Object> createUserAddress(@Validated @RequestBody UserAddress resources) { |
| | | resources.setAddressId(null); |
| | | resources.setUserId(SecurityUtils.getCurrentUserId()); |
| | | userAddressService.create(resources); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.CREATED); |
| | | return new ResponseEntity<>(R.success(resources), HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改用户地址") |
| | | @ApiOperation("修改用户地址") |
| | | @PreAuthorize("@el.check('userAddress:edit')") |
| | | @Log("小程序:修改用户地址") |
| | | @ApiOperation("小程序:修改用户地址") |
| | | public ResponseEntity<Object> updateUserAddress(@Validated @RequestBody UserAddress resources) { |
| | | if (resources.getAddressId() == null) { |
| | | throw new BadRequestException("修改用户地址主键不能为空"); |
| | | } |
| | | userAddressService.update(resources); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除用户地址") |
| | | @ApiOperation("删除用户地址") |
| | | @PreAuthorize("@el.check('userAddress:del')") |
| | | @Log("小程序:删除用户地址") |
| | | @ApiOperation("小程序:删除用户地址") |
| | | public ResponseEntity<Object> deleteUserAddress(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) { |
| | | userAddressService.deleteAll(ids); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |