package com.dxhy.core.service.config.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dxhy.api.model.config.sys.SysGroupConfigEntity;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.core.dao.CoreSysEnterpriseConfigDao;
import com.dxhy.core.dao.CoreSysGroupConfigDao;
import com.dxhy.core.service.config.SysGroupConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


@Service("sysGroupConfigService")
@Slf4j
public class SysGroupConfigServiceImpl
		extends ServiceImpl<CoreSysGroupConfigDao, SysGroupConfigEntity>
		implements SysGroupConfigService {

	@Resource
	private CoreSysEnterpriseConfigDao coreSysEnterpriseConfigDao;

	@Override
	public SysGroupConfigEntity getGroupInfo(String company) {
		DynamicContextHolder.push(DbConstant.BASICS_WRITE);
		SysGroupConfigEntity sysGroupConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysGroupConfigEntity>().eq(SysGroupConfigEntity::getCompany, company));
		return sysGroupConfig;
	}

	@Override
	public Map<String, String> getApplyKeyByNsrsbh(String nsrsbh) {
		DynamicContextHolder.push(DbConstant.BASICS_READ);
		return baseMapper.getApplyKeyByNsrsbh(nsrsbh);
	}
}
