🎨 模糊查询
All checks were successful
Release / Release (push) Successful in 33s

This commit is contained in:
my_ong 2024-12-18 17:20:37 +08:00
parent 0e4a1e2b73
commit 7d28aab41f

View File

@ -45,7 +45,7 @@ public class MaterialController {
.initialCapacity(10)
.maximumSize(300)
.recordStats()
.build(new CacheLoader<String,String>() {
.build(new CacheLoader<String, String>() {
@Override
@Nonnull
@ -64,18 +64,19 @@ public class MaterialController {
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key) {
boolean hasLike = Strings.isNotBlank(key);
key = String.format("%%%s%%", key);
return materialService.page(Page.of(page, size),Wrappers.<Material>lambdaQuery()
return materialService.page(Page.of(page, size), Wrappers.<Material>lambdaQuery()
.like(hasLike, Material::getName, key)
.or()
.like(hasLike, Material::getCode, key)
.eq(type != null, Material::getType, type)
.or()
.like(hasLike, Material::getType, key)
.orderByDesc(Material::getUpdatedTime));
}
@GetMapping("material/list")
@Operation(summary = "查询所有物料列表")
public List<Material> all(){
public List<Material> all() {
return materialService.list();
}
@ -97,7 +98,7 @@ public class MaterialController {
throw BizException.create("保存物料失败!");
}
} else {
if (materialService.update(material, Wrappers.<Material> lambdaUpdate().eq(Material::getId, material.getId()))) {
if (materialService.update(material, Wrappers.<Material>lambdaUpdate().eq(Material::getId, material.getId()))) {
return material;
} else {
throw BizException.create("更新物料失败!");
@ -133,14 +134,14 @@ public class MaterialController {
// 批量生成条形码
@PostMapping("material/{id}/generate-barcodes")
@Operation(summary = "批量生成条形码")
public List<String> generateBarcodes(@Parameter(description = "物料id", required = true) @PathVariable Long id,
@Parameter(description = "条形码数量", required = true) @RequestParam(name = "count") int count) {
public List<String> generateBarcodes(@Parameter(description = "物料id", required = true) @PathVariable Long id,
@Parameter(description = "条形码数量", required = true) @RequestParam(name = "count") int count) {
List<String> res = new ArrayList<>();
Material byId = materialService.getById(id);
if (byId != null && count > 0) {
String code = byId.getCode();
while (count-- > 0) {
res.add(code + BarcodeUtil.generateBarcode());
res.add(code + BarcodeUtil.generateBarcode());
}
}
log.info("生成条形码成功,条形码列表:{}", res);