| | |
| | | package com.by4cloud.platformx.business.controller; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | 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.business.vo.ProductTreeVo; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.business.entity.Product; |
| | |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | @Inner(value = false) |
| | | public R getProductList(@ParameterObject Product product) { |
| | | LambdaQueryWrapper<Product> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()); |
| | | wrapper.last("limit 20"); |
| | | return R.ok(productService.listByScope(wrapper)); |
| | | return R.ok(productService.getProductList(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)); |
| | | return R.ok(BeanUtil.copyToList(productService.listByScope(wrapper), ProductTreeVo.class)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_product_add')" ) |
| | | public R save(@RequestBody Product product) { |
| | | if (ArrayUtil.isNotEmpty(productService.listByScope(Wrappers.lambdaQuery(product).eq(Product::getErpCode,product.getErpCode())).toArray())){ |
| | | return R.failed("产品Erp编码已存在"); |
| | | } |
| | | return R.ok(productService.save(product)); |
| | | } |
| | | |