XiaoRuby
2023-07-27 ad7151b14f2721b0fa40a903c6e65a2c511dd4c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.yuanchu.limslaboratory.controller;
 
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.vo.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-07-17
 */
@Api(tags = "标准库-->4、项目")
@RestController
@RequestMapping("/product")
public class ProductController {
 
    @Autowired
    private ProductService productService;
 
    @ApiOperation("1、分页查询项目")
    @ApiImplicitParams(value = {
            @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)
    })
    @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("2、根据父类查子类")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(value = "父类名称", name = "fatherName", dataTypeClass = String.class)
    })
    @GetMapping("/father")
    public Result<?> pageFatherNameProductInformation(String fatherName) {
        List<Map<String, Object>> maps = productService.pageFatherNameProductInformation(fatherName);
        return Result.success(maps);
    }
}