use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiUserService method updateProfile.
/**
* 更新用户个人信息
*
* @param command
* @return
*/
public CommandResponse updateProfile(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiUserUpdateProfileProto.ApiUserUpdateProfileRequest request = ApiUserUpdateProfileProto.ApiUserUpdateProfileRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String userName = request.getUserProfile().getUserName();
String userPhoto = request.getUserProfile().getUserPhoto();
String introduce = request.getUserProfile().getSelfIntroduce();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneEmpty(siteUserId, userName, userPhoto)) {
UserProfileBean userBean = new UserProfileBean();
userBean.setSiteUserId(siteUserId);
userBean.setUserName(userName);
userBean.setUserPhoto(userPhoto);
userBean.setSelfIntroduce(introduce);
if (UserProfileDao.getInstance().updateUserProfile(userBean)) {
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR2_USER_UPDATE_PROFILE;
}
} 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 nonmembers.
public CommandResponse nonmembers(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupNonmembersProto.HaiGroupNonmembersRequest request = HaiGroupNonmembersProto.HaiGroupNonmembersRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<GroupMemberBean> memberList = UserGroupDao.getInstance().getNonGroupMemberList(groupId, pageNum, pageSize);
HaiGroupNonmembersProto.HaiGroupNonmembersResponse.Builder responseBuilder = HaiGroupNonmembersProto.HaiGroupNonmembersResponse.newBuilder();
for (GroupMemberBean member : memberList) {
GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.NONMEMBER;
UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder().setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())).setUserPhoto(String.valueOf(member.getUserPhoto())).build();
GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder().setRole(memberRole).setProfile(memberProfile).build();
responseBuilder.addGroupMember(groupMember);
}
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 members.
/**
* 获取群成员列表
*
* @param command
* @return
*/
public CommandResponse members(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupMembersProto.HaiGroupMembersRequest request = HaiGroupMembersProto.HaiGroupMembersRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
if (pageNum == 0 && pageSize == 0) {
pageNum = 1;
pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT;
}
LogUtils.requestDebugLog(logger, command, request.toString());
List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize);
HaiGroupMembersProto.HaiGroupMembersResponse.Builder responseBuilder = HaiGroupMembersProto.HaiGroupMembersResponse.newBuilder();
for (GroupMemberBean member : memberList) {
GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.forNumber(member.getUserRole());
UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder().setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())).setUserPhoto(String.valueOf(member.getUserPhoto())).build();
GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder().setRole(memberRole).setProfile(memberProfile).build();
responseBuilder.addGroupMember(groupMember);
}
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 delete.
/**
* 删除群组
*
* @param command
* @return
*/
public CommandResponse delete(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupDeleteProto.HaiGroupDeleteRequest request = HaiGroupDeleteProto.HaiGroupDeleteRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(groupId)) {
if (UserGroupDao.getInstance().deleteGroup(groupId)) {
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 removeMember.
/**
* 删除群成员
*
* @param command
* @return
*/
public CommandResponse removeMember(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupRemoveMemberProto.HaiGroupRemoveMemberRequest request = HaiGroupRemoveMemberProto.HaiGroupRemoveMemberRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
ProtocolStringList deleteMemberIds = request.getGroupMemberList();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(groupId)) {
if (UserGroupDao.getInstance().deleteGroupMember(groupId, deleteMemberIds)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations