From ad7151b14f2721b0fa40a903c6e65a2c511dd4c5 Mon Sep 17 00:00:00 2001 From: XiaoRuby <3114200645@qq.com> Date: 星期四, 27 七月 2023 15:08:13 +0800 Subject: [PATCH] LIMS管理系统框架-开发7-27第二次标准库完成修改 --- standard-server/src/main/java/com/yuanchu/limslaboratory/controller/ProductController.java | 79 +++++++++++---------------------------- 1 files changed, 22 insertions(+), 57 deletions(-) diff --git a/standard-server/src/main/java/com/yuanchu/limslaboratory/controller/ProductController.java b/standard-server/src/main/java/com/yuanchu/limslaboratory/controller/ProductController.java index 62c8682..48d6c63 100644 --- a/standard-server/src/main/java/com/yuanchu/limslaboratory/controller/ProductController.java +++ b/standard-server/src/main/java/com/yuanchu/limslaboratory/controller/ProductController.java @@ -1,17 +1,17 @@ package com.yuanchu.limslaboratory.controller; -import com.yuanchu.limslaboratory.pojo.Product; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.limslaboratory.service.ProductService; -import com.yuanchu.limslaboratory.utils.JackSonUtil; -import com.yuanchu.limslaboratory.utils.RedisUtil; import com.yuanchu.limslaboratory.vo.Result; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * <p> @@ -21,7 +21,7 @@ * @author 姹熻嫃榈烽洀缃戠粶绉戞妧鏈夐檺鍏徃 * @since 2023-07-17 */ -@Api(tags = "鏍囧噯搴�-->瑙勬牸-->鏌ョ湅-->鐖�-->瀛�") +@Api(tags = "鏍囧噯搴�-->4銆侀」鐩�") @RestController @RequestMapping("/product") public class ProductController { @@ -29,63 +29,28 @@ @Autowired private ProductService productService; - @ApiOperation("娴嬭瘯鏍囧噯妯″潡-->娣诲姞娴嬭瘯鏍囧噯") - @PostMapping("/add") - public Result<?> addProductInformation(@RequestHeader("X-Token") String token, @RequestBody Product product) throws Exception { - Object userMessage = RedisUtil.get(token); - if (!ObjectUtils.isEmpty(userMessage)){ - Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(userMessage), Map.class); - product.setUserId(Integer.parseInt(unmarshal.get("id").toString())); - } else { - return Result.fail("瀵逛笉璧凤紝Token閿欒!"); - } - Integer isProductSuccess = productService.addProductInformation(product); - if (isProductSuccess == 1) { - return Result.success("娣诲姞鐗╂枡銆�"+ product.getName() +"銆戞垚鍔燂紒"); - } - return Result.fail("娣诲姞鐗╂枡銆�"+ product.getName() +"銆戝け璐ワ紒"); - } - - @ApiOperation("鐗╂枡搴�-->鏍规嵁鐗╂枡ID鏌ヨ鎵�鏈夋祴璇曟爣鍑�") - @GetMapping("/list") + @ApiOperation("1銆佸垎椤垫煡璇㈤」鐩�") @ApiImplicitParams(value = { - @ApiImplicitParam(value = "鐗╂枡ID", name = "materialId", dataTypeClass = String.class) + @ApiImplicitParam(name = "pageNo", value = "璧峰椤�", dataTypeClass = Integer.class, required = true), + @ApiImplicitParam(name = "pageSize", value = "姣忎竴椤垫暟閲�", dataTypeClass = Integer.class, required = true), + @ApiImplicitParam(value = "鍘熸潗鏂欑紪鐮�/鍘熸潗鏂欏悕绉�", name = "productCodeOrName", dataTypeClass = String.class) }) - public Result<?> getListProductInformation(Integer materialId) { - List<Map<String, Object>> listMaterialInformation = productService.getListProductInformation(materialId); - return Result.success(listMaterialInformation); + @GetMapping("/page") + public Result<?> pageProductInformation(Integer pageNo, Integer pageSize,String productCodeOrName) { + IPage<Map<String, Object>> maps = productService.pageProductInformation(productCodeOrName, new Page<Objects>(pageNo, pageSize)); + Map<String, Object> map = new HashMap<>(); + map.put("row", maps.getRecords()); + map.put("total", maps.getTotal()); + return Result.success(map); } - @ApiOperation("鐗╂枡搴�-->鏍规嵁娴嬭瘯鏍囧噯ID鏌ヨ鍩烘湰淇℃伅") - @GetMapping("/delete") + @ApiOperation("2銆佹牴鎹埗绫绘煡瀛愮被") @ApiImplicitParams(value = { - @ApiImplicitParam(value = "娴嬭瘯鏍囧噯ID", name = "productId", dataTypeClass = String.class) + @ApiImplicitParam(value = "鐖剁被鍚嶇О", name = "fatherName", dataTypeClass = String.class) }) - public Result<?> getProductInformation(Integer productId) { - Map<String, Object> productInformation = productService.getProductInformation(productId); - return Result.success(productInformation); + @GetMapping("/father") + public Result<?> pageFatherNameProductInformation(String fatherName) { + List<Map<String, Object>> maps = productService.pageFatherNameProductInformation(fatherName); + return Result.success(maps); } - - @ApiOperation("鐗╂枡搴�-->鍒犻櫎娴嬭瘯鏍囧噯妯″潡鏁版嵁") - @DeleteMapping("/delete") - @ApiImplicitParams(value = { - @ApiImplicitParam(value = "娴嬭瘯鏍囧噯ID", name = "productId", dataTypeClass = String.class) - }) - public Result<?> deleteProductInformation(Integer productId) { - Integer isDeleteProduct = productService.deleteProductInformation(productId); - if (isDeleteProduct == 1) { - return Result.success("鍒犻櫎鎴愬姛锛�"); - } - return Result.fail("鍒犻櫎澶辫触锛�"); - } - -// @ApiOperation("鐗╂枡搴�-->淇敼鐗╂枡") -// @PutMapping("/update") -// public Result<?> updateMaterialInformation(@RequestBody Material material) { -// Integer isUpdateMaterialSuccess = materialService.updateMaterialInformation(material); -// if (isUpdateMaterialSuccess == 1) { -// return Result.success("淇敼鐗╂枡銆�"+ material.getName() +"銆戞垚鍔燂紒"); -// } -// return Result.fail("淇敼鐗╂枡銆�"+ material.getName() +"銆戝け璐ワ紒"); -// } } -- Gitblit v1.9.3