|
|
|
|
@ -37,7 +37,6 @@ import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.modules.jinchao.constant.BaseCol; |
|
|
|
|
import org.springblade.modules.jinchao.constant.ProductConst; |
|
|
|
|
import org.springblade.modules.jinchao.pojo.vo.ProductVO; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
@ -53,7 +52,7 @@ import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
@ -79,7 +78,8 @@ public class ProductController extends BladeController { |
|
|
|
|
@Operation(summary = "详情", description = "传入product") |
|
|
|
|
public R<ProductVO> detail(ProductEntity product) { |
|
|
|
|
ProductEntity detail = service.getOne(Condition.getQueryWrapper(product)); |
|
|
|
|
return R.data(ProductWrapper.build().entityVO(detail)); |
|
|
|
|
ProductVO vo = ProductWrapper.build().entityVO(detail); |
|
|
|
|
return R.data(vo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -90,7 +90,7 @@ public class ProductController extends BladeController { |
|
|
|
|
@Operation(summary = "list分页", description = "传入product") |
|
|
|
|
public R<IPage<ProductVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> product, |
|
|
|
|
Query query) { |
|
|
|
|
return service.list(product,query); |
|
|
|
|
return service.list(product, query); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -100,7 +100,7 @@ public class ProductController extends BladeController { |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@Operation(summary = "page分页", description = "传入product") |
|
|
|
|
public R<IPage<ProductVO>> page(ProductVO product, Query query) { |
|
|
|
|
IPage<ProductVO> pages = service.selectProductPage(Condition.getPage(query), product); |
|
|
|
|
IPage<org.springblade.modules.jinchao.pojo.vo.ProductVO> pages = service.selectProductPage(Condition.getPage(query), product); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -110,9 +110,15 @@ public class ProductController extends BladeController { |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
@Operation(summary = "新增", description = "传入product") |
|
|
|
|
public R save(@Valid @RequestBody ProductEntity product) { |
|
|
|
|
product.setId(null); |
|
|
|
|
return R.status(service.save(product)); |
|
|
|
|
public R save(@Valid @RequestBody ProductVO vo) { |
|
|
|
|
vo.setId(null); |
|
|
|
|
if (service.existsCode(vo.getCode())) { |
|
|
|
|
return R.fail("已经存在此code"); |
|
|
|
|
} |
|
|
|
|
if (service.existsNameCn(vo.getNameCn())) { |
|
|
|
|
return R.fail("已经存在此nameCn"); |
|
|
|
|
} |
|
|
|
|
return R.status(service.save(vo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -126,20 +132,53 @@ public class ProductController extends BladeController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* [产品] 新增或修改 |
|
|
|
|
* [产品] 单条新增或修改 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submit") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@Operation(summary = "新增或修改", description = "传入product") |
|
|
|
|
public R submit(@Valid @RequestBody ProductEntity product) { |
|
|
|
|
return R.status(service.saveOrUpdate(product)); |
|
|
|
|
public R submit(@Valid @RequestBody ProductVO vo) { |
|
|
|
|
if (vo.getId() == null || vo.getId() == 0L) { |
|
|
|
|
if (service.existsCode(vo.getCode())) { |
|
|
|
|
return R.fail("已经存在此code"); |
|
|
|
|
} |
|
|
|
|
if (service.existsNameCn(vo.getNameCn())) { |
|
|
|
|
return R.fail("已经存在此nameCn"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (Objects.equals(vo.getBizType(), ProductConst.TYPE_PRICE_CUSTOM)) { |
|
|
|
|
// 跳过
|
|
|
|
|
return R.fail("bizType类型错误"); |
|
|
|
|
} |
|
|
|
|
return R.status(service.saveOrUpdate(vo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/submitBat") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@Operation(summary = "批量新增或修改", description = "ProductEntity List") |
|
|
|
|
public R submit(@Valid @RequestBody List<ProductEntity> products) { |
|
|
|
|
return R.status(service.saveOrUpdateBatch(products)); |
|
|
|
|
public R submitBat(@Valid @RequestBody List<ProductVO> vos) { |
|
|
|
|
if (vos != null && !vos.isEmpty()) { |
|
|
|
|
for (ProductVO vo : vos) { |
|
|
|
|
if (vo != null && Objects.equals(vo.getBizType(), ProductConst.TYPE_PRICE_CUSTOM)) { |
|
|
|
|
// 跳过
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (Objects.requireNonNull(vo).getId() == null || vo.getId() == 0L) { |
|
|
|
|
// 新增check
|
|
|
|
|
if (service.existsCode(vo.getCode())) { |
|
|
|
|
return R.fail("已经存在此code"); |
|
|
|
|
} |
|
|
|
|
if (service.existsNameCn(vo.getNameCn())) { |
|
|
|
|
return R.fail("已经存在此nameCn"); |
|
|
|
|
} |
|
|
|
|
// 新增
|
|
|
|
|
service.save(vo); |
|
|
|
|
} else { |
|
|
|
|
service.updateById(vo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return R.success(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -158,7 +197,8 @@ public class ProductController extends BladeController { |
|
|
|
|
@GetMapping("/export-product") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@Operation(summary = "导出数据", description = "传入product") |
|
|
|
|
public void exportProduct(@Parameter(hidden = true) @RequestParam Map<String, Object> product, BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
public void exportProduct(@Parameter(hidden = true) @RequestParam Map<String, Object> product, |
|
|
|
|
BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
QueryWrapper<ProductEntity> queryWrapper = Condition.getQueryWrapper(product, ProductEntity.class); |
|
|
|
|
//if (!AuthUtil.isAdministrator()) {
|
|
|
|
|
// queryWrapper.lambda().eq(Product::getTenantId, bladeUser.getTenantId());
|
|
|
|
|
@ -167,4 +207,11 @@ public class ProductController extends BladeController { |
|
|
|
|
List<ProductExcel> list = service.exportProduct(queryWrapper); |
|
|
|
|
ExcelUtil.export(response, "[产品]数据" + DateUtil.time(), "[产品]数据表", list, ProductExcel.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/oneKeyMatch") |
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
@Operation(summary = "一键匹配", description = "") |
|
|
|
|
public R oneKeyMatch(@Parameter(description = "一键匹配", required = true) @Valid @RequestBody List<ProductVO> list) { |
|
|
|
|
return service.oneKeyMatch(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|