package com.hzya.frame.sysnew.comparison.dao.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.sysnew.comparison.dao.IComparisonDao;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import org.springframework.stereotype.Repository;

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

@Repository(value = "comparisonDaoImpl")
public class ComparisonDaoImpl extends MybatisGenericDao<ComparisonEntity, String> implements IComparisonDao {
    //根据主数据编码查询表名，字段名等信息
    @Override
    public List<ComparisonEntity> queryComparison(ComparisonEntity comparison) {
        List<ComparisonEntity> query = super.query(getSqlIdPrifx() + "queryComparison", comparison);
        return query;
    }

    //分页查询
    @Override
    public List<Map<String,Object>> queryComparisonPage(ComparisonEntity comparison) {
        List<Map<String,Object>> query =(List<Map<String, Object>>) super.selectList(getSqlIdPrifx() + "queryComparisonPage", comparison);
        return query;
    }

    //保存数据
    @Override
    public ComparisonEntity saveComparison(ComparisonEntity comparison) {
        ComparisonEntity comparisonEntity = super.save(getSqlIdPrifx() + "saveComparison", comparison);
        return comparisonEntity;
    }

    //生成单据规则
    @Override
    public ComparisonEntity queryComparisonRule(ComparisonEntity comparison) {
        List<ComparisonEntity> comparisonEntities = super.query(getSqlIdPrifx() + "queryComparisonRule", comparison);
        return comparisonEntities.get(0);
    }

    //更新通用数据数据
    @Override
    public Integer updateComparisonByType(ComparisonEntity comparison) {
        int update = super.update(getSqlIdPrifx() + "updateComparisonByType", comparison);
        return update;
    }

    //删除通用数据
    @Override
    public Integer deleteComparison(ComparisonEntity comparison) {
        int delete = super.delete(getSqlIdPrifx() + "deleteComparison", comparison);
        return delete;
    }

    //查询单据规则
    @Override
    public ComparisonEntity queryComparisonById(ComparisonEntity comparison) {
        List<ComparisonEntity> comparisonEntities = super.query(getSqlIdPrifx() + "queryComparisonById", comparison);
        return comparisonEntities.get(0);
    }

    //根据主数据编码查询mdm_module数据
    @Override
    public ComparisonEntity queryComparisonBymdmCode(ComparisonEntity comparison) {
        ComparisonEntity comparisonEntity =(ComparisonEntity) super.selectOne(getSqlIdPrifx() + "queryComparisonBymdmCode", comparison);
        return comparisonEntity;
    }

    //根据mdm_module得id查询mdm_module_db得数据
    @Override
    public List<ComparisonEntity> queryComparisonBymdmId(ComparisonEntity comparison) {
        List<ComparisonEntity> list =(List<ComparisonEntity>) super.selectList(getSqlIdPrifx() + "queryComparisonBymdmId", comparison);
        return list;
    }

    //根据mdm_module得id查询mdm_module_db_fileds得数据
    @Override
    public List<ComparisonEntity> queryComparisonBymdmIdFileds(ComparisonEntity comparison) {
        List<ComparisonEntity> list =(List<ComparisonEntity>) super.selectList(getSqlIdPrifx() + "queryComparisonBymdmIdFileds", comparison);
        return list;
    }

    //根据mdm_id查询mdm_module_db_fileds_rule中的字段是否是必填项
    @Override
    public List<ComparisonEntity> queryComparisonBymdmIdDbIdFiledId(ComparisonEntity comparison) {
        List<ComparisonEntity> list =(List<ComparisonEntity>) super.selectList(getSqlIdPrifx() + "queryComparisonBymdmIdDbIdFiledId", comparison);
        return list;
    }

}
