package cn.feast.coding.service.stock.impl;

import cn.feast.coding.mapper.stock.StockAnalyseMapper;
import cn.feast.coding.model.stock.StockAnalyse;
import cn.feast.coding.service.stock.StockAnalyseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created By FeastCoding.
 */
@Service
public class StockAnalyseServiceImpl implements StockAnalyseService {
    @Autowired
    private StockAnalyseMapper mapper;

    public int insert(StockAnalyse model){
        return mapper.insert(model);
    }

    public int update(StockAnalyse model){
        return mapper.update(model);
    }

    public int deleteByPrimaryKey(Integer id){
        return mapper.deleteByPrimaryKey(id);
    }

    public List<StockAnalyse> selectAll(StockAnalyse model){
        return mapper.selectAll(model);
    }

    public PageInfo<StockAnalyse> queryPage(StockAnalyse model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<StockAnalyse> list = mapper.selectAll(model);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    public PageInfo<Map<String, Object>> queryAnalyse(StockAnalyse model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.queryAnalyse(model.getDate());
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> queryAnalyse1(StockAnalyse model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.queryAnalyse1();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> queryAnalyse2(StockAnalyse model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.queryAnalyse2(model.getDate());
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> sortByTurn(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.sortByTurn();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> sortByPrice(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.sortByPrice();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> querySentiment(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.querySentiment();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Map<String, Object>> queryConcept(StockAnalyse stockAnalyse, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.queryConcept();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    public StockAnalyse selectByPrimaryKey(Integer id){
        return mapper.selectByPrimaryKey(id);
    }

    public List<StockAnalyse> queryAll(){
        return mapper.queryAll();
    }

    @Override
    public PageInfo<Map<String, Object>> queryStockConcept(String stockCode, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = mapper.queryStockConcept(stockCode);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public List<Map<String, Object>> queryConceptStocks(String conceptName) {
        return mapper.queryConceptStocks(conceptName);
    }

    @Override
    public List<Map<String, Object>> getKLineData(String stockCode) {
        return mapper.getKLineData(stockCode);
    }

}
