package io.renren.modules.levelManage.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.datasource.annotation.DataSource;
import io.renren.modules.levelManage.dao.LevelTableDao;
import io.renren.modules.levelManage.entity.LevelTableEntity;
import io.renren.modules.levelManage.service.LevelTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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


@Service("levelTableService")
@DataSource("heBing")
public class LevelTableServiceImpl extends ServiceImpl<LevelTableDao, LevelTableEntity> implements LevelTableService {

    @Autowired
    LevelTableDao levelTableDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LevelTableEntity> page = this.page(
                new Query<LevelTableEntity>().getPage(params),
                new QueryWrapper<LevelTableEntity>()
        );

        return new PageUtils(page);
    }

    public Integer createTable(String tableName, List<Map<String,String>> cols)
    {
        return levelTableDao.createTable(tableName,cols);
    }

    public List<Map<String,Object>> listByLevelId(Long id)
    {
        return levelTableDao.listByLevelId(id);
    }

    public List<String> listColsByLevelId(Long id){
        return levelTableDao.listColsByLevelId(id);
    };

    public  List<String> listCommentByLevelId(Long id){
        return levelTableDao.listCommentByLevelId(id);
    }

    public List<String> listTypeByLevelId(Long id){
        return levelTableDao.listTypeByLevelId(id);
    }

    public  Integer removeByIdsFromTableName(List<Long> ids,String tableName)
    {
        return levelTableDao.removeByIdsFromTableName(ids,tableName);
    }

    public List<String> listBoolColsById(Long id)
    {
        return levelTableDao.listBoolColsByLevelId(id);
    }

}