BootTestController.java 1.97 KB
package com.cnlive.shenhe.controller;
import com.google.common.collect.Lists;

import com.cnlive.shenhe.entity.BootTest;
import com.cnlive.shenhe.serviceImpl.BootTestServiceImpl;
import com.cnlive.shenhe.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: yanzhaowang
 * @Date: 2022/3/4 14:10
 */
@RestController
@RequestMapping("/boottest")
public class BootTestController {

    @Autowired
    BootTestServiceImpl bootTestService;

    @GetMapping("/testselect/{pagesiaz}/{pageNum}")
    public List<BootTest> selectAll(@RequestParam(defaultValue = "10") @PathVariable(name = "pagesiaz") int pagesiaz, @RequestParam(defaultValue = "1") @PathVariable(name = "pageNum") int pageNum){
        List<BootTest> bootTests = bootTestService.selectAll(pagesiaz, pageNum);
        return bootTests;
    }
    @GetMapping("/testselectid/{BootId}")
    public BootTest selectById(@PathVariable(value = "BootId") String BootId){
        if (BootId != null) {
            BootTest bootTest = bootTestService.selectByid(BootId);
            return bootTest;
        }
        return null;
    }

    @RequestMapping("/testaddBoottest")
    public int addBootTest(@RequestBody BootTest bootTest){
        int i = bootTestService.addBootTest(bootTest);
        return i;
    }

    @DeleteMapping("/testdeleteBoottest/{bootTestid}")
    public int deleteBootTest(@PathVariable(name = "bootTestid") String bootTestid){
        if (CommonUtils.isNotEmpty(bootTestid)) {
            int i = bootTestService.deleteBootTest(bootTestid);
            return i;
        }
        return 0;
    }

    @RequestMapping("/testupdateBoottest")
    public int testupdateBoottest(@RequestBody BootTest bootTest){
        if (bootTest.getId() != null&&bootTest.getAge()!=null&&bootTest.getName()!=null) {
            int i = bootTestService.updateBootTest(bootTest);
            return i;
        }
        return 0;
    }
}