package com.liang.service.impl;

import com.liang.entity.PrjContacts;
import com.liang.dao.PrjContactsDao;
import com.liang.service.PrjContactsService;
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;

/**
 * (PrjContacts)表服务实现类
 *
 * @author makejava
 * @since 2023-04-11 15:04:32
 */
@Service("prjContactsService")
public class PrjContactsServiceImpl implements PrjContactsService {
    @Resource
    private PrjContactsDao prjContactsDao;

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

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

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

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

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

    @Override
    public List<PrjContacts> getContactList(Integer xm) {
        return this.prjContactsDao.getContactList(xm);
    }

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