BootTestServiceImpl.java 2.24 KB
package com.cnlive.shenhe.serviceImpl;
import com.google.common.collect.Lists;

import com.cnlive.shenhe.entity.BootTest;
import com.cnlive.shenhe.mapper.BootTestMapper;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yanzhaowang
 * @Date: 2022/3/4 13:38
 */
@Service
public class BootTestServiceImpl {

    @Autowired
    BootTestMapper bootTestMapper;

    /**
     *根据主键查询对象
     * @param boottestid
     * @return
     */
    public BootTest selectByid(String boottestid) {

        if (CommonUtils.isEmpty(boottestid)) {
            return null;
        }
        BootTest bootTest = bootTestMapper.selectByPrimaryKey(boottestid);

        return bootTest;
    }

    /**
     * 查询所有的数据
     * @return
     */
    public List<BootTest> selectAll(int pagesaiz, int pagenum){
//        PageInfo pageInfo = new PageInfo();
//        pageInfo.setSize(pagesaiz);
//        pageInfo.setPageNum(pagenum);
//        PageHelper pageHelper = new PageHelper();
        List<BootTest> bootTestList = bootTestMapper.selectAll();
//        pageInfo.setList(bootTestList);
        return bootTestList;
    }

    /**
     * 添加一个对象
     * @param bootTest
     * @return
     */
    public int addBootTest(BootTest bootTest) {
        Integer age = bootTest.getAge();
        if (age >= 18 && age <= 60) {
            int i = bootTestMapper.insertSelective(bootTest);
            return i;
        }
        return 0;
    }

    /**
     * 根据主键删除一个对象
     * @param boottestid
     * @return
     */
    public int deleteBootTest(String boottestid){
        if (boottestid == null) {
            return 0;
        }
        int i = bootTestMapper.deleteByPrimaryKey(boottestid);
        return i;
    }

    /**
     * 根据条件修改对象
     * @return
     */
    public int updateBootTest(BootTest bootTest){
        if (bootTest != null) {
            int i = bootTestMapper.updateByPrimaryKeySelective(bootTest);
            return i;
        }
        return 0;

    }
}