package com.bjtdba.system.service.impl;

import com.bjtdba.entity.system.FeedbackCategory;
import com.bjtdba.system.dao.FeedbackCategoryDao;
import com.bjtdba.system.service.FeedbackCategoryService;
import com.bjtdba.system.vo.FeedbackVo;
import org.springframework.stereotype.Service;

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

/**
 * 用户反馈分类表(FeedbackCategory)表服务实现类
 *
 * @author 何海强
 * @since 2022-11-18 11:45:04
 */
@Service("feedbackCategoryService")
public class FeedbackCategoryServiceImpl implements FeedbackCategoryService {
    @Resource
    private FeedbackCategoryDao feedbackCategoryDao;

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

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

    public long counts(FeedbackCategory feedbackCategory){
        return  this.feedbackCategoryDao.count(feedbackCategory);
    }

    /**
     * 新增数据
     *
     * @param feedbackCategory 实例对象
     * @return 实例对象
     */
    @Override
    public FeedbackVo insert(FeedbackVo feedbackVo) {
        this.feedbackCategoryDao.insert(feedbackVo);
        return feedbackVo;
    }

    /**
     * 修改数据
     *
     * @param feedbackCategory 实例对象
     * @return 实例对象
     */
    @Override
    public FeedbackCategory update(FeedbackCategory feedbackCategory) {
        this.feedbackCategoryDao.update(feedbackCategory);
        return this.queryById(feedbackCategory.getFeedback_category_id());
    }

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