| | |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.business.entity.Product; |
| | | import com.by4cloud.platformx.business.service.ProductService; |
| | | import com.by4cloud.platformx.common.security.annotation.Inner; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | public R getProductPage(@ParameterObject Page page, @ParameterObject Product product) { |
| | | LambdaQueryWrapper<Product> wrapper = Wrappers.lambdaQuery(); |
| | | return R.ok(productService.page(page, wrapper)); |
| | | wrapper.eq(product.getParentId()!=null,Product::getParentId,product.getParentId()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getMainCode()),Product::getMainCode,product.getMainCode()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getErpCode()),Product::getErpCode,product.getErpCode()); |
| | | wrapper.orderByDesc(Product::getCreateTime); |
| | | Page<Product> page1 = productService.pageByScope(page, wrapper); |
| | | List<Product> list = page1.getRecords(); |
| | | for(Product product1 : list){ |
| | | Product parent = productService.getById(product1.getParentId()); |
| | | if(parent==null){ |
| | | product1.setParentName("根级产品"); |
| | | }else { |
| | | product1.setParentName(parent.getProductName()); |
| | | } |
| | | } |
| | | page1.setRecords(list); |
| | | return R.ok(page1); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param product 产品信息 |
| | | * @return |
| | | */ |
| | | @Operation(summary = "分页查询" , description = "分页查询" ) |
| | | @GetMapping("/list" ) |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | @Inner(value = false) |
| | | public R getProductList(@ParameterObject Product product) { |
| | | return R.ok(productService.getProductList(product)); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param product 产品信息 |
| | | * @return |
| | | */ |
| | | @Operation(summary = "分页查询" , description = "分页查询" ) |
| | | @GetMapping("/listByParentId" ) |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | //@Inner(value = false) |
| | | public R getProductListByParentId(@ParameterObject Product product) { |
| | | LambdaQueryWrapper<Product> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()); |
| | | wrapper.eq(product.getParentId()!=null,Product::getParentId,product.getParentId()); |
| | | wrapper.last("limit 30"); |
| | | return R.ok(productService.listByScope(wrapper)); |
| | | } |
| | | |
| | | /** |
| | | * 层级查询 |
| | | * @param product 商品表 |
| | | * @return |
| | | */ |
| | | @Operation(summary = "层级查询" , description = "层级查询" ) |
| | | @GetMapping("/treeList" ) |
| | | //@PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | @Inner(value = false) |
| | | public R getNewsCategoryTree(@ParameterObject Product product) { |
| | | return R.ok(productService.treeList(product.getParentId(), product.getProductName())); |
| | | } |
| | | |
| | | |