| 
					
				 | 
			
			
				@@ -3,24 +3,23 @@ package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.SysTenantConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.SysConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.SysTenantConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.Teacher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.enums.TeachModeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.event.TenantConfigChangeEvent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.SysTenantConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.poi.ss.formula.functions.T; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.util.collection.MapUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.ApplicationEventPublisher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.ApplicationEventPublisherAware; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTenantConfig>  implements SysTenantConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTenantConfig>  implements SysTenantConfigService, ApplicationEventPublisherAware { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private SysTenantConfigDao sysTenantConfigDao; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,6 +29,39 @@ public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTena 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return sysTenantConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Map<Integer,Map<String,String>> tenantConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private ApplicationEventPublisher applicationEventPublisher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.applicationEventPublisher = applicationEventPublisher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		applicationEventPublisher.publishEvent(new TenantConfigChangeEvent(this,null)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setTenantConfig(Map<Integer, Map<String, String>> tenantConfig) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.tenantConfig = tenantConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public Map<String, String> getTenantConfig(Integer tenantId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return tenantConfig.get(tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public String getTenantConfigValue(Integer tenantId,String paramName) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Map<String, String> map = tenantConfig.get(tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(map != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return map.get(paramName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public Map<Integer, Map<String, String>> getAllTenantConfig() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return tenantConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public List<SysConfig> queryAll(Map<String, Object> params) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return sysTenantConfigDao.queryALl(params); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,10 +76,22 @@ public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTena 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		List<Long> configIdList = sysConfigs.stream().map(e -> e.getId()).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		sysTenantConfigDao.delByConfigId(configIdList,tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		sysTenantConfigDao.batchInsert(sysConfigs,tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		applicationEventPublisher.publishEvent(new TenantConfigChangeEvent(this,tenantId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public String getConfigValue(String paramName, Integer tenantId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return sysTenantConfigDao.getConfigValue(paramName, tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public Map<String, String> queryAllMap(Integer tenantId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<Map<String, String>> maps = sysTenantConfigDao.queryAllMap(tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Map<String, String> resultMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(maps != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			resultMap = MapUtil.convertMybatisMap(maps); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return resultMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |