package com.liang.service.impl;

import com.liang.entity.BaseProjecttemplate;
import com.liang.dao.BaseProjecttemplateDao;
import com.liang.service.BaseProjecttemplateService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

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

/**
 * 项目模板(BaseProjecttemplate)表服务实现类
 *
 * @author makejava
 * @since 2023-03-14 15:30:38
 */
@Service("baseProjecttemplateService")
public class BaseProjecttemplateServiceImpl implements BaseProjecttemplateService {
    @Resource
    private BaseProjecttemplateDao baseProjecttemplateDao;

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

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

    /**
     * 新增数据
     *
     * @param baseProjecttemplate 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(BaseProjecttemplate baseProjecttemplate) {
        return this.baseProjecttemplateDao.insert(baseProjecttemplate);
    }

    /**
     * 修改数据
     *
     * @param baseProjecttemplate 实例对象
     * @return 实例对象
     */
    @Override
    public int update(BaseProjecttemplate baseProjecttemplate) {
        return this.baseProjecttemplateDao.update(baseProjecttemplate);
    }

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

    @Override
    public List<BaseProjecttemplate> getTemplateList(Map map) {
        return this.baseProjecttemplateDao.getTemplateList(map);
    }

    @Override
    public int batchDelete(List<String> idList) {
        return this.baseProjecttemplateDao.batchDelete(idList);
    }
}
