| | |
| | | import com.oying.modules.pc.product.service.ProductImageService; |
| | | import com.oying.modules.pc.product.service.ProductLabelService; |
| | | import com.oying.modules.pc.product.service.ProductService; |
| | | import com.oying.utils.PageResult; |
| | | import com.oying.utils.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | // @PreAuthorize("@el.check('product:list')") |
| | | public ResponseEntity<?> getProductsByPage(ProductQueryCriteria criteria) { |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | return ResponseEntity.ok(R.success(productService.queryAll(criteria, page))); |
| | | PageResult<Product> pageResult = productService.queryAll(criteria, page); |
| | | pageResult.getContent().forEach(product -> { |
| | | Long productId = product.getProductId(); |
| | | product.setImages(productImageService.queryImagesByProductId(productId)); |
| | | product.setLabels(productLabelService.queryLabelsByProductId(productId)); |
| | | }); |
| | | return ResponseEntity.ok(R.success(pageResult)); |
| | | } |
| | | |
| | | @GetMapping(value = "/{productId}}") |
| | |
| | | //@PreAuthorize("@el.check('merchant:product:add')") |
| | | public ResponseEntity<?> createProduct(@Validated @RequestBody ProductMerchantCreateRequest request) { |
| | | productAdminService.create(request); |
| | | return ResponseEntity.noContent().build(); |
| | | return ResponseEntity.status(HttpStatus.CREATED).build(); |
| | | } |
| | | |
| | | @PutMapping |