package com.platform.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.dao.RecommendDao;
import com.platform.entity.RecommendEntity;
import com.platform.service.RecommendService;
import com.platform.vo.RecommendEntityVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * Created by Hb_zzZ on 2018/12/7.
 */
@Service
public class RecommendServiceImpl implements RecommendService {

    @Autowired
    private RecommendDao recommendDao;

    @Override
    public int save(RecommendEntity bo) {
        return recommendDao.save(bo);
    }

    @Override
    public RecommendEntity selectById(Long id) {
        return recommendDao.queryObject(id);
    }

    @Override
    public int update(RecommendEntity bo) {
        return recommendDao.update(bo);
    }

    @Override
    public int delete(Long id) {
        return recommendDao.delete(id);
    }

    @Override
    public IPage<RecommendEntity> selectByType(RecommendEntityVo bo) {
        IPage<RecommendEntity> page = new Page<>(bo.getPageNum() , bo.getLimit());
        RecommendEntity recommendEntity = new RecommendEntity();
        recommendEntity.setType(bo.getType());
        recommendEntity.setTitle(bo.getTitle());
        return recommendDao.queryByPage(page,recommendEntity);
    }
}
