use of com.sohu.cache.entity.AppAudit in project cachecloud by sohutv.
the class AppAuditDaoTest method testGetAppAuditByAppId.
@Test
public void testGetAppAuditByAppId() {
Long appId = 10170L;
List<AppAudit> appAudits = appAuditDao.getAppAuditByAppId(appId);
for (AppAudit appAudit : appAudits) {
logger.info("{}", appAudit);
}
}
use of com.sohu.cache.entity.AppAudit in project cachecloud by sohutv.
the class AppDeployCenterImpl method createApp.
@Override
public boolean createApp(AppDesc appDesc, AppUser appUser, String memSize) {
try {
appService.save(appDesc);
// 保存应用和用户的关系
appService.saveAppToUser(appDesc.getAppId(), appDesc.getUserId());
// 更新appKey
long appId = appDesc.getAppId();
appService.updateAppKey(appId);
// 保存应用审批信息
AppAudit appAudit = new AppAudit();
appAudit.setAppId(appId);
appAudit.setUserId(appUser.getId());
appAudit.setUserName(appUser.getName());
appAudit.setModifyTime(new Date());
appAudit.setParam1(memSize);
appAudit.setParam2(appDesc.getTypeDesc());
appAudit.setInfo("类型:" + appDesc.getTypeDesc() + ";初始申请空间:" + memSize);
appAudit.setStatus(AppCheckEnum.APP_WATING_CHECK.value());
appAudit.setType(AppAuditType.APP_AUDIT.getValue());
appAuditDao.insertAppAudit(appAudit);
// 发邮件
appEmailUtil.noticeAppResult(appDesc, appAudit);
// 保存申请日志
AppAuditLog appAuditLog = AppAuditLog.generate(appDesc, appUser, appAudit.getId(), AppAuditLogTypeEnum.APP_DESC_APPLY);
if (appAuditLog != null) {
appAuditLogDao.save(appAuditLog);
}
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
use of com.sohu.cache.entity.AppAudit in project cachecloud by sohutv.
the class AppDeployCenterImpl method checkAppDeployDetail.
@Override
public DataFormatCheckResult checkAppDeployDetail(Long appAuditId, String appDeployText) {
if (appAuditId == null) {
logger.error("appAuditId is null");
return DataFormatCheckResult.fail("审核id不能为空!");
}
if (StringUtils.isBlank(appDeployText)) {
logger.error("appDeployText is null");
return DataFormatCheckResult.fail("部署节点列表不能为空!");
}
String[] nodeInfoList = appDeployText.split(ConstUtils.NEXT_LINE);
if (nodeInfoList == null || nodeInfoList.length == 0) {
logger.error("nodeInfoList is null");
return DataFormatCheckResult.fail("部署节点列表不能为空!");
}
AppAudit appAudit = appAuditDao.getAppAudit(appAuditId);
if (appAudit == null) {
logger.error("appAudit:id={} is not exist", appAuditId);
return DataFormatCheckResult.fail(String.format("审核id=%s不存在", appAuditId));
}
long appId = appAudit.getAppId();
AppDesc appDesc = appService.getByAppId(appId);
if (appDesc == null) {
logger.error("appDesc:id={} is not exist");
return DataFormatCheckResult.fail(String.format("appId=%s不存在", appId));
}
int type = appDesc.getType();
//检查每一行
for (String nodeInfo : nodeInfoList) {
nodeInfo = StringUtils.trim(nodeInfo);
if (StringUtils.isBlank(nodeInfo)) {
return DataFormatCheckResult.fail(String.format("部署列表%s中存在空行", appDeployText));
}
String[] array = nodeInfo.split(ConstUtils.COLON);
if (array == null || array.length == 0) {
return DataFormatCheckResult.fail(String.format("部署列表%s中存在空行", appDeployText));
}
String masterHost = null;
String memSize = null;
String slaveHost = null;
if (TypeUtil.isRedisCluster(type)) {
if (array.length == 2) {
masterHost = array[0];
memSize = array[1];
} else if (array.length == 3) {
masterHost = array[0];
memSize = array[1];
slaveHost = array[2];
} else {
return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo));
}
} else if (TypeUtil.isRedisSentinel(type)) {
if (array.length == 3) {
masterHost = array[0];
memSize = array[1];
slaveHost = array[2];
} else if (array.length == 1) {
masterHost = array[0];
} else {
return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo));
}
} else if (TypeUtil.isRedisStandalone(type)) {
if (array.length == 2) {
masterHost = array[0];
memSize = array[1];
} else {
return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo));
}
}
if (!checkHostExist(masterHost)) {
return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", nodeInfo, masterHost));
}
if (StringUtils.isNotBlank(memSize) && !NumberUtils.isDigits(memSize)) {
return DataFormatCheckResult.fail(String.format("%s中的中的memSize=%s不是整数!", nodeInfo, memSize));
}
if (StringUtils.isNotBlank(slaveHost) && !checkHostExist(slaveHost)) {
return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", nodeInfo, slaveHost));
}
}
//检查sentinel类型:数据节点一行,sentinel节点多行
if (TypeUtil.isRedisSentinel(type)) {
return checkSentinelAppDeploy(nodeInfoList);
//检查单点类型:只能有一行数据节点
} else if (TypeUtil.isRedisStandalone(type)) {
return checkStandaloneAppDeploy(nodeInfoList);
}
return DataFormatCheckResult.success("应用部署格式正确,可以开始部署了!");
}
use of com.sohu.cache.entity.AppAudit in project cachecloud by sohutv.
the class UserController method doAddUser.
/**
* 注册用户申请
*/
@RequestMapping(value = "/apply")
public ModelAndView doAddUser(HttpServletRequest request, HttpServletResponse response, Model model, String name, String chName, String email, String mobile, Integer type, Long userId) {
SuccessEnum success = SuccessEnum.SUCCESS;
try {
//保存用户(type=-1为无效用户,需要审批)
AppUser appUser = AppUser.buildFrom(userId, name, chName, email, mobile, type);
userService.save(appUser);
//提交审批
AppAudit appAudit = appService.saveRegisterUserApply(appUser, AppAuditType.REGISTER_USER_APPLY);
appEmailUtil.noticeUserResult(appUser, appAudit);
} catch (Exception e) {
success = SuccessEnum.FAIL;
logger.error(e.getMessage(), e);
}
return new ModelAndView("redirect:/user/register?success=" + success.value());
}
use of com.sohu.cache.entity.AppAudit in project cachecloud by sohutv.
the class UserManageController method doAddAuditStatus.
@RequestMapping(value = "/addAuditStatus")
public ModelAndView doAddAuditStatus(HttpServletRequest request, HttpServletResponse response, Model model, Integer status, Long appAuditId, String refuseReason) {
AppAudit appAudit = appService.getAppAuditById(appAuditId);
AppUser appUser = userService.get(appAudit.getUserId());
// 通过或者驳回并记录日志
appService.updateUserAuditStatus(appAuditId, status);
// 记录驳回原因
if (AppCheckEnum.APP_REJECT.value().equals(status)) {
appAudit.setRefuseReason(refuseReason);
appService.updateRefuseReason(appAudit, getUserInfo(request));
userService.delete(appUser.getId());
}
// 发邮件统计
if (AppCheckEnum.APP_PASS.value().equals(status) || AppCheckEnum.APP_REJECT.value().equals(status)) {
appUser.setType(AppUserTypeEnum.REGULAR_USER.value());
appAudit.setStatus(status);
userService.update(appUser);
appEmailUtil.noticeUserResult(appUser, appAudit);
}
// 批准成功直接跳转
if (AppCheckEnum.APP_PASS.value().equals(status)) {
return new ModelAndView("redirect:/manage/app/auditList");
}
write(response, String.valueOf(SuccessEnum.SUCCESS.value()));
return null;
}
Aggregations