package com.bjtdba.system.service.impl;


import com.bjtdba.entity.system.Regions;
import com.bjtdba.system.dao.RegionsDao;
import com.bjtdba.system.service.RegionsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Regions)表服务实现类
 *
 * @author makejava
 * @since 2022-10-17 17:37:44
 */
@Service("regionsService")
public class RegionsServiceImpl implements RegionsService {
    @Resource
    private RegionsDao regionsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param
     * @return 实例对象
     */
    @Override
    public Regions queryById(Integer id) {
        return this.regionsDao.queryById();
    }

    /**
     * 分页查询
     *
     * @param regions 筛选条件
     * @return 查询结果
     */
//    @Override
//    public Page<Regions> queryByPage(Regions regions, PageRequest pageRequest) {
//        long total = this.regionsDao.count(regions);
//        return new PageImpl<>(this.regionsDao.queryAllByLimit(regions, pageRequest), pageRequest, total);
//    }

    public  List<Regions> queryList(Regions regions){
        return regionsDao.queryAllByLimit(regions);
    }
    /**
     * 新增数据
     *
     * @param regions 实例对象
     * @return 实例对象
     */
    @Override
    public Regions insert(Regions regions) {
        this.regionsDao.insert(regions);
        return regions;
    }

    /**
     * 修改数据
     *
     * @param regions 实例对象
     * @return 实例对象
     */
    @Override
    public Regions update(Regions regions) {
        this.regionsDao.update(regions);
        return this.queryById(regions.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param
     * @return 是否成功
     */
    @Override
    public boolean deleteById( ) {
        return this.regionsDao.deleteById() > 0;
    }
}
