package com.yc.education.service.impl;

import com.github.pagehelper.PageHelper;
import com.yc.education.mapper.SuccessCaseMapper;
import com.yc.education.model.SuccessCase;
import com.yc.education.service.ISuccessCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Hickey
 * @create 2019-07-25 10:20
 */
@Service
public class SuccessCaseServiceImpl extends  BaseService<SuccessCase> implements ISuccessCaseService {

    @Autowired
    private SuccessCaseMapper mapper;

    /**
     * 前台
     * 查询所有案例  和  根据类别id查询案例
     * @param id
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<SuccessCase> listAllCase(Integer id,Integer pageNum,Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        return mapper.listAllCase(id);
    }

    /**
     * 后台
     * 查询所有案例信息 分页   多条件查询
     * @param id
     * @param name
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public  List<SuccessCase> manageAllCase(Integer id,String name,Integer pageNum,Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        return  mapper.manageAllCase(id,name);
    }

    /**
     * 后台
     * 根据选中案例id批量删除案例信息
     * @param caseArray
     * @return
     */
    @Override
    public  int deleteCaseArray(int [] caseArray){
        return mapper.deleteCaseArray(caseArray);
    }

    /**
     * 前台
     * 查询所有推荐的案例信息
     * @return
     */
    @Override
    public  List<SuccessCase> findCaseByState(){
        return  mapper.findCaseByState();
    }


    /**
     *前台首页  根据需求查询某个案例类别下的推荐案例信息
     * @return
     */
    @Override
    public List<SuccessCase> listCaseByCondition(){
        return  mapper.listCaseByCondition();
    }

}

