2019-07-29 23:42:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* Copyright 2018-2028 Akaxin Group
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
2019-11-27 23:33:33 +08:00
|
|
|
|
package com.windchat.im.business.impl.hai;
|
2019-07-29 23:42:16 +08:00
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
2019-11-27 23:33:33 +08:00
|
|
|
|
import com.windchat.im.business.impl.AbstractRequest;
|
2019-07-29 23:42:16 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
2019-11-27 23:36:54 +08:00
|
|
|
|
import com.windchat.common.command.Command;
|
|
|
|
|
import com.windchat.common.command.CommandResponse;
|
|
|
|
|
import com.windchat.common.constant.ErrorCode2;
|
|
|
|
|
import com.windchat.common.logs.LogUtils;
|
2019-07-29 23:42:16 +08:00
|
|
|
|
import com.akaxin.proto.core.ConfigProto;
|
|
|
|
|
import com.akaxin.proto.plugin.HaiSiteGetConfigProto;
|
2019-11-27 23:36:54 +08:00
|
|
|
|
import com.windchat.im.business.impl.AbstractRequest;
|
|
|
|
|
import com.windchat.im.business.impl.site.SiteConfig;
|
2019-07-29 23:42:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* hai接口,提供对站点配置相关操作
|
|
|
|
|
*
|
|
|
|
|
* @author Sam{@link an.guoyue254@gmail.com}
|
|
|
|
|
* @since 2018-01-08 14:22:52
|
|
|
|
|
*/
|
|
|
|
|
public class HttpSiteService extends AbstractRequest {
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(HttpSiteService.class);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取站点配置信息
|
|
|
|
|
*
|
|
|
|
|
* @param command
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public CommandResponse getConfig(Command command) {
|
|
|
|
|
CommandResponse commandResponse = new CommandResponse();
|
|
|
|
|
ErrorCode2 errorCode = ErrorCode2.ERROR;
|
|
|
|
|
try {
|
|
|
|
|
Map<Integer, String> configMap = SiteConfig.getConfigMap();
|
|
|
|
|
LogUtils.requestDebugLog(logger, command, "");
|
|
|
|
|
logger.info("get config map = {}", configMap);
|
|
|
|
|
|
|
|
|
|
ConfigProto.SiteBackConfig config = ConfigProto.SiteBackConfig.newBuilder().putAllSiteConfig(configMap)
|
|
|
|
|
.build();
|
|
|
|
|
HaiSiteGetConfigProto.HaiSiteGetConfigResponse response = HaiSiteGetConfigProto.HaiSiteGetConfigResponse
|
|
|
|
|
.newBuilder().setSiteConfig(config).build();
|
|
|
|
|
logger.info("get config service response={}", response.toString());
|
|
|
|
|
commandResponse.setParams(response.toByteArray());
|
|
|
|
|
errorCode = ErrorCode2.SUCCESS;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
|
|
|
|
|
LogUtils.requestErrorLog(logger, command, e);
|
|
|
|
|
}
|
|
|
|
|
return commandResponse.setErrCode2(errorCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|