use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpGroupService method addMember.
/**
* 添加群成员
*
* @param command
* @return
*/
public CommandResponse addMember(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupAddMemberProto.HaiGroupAddMemberRequest request = HaiGroupAddMemberProto.HaiGroupAddMemberRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
ProtocolStringList addMemberList = request.getGroupMemberList();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNoneBlank(groupId) && addMemberList != null) {
if (UserGroupDao.getInstance().addGroupMember(siteUserId, groupId, addMemberList)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpGroupService method profile.
/**
* 获取群资料
*
* @param command
* @return
*/
public CommandResponse profile(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
LogUtils.requestDebugLog(logger, command, request.toString());
GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);
if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName())).setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse.newBuilder();
responseBuilder.setProfile(groupProfile);
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpGroupService method list.
/**
* 分页获取站点群列表
*
* @param command
* @return
*/
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupListProto.HaiGroupListRequest request = HaiGroupListProto.HaiGroupListRequest.parseFrom(command.getParams());
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<SimpleGroupBean> groupList = UserGroupDao.getInstance().getGroupList(pageNum, pageSize);
if (groupList != null) {
HaiGroupListProto.HaiGroupListResponse.Builder responseBuilder = HaiGroupListProto.HaiGroupListResponse.newBuilder();
for (SimpleGroupBean bean : groupList) {
responseBuilder.addGroupProfile(getSimpleGroupProfile(bean));
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpPluginService method add.
/**
* 申请添加好友
*
* @param command
* @return
*/
public CommandResponse add(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiPluginAddProto.HaiPluginAddRequest request = HaiPluginAddProto.HaiPluginAddRequest.parseFrom(command.getParams());
LogUtils.requestDebugLog(logger, command, request.toString());
PluginBean bean = new PluginBean();
bean.setName(request.getPlugin().getName());
bean.setIcon(request.getPlugin().getIcon());
bean.setUrlPage(request.getPlugin().getUrlPage());
bean.setApiUrl(request.getPlugin().getApiUrl());
bean.setAllowedIp(request.getPlugin().getAllowedIp());
bean.setPosition(request.getPlugin().getPositionValue());
bean.setDisplayMode(PluginProto.PluginDisplayMode.NEW_PAGE_VALUE);
bean.setPermissionStatus(request.getPlugin().getPermissionStatusValue());
bean.setAddTime(System.currentTimeMillis());
// 随机生成64位的字符串
bean.setAuthKey(StringHelper.generateRandomString(16));
if (SitePluginDao.getInstance().addPlugin(bean)) {
errorCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpUICService method info.
/**
* 获取UIC信息
*
* @param command
* @return
*/
public CommandResponse info(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUicInfoProto.HaiUicInfoRequest request = HaiUicInfoProto.HaiUicInfoRequest.parseFrom(command.getParams());
int id = request.getId();
String uic = request.getUic();
LogUtils.requestDebugLog(logger, command, request.toString());
if (id > 0 && StringUtils.isNotBlank(uic)) {
UicBean bean = SiteUicDao.getInstance().getUicInfo(uic);
if (bean != null) {
HaiUicInfoProto.HaiUicInfoResponse response = HaiUicInfoProto.HaiUicInfoResponse.newBuilder().setUicInfo(getUicInfo(bean)).build();
commandResponse.setParams(response.toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
Aggregations