use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpSiteConfigService method updateConfig.
/**
* 更新站点配置相关操作
*
* @param command
* @return
*/
public CommandResponse updateConfig(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiSiteUpdateConfigProto.HaiSiteUpdateConfigRequest request = HaiSiteUpdateConfigProto.HaiSiteUpdateConfigRequest.parseFrom(command.getParams());
Map<Integer, String> configMap = request.getSiteConfig().getSiteConfigMap();
LogUtils.requestDebugLog(logger, command, request.toString());
if (configMap != null) {
// update db config
if (SiteConfigDao.getInstance().updateSiteConfig(configMap)) {
errorCode = ErrorCode2.SUCCESS;
SiteConfig.updateConfig();
SiteConfigHelper.updateConfig();
}
// update log level
if (configMap.get(ConfigProto.ConfigKey.LOG_LEVEL_VALUE) != null) {
String loglev = configMap.get(ConfigProto.ConfigKey.LOG_LEVEL_VALUE);
Level level = Level.toLevel(loglev);
AkxLog4jManager.setLogLevel(level);
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} 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 create.
/**
* 生成UIC(用户邀请码)
*
* @param command
* @return
*/
public CommandResponse create(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUicCreateProto.HaiUicCreateRequest request = HaiUicCreateProto.HaiUicCreateRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
int num = request.getUicNumber();
int successCount = 0;
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && num > 0) {
UicBean bean = new UicBean();
bean.setStatus(UicStatus.UNUSED_VALUE);
bean.setCreateTime(System.currentTimeMillis());
if (SiteUicDao.getInstance().batchAddUic(bean, num)) {
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} 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 list.
/**
* 分页获取UIC
*
* @param command
* @return
*/
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiUicListProto.HaiUicListRequest request = HaiUicListProto.HaiUicListRequest.parseFrom(command.getParams());
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
int status = request.getStatusValue();
LogUtils.requestDebugLog(logger, command, request.toString());
List<UicBean> uicList = SiteUicDao.getInstance().getUicList(pageNum, pageSize, status);
if (uicList != null) {
HaiUicListProto.HaiUicListResponse.Builder responseBuilder = HaiUicListProto.HaiUicListResponse.newBuilder();
for (UicBean bean : uicList) {
responseBuilder.addUicInfo(getUicInfo(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 HttpUserService method list.
/**
* 分页获取用户列表
*
* @param command
* @return
*/
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUserListProto.HaiUserListRequest request = HaiUserListProto.HaiUserListRequest.parseFrom(command.getParams());
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<SimpleUserBean> pageList = UserProfileDao.getInstance().getUserPageList(pageNum, pageSize);
if (pageList != null) {
HaiUserListProto.HaiUserListResponse.Builder responseBuilder = HaiUserListProto.HaiUserListResponse.newBuilder();
for (SimpleUserBean bean : pageList) {
UserProto.SimpleUserProfile.Builder userProfileBuilder = UserProto.SimpleUserProfile.newBuilder();
userProfileBuilder.setSiteUserId(bean.getUserId());
if (StringUtils.isNotBlank(bean.getUserName())) {
userProfileBuilder.setUserName(bean.getUserName());
}
if (StringUtils.isNotBlank(bean.getUserPhoto())) {
userProfileBuilder.setUserPhoto(bean.getUserPhoto());
}
userProfileBuilder.setUserStatusValue(bean.getUserStatus());
userProfileBuilder.setUserStatusValue(bean.getUserStatus());
responseBuilder.addUserProfile(userProfileBuilder.build());
}
commandResponse.setParams(responseBuilder.build().toByteArray());
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 HttpUserService method search.
/**
* 查找用户
*
* @param command
* @return
*/
public CommandResponse search(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUserSearchProto.HaiUserSearchRequest request = HaiUserSearchProto.HaiUserSearchRequest.parseFrom(command.getParams());
String siteUserId = request.getSiteUserId();
String userName = request.getUserName();
LogUtils.requestDebugLog(logger, command, request.toString());
List<SimpleUserBean> userList = new ArrayList<SimpleUserBean>();
if (StringUtils.isNotBlank(siteUserId)) {
userList.add(UserProfileDao.getInstance().getSimpleProfileById(siteUserId));
} else if (StringUtils.isNotBlank(userName)) {
userList = UserProfileDao.getInstance().getSimpleProfileByName(userName);
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
if (userList != null && userList.size() > 0) {
HaiUserSearchProto.HaiUserSearchResponse.Builder responseBuilder = HaiUserSearchProto.HaiUserSearchResponse.newBuilder();
for (SimpleUserBean bean : userList) {
UserProto.SimpleUserProfile profile = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(bean.getUserId()).setUserName(String.valueOf(bean.getUserName())).setUserPhoto(String.valueOf(bean.getUserPhoto())).build();
responseBuilder.addUserProfile(profile);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
Aggregations