New file |
| | |
| | | package com.oying.modules.pc.product.rest; |
| | | |
| | | import com.oying.annotation.Log; |
| | | import com.oying.utils.R; |
| | | import com.oying.modules.pc.product.domain.Product; |
| | | import com.oying.modules.pc.product.service.ProductService; |
| | | import com.oying.modules.pc.product.domain.dto.ProductQueryCriteria; |
| | | import lombok.RequiredArgsConstructor; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.oying.utils.PageResult; |
| | | |
| | | /** |
| | | * @author lzp |
| | | * @date 2025-04-30 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "商品") |
| | | @RequestMapping("/api/product") |
| | | public class ProductController { |
| | | |
| | | private final ProductService productService; |
| | | |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('product:list')") |
| | | public void exportProduct(HttpServletResponse response, ProductQueryCriteria criteria) throws IOException { |
| | | productService.download(productService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @ApiOperation("查询商品") |
| | | @PreAuthorize("@el.check('product:list')") |
| | | public R<PageResult<Product>> queryProduct(ProductQueryCriteria criteria){ |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | return R.success(productService.queryAll(criteria,page)); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增商品") |
| | | @ApiOperation("新增商品") |
| | | @PreAuthorize("@el.check('product:add')") |
| | | public R<?> createProduct(@Validated @RequestBody Product resources){ |
| | | productService.create(resources); |
| | | return R.success(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改商品") |
| | | @ApiOperation("修改商品") |
| | | @PreAuthorize("@el.check('product:edit')") |
| | | public R<?> updateProduct(@Validated @RequestBody Product resources){ |
| | | productService.update(resources); |
| | | return R.success(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除商品") |
| | | @ApiOperation("删除商品") |
| | | @PreAuthorize("@el.check('product:del')") |
| | | public R<?> deleteProduct(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) { |
| | | productService.deleteAll(ids); |
| | | return R.success(); |
| | | } |
| | | } |