WindChat/windchat-business/src/main/java/com/windchat/im/business/impl/hai/HttpSiteService.java

71 lines
2.4 KiB
Java
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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.
*/
package com.windchat.im.business.impl.hai;
import java.util.Map;
import com.windchat.im.business.impl.AbstractRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.windchat.common.command.Command;
import com.windchat.common.command.CommandResponse;
import com.windchat.common.constant.ErrorCode2;
import com.windchat.common.logs.LogUtils;
import com.akaxin.proto.core.ConfigProto;
import com.akaxin.proto.plugin.HaiSiteGetConfigProto;
import com.windchat.im.business.impl.AbstractRequest;
import com.windchat.im.business.impl.site.SiteConfig;
/**
* 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);
}
}