package com.liang.service.impl;

import com.liang.entity.PrjPayplanname;
import com.liang.dao.PrjPayplannameDao;
import com.liang.service.PrjPayplannameService;
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;

/**
 * 外语语种(PrjPayplanname)表服务实现类
 *
 * @author makejava
 * @since 2023-06-30 10:33:05
 */
@Service("prjPayplannameService")
public class PrjPayplannameServiceImpl implements PrjPayplannameService {
    @Resource
    private PrjPayplannameDao prjPayplannameDao;

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

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

    /**
     * 新增数据
     *
     * @param prjPayplanname 实例对象
     * @return 实例对象
     */
    @Override
    public PrjPayplanname insert(PrjPayplanname prjPayplanname) {
        this.prjPayplannameDao.insert(prjPayplanname);
        return prjPayplanname;
    }

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

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

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