package com.hzya.frame.mdm.mdmModule.dao.impl;

import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.mdm.entity.MdmDataDto;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.mdm.entity.MdmFiledsRuleDto;
import com.hzya.frame.mdm.entity.MdmQuery;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.mdm.mdmModuleDbFileds.entity.MdmModuleDbFiledsEntity;
import com.hzya.frame.sys.entity.FormmainDeleteDto;
import org.springframework.stereotype.Repository;

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

/**
 * 主数据模版(MdmModule)表数据库访问层
 *
 * @author makejava
 * @since 2024-06-03 08:46:29
 */
@Repository(value = "MdmModuleDaoImpl")
public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String> implements IMdmModuleDao{

    @Override
    public List<MdmModuleEntity> queryMdm(MdmModuleEntity entity) {
        List<MdmModuleEntity> o = (List<MdmModuleEntity>) super.selectList(getSqlIdPrifx() + "queryMdm", entity);
        return o;
    }



    @Override
    public MdmModuleEntity getByMdmCode(Long mdmCode) {
        MdmModuleEntity mdmModuleEntity = (MdmModuleEntity) super.selectOne(getSqlIdPrifx() + "getByMdmCode",mdmCode);
        return mdmModuleEntity;
    }

    @Override
    public Integer checkTable(Map<String, String> maps) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "checkTable", maps);
        return o;

    }
    @Override
    public List<HashMap<String, Object>> queryDataAll(MdmDto entity) {
        List<HashMap<String, Object>> o = (List<HashMap<String, Object>>) super.selectList(getSqlIdPrifx() + "queryDataAll", entity);
        return o;
    }

    @Override
    public Integer deleteMdmModuleEntity(MdmModuleEntity entity) {
        Integer o = (Integer) super.delete(getSqlIdPrifx() + "deleteMdmModuleEntity", entity);
        return o;
    }

    @Override
    public Integer queryMainCount(MdmQuery entity) {
        Integer o = (Integer) super.getCount(getSqlIdPrifx() + "queryMainCount", entity);
        return o;
    }

    @Override
    public Integer checkData(Map<String, String> maps) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "checkData", maps);
        return o;

    }
    @Override
    public Integer updateForm(MdmDataDto mdmDataDto) {
        Integer o = super.update(getSqlIdPrifx() + "updateForm", mdmDataDto);
        return o;

    }
    @Override
    public List<HashMap<String, Object>> querySelectData(MdmDto entity) {
        List<HashMap<String, Object>> o = (List<HashMap<String, Object>>) super.selectList(getSqlIdPrifx() + "querySelectData", entity);
        return o;

    }
    @Override
    public Integer deleteChilder(FormmainDeleteDto entity) {
        Integer o = super.delete(getSqlIdPrifx() + "deleteChilder", entity);
        return o;

    }
    @Override
    public Integer deleteTemplateById(FormmainDeleteDto entity) {
        Integer o = super.delete(getSqlIdPrifx() + "deleteTemplateById", entity);
        return o;

    }
    @Override
    public Integer saveForm(MdmDataDto mdmDataDto) {
        Integer o = super.update(getSqlIdPrifx() + "saveForm", mdmDataDto);
        return o;

    }
    @Override
    public List<HashMap<String, Object>> queryTemplateDataMore(MdmDto entity) {
        List<HashMap<String, Object>> o = (List<HashMap<String, Object>>) super.selectList(getSqlIdPrifx() + "queryTemplateDataMore", entity);
        return o;

    }

    @Override
    public HashMap<String, Object> queryTemplateDataOne(MdmDto entity) {
        HashMap<String, Object> o = (HashMap<String, Object>) super.selectOne(getSqlIdPrifx() + "queryTemplateDataOne", entity);
        return o;

    }

    @Override
    public List<HashMap<String, Object>> queryMdmShowData(MdmQuery entity) {
        //HashMap<String, Object> maps = new HashMap<>();
        //maps.put("tableName",entity.getTableName());
        //List<String> fields = queryMdMFields(maps);
        //entity.setFields(fields);
        List<HashMap<String, Object>> o = (List<HashMap<String, Object>>) super.selectList(getSqlIdPrifx() + "queryMdmShowData", entity);
        return o;
    }
    @Override
    public Integer createTable(Map<String, Object> maps) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "createTable", maps);
        return o;
    }

    @Override
    public Integer deleteTable(Map<String, Object> maps) {
        Integer o = (Integer) super.delete(getSqlIdPrifx() + "deleteTable", maps);
        return o;
    }



    @Override
    public Integer alterTable(Map<String, Object> maps) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "alterTable", maps);
        return o;
    }
    @Override
    public Integer alterTableField(MdmModuleDbFiledsEntity entity) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "alterTableField", entity);
        return o;
    }

    @Override
    public Integer alterTableName(Map<String, String> maps) {
        Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "alterTableName", maps);
        return o;

    }

    @Override
    public JSONObject queryMdmST(Map<String, Object> maps) {
        //List<String> fields = queryMdMFields(maps);
        //maps.put("fields",fields);
        JSONObject o = (JSONObject) super.selectOne(getSqlIdPrifx() + "queryMdmST", maps);
        return o;
    }
    @Override
    public List<JSONObject> queryMdmSTs(Map<String, Object> maps) {
        List<JSONObject> o = (List<JSONObject>) super.selectList(getSqlIdPrifx() + "queryMdmST", maps);
        return o;
    }

    @Override
    public void updateMdmSTs(Map<String, Object> maps) {
        super.update(getSqlIdPrifx() + "updateMdmSTs", maps);
    }

    @Override
    public void updataTreeUpData(Map<String, String> maps) {
        super.update(getSqlIdPrifx() + "updataTreeUpData", maps);
    }

    @Override
    public void updataTreeUpDataDetail(Map<String, String> maps) {
        super.update(getSqlIdPrifx() + "updataTreeUpDataDetail", maps);
    }

    @Override
    public MdmFiledsRuleDto queryDataId(MdmFiledsRuleDto mdmFiledsRuleDto) {
        MdmFiledsRuleDto o = (MdmFiledsRuleDto) super.selectOne(getSqlIdPrifx() + "queryDataId", mdmFiledsRuleDto);
        return o;
    }

    @Override
    public List<String> queryMdMFields(Map<String, Object> maps) {
        List<String> o = (List<String>) super.selectList(getSqlIdPrifx() + "queryMdMFields", maps);
        return o;
    }

    @Override
    public List<JSONObject> queryMdmSTDetail(Map<String, Object> maps) {
        //List<String> fields = queryMdMFields(maps);
        //maps.put("fields", fields );
        List<JSONObject> o = (List<JSONObject>) super.selectList(getSqlIdPrifx() + "queryMdmSTDetail", maps);
        return o;
    }

}

