package com.liang.service.impl;

import com.liang.entity.PrjProjectdivision;
import com.liang.dao.PrjProjectdivisionDao;
import com.liang.service.PrjProjectdivisionService;
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;

/**
 * 项目分工(PrjProjectdivision)表服务实现类
 *
 * @author makejava
 * @since 2023-03-28 17:17:36
 */
@Service("prjProjectdivisionService")
public class PrjProjectdivisionServiceImpl implements PrjProjectdivisionService {
    @Resource
    private PrjProjectdivisionDao prjProjectdivisionDao;

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

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

    /**
     * 新增数据
     *
     * @return 实例对象
     */
    @Override
    public int insert(String mc) {
        return this.prjProjectdivisionDao.insert(mc);
    }

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

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

    @Override
    public List<Map<String, String>> getPrjDivision() {
        return this.prjProjectdivisionDao.getPrjDivision();
    }
}
