use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalGroupResource method update.
@POST
@Path("update")
public Status update(@Context HttpServletRequest request, @FormParam("groupId") String id, @FormParam("groupName") String groupName, @FormParam("groupComment") String groupComment) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null || id == null || id.isEmpty()) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (!this.validate(userNo)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的操作权限.");
return status;
}
int groupId = -1;
try {
groupId = Integer.parseInt(id);
} catch (NumberFormatException ex) {
Status status = Status.ERROR();
status.setInfo("Illegal group id");
return status;
}
DalGroup group = BeanGetter.getDaoOfDalGroup().getDalGroupById(groupId);
if (null == group) {
Status status = Status.ERROR();
status.setInfo("Group id not existed");
return status;
}
if (null != groupName && !groupName.trim().isEmpty()) {
group.setGroup_name(groupName);
}
if (null != groupComment && !groupComment.trim().isEmpty()) {
group.setGroup_comment(groupComment);
}
group.setCreate_time(new Timestamp(System.currentTimeMillis()));
int ret = BeanGetter.getDaoOfDalGroup().updateDalGroup(group);
if (ret <= 0) {
Status status = Status.ERROR();
status.setInfo("update operation failed.");
return status;
}
return Status.OK();
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalUserResource method isUserExists.
@POST
@Path("exist")
public Status isUserExists(@FormParam("userNo") String userNo) {
try {
Status status = Status.ERROR();
if (userNo == null || userNo.isEmpty()) {
status.setInfo(userNumberNullMessage);
return status;
}
try {
LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
if (user != null && user.getUserNo().equals(userNo)) {
status.setInfo(userNumberExistMessage);
return status;
}
} catch (Exception e) {
String message = e.getMessage() == null ? e.toString() : e.getMessage();
status.setInfo(message);
return status;
}
status = Status.OK();
return status;
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalUserResource method addUser.
@POST
@Path("add")
public Status addUser(@FormParam("userNo") String userNo, @FormParam("userName") String userName, @FormParam("userEmail") String userEmail, @FormParam("password") String password) {
try {
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (userName == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (userEmail == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
password = MD5Util.parseStrToMd5L32(password);
LoginUser user = new LoginUser();
user.setUserNo(userNo);
user.setUserName(userName);
user.setUserEmail(userEmail);
user.setPassword(password);
try {
int result = BeanGetter.getDaoOfLoginUser().insertUser(user);
if (result < 1) {
Status status = Status.ERROR();
status.setInfo("Add operation failed.");
return status;
}
} catch (Exception e) {
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
return Status.OK();
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalUserResource method userSignUp.
@POST
@Path("signup")
public Status userSignUp(@Context HttpServletRequest request, @FormParam("userNo") String userNo, @FormParam("userName") String userName, @FormParam("userEmail") String userEmail, @FormParam("password") String password) {
try {
Status status = Status.ERROR();
if (userNo == null || userNo.isEmpty()) {
status.setInfo(userNumberNullMessage);
return status;
}
if (userName == null || userName.isEmpty()) {
status.setInfo(userNameNullMessage);
return status;
}
if (password == null || password.isEmpty()) {
status.setInfo(passwordNullMessage);
return status;
}
if (userEmail == null || userEmail.isEmpty()) {
status.setInfo(emailNullMessage);
return status;
}
password = MD5Util.parseStrToMd5L32(password);
LoginUser user = new LoginUser();
user.setUserNo(userNo);
user.setUserName(userName);
user.setUserEmail(userEmail);
user.setPassword(password);
try {
int result = BeanGetter.getDaoOfLoginUser().insertUser(user);
if (result < 1) {
status.setInfo("用户创建失败");
return status;
}
setSession(request, user);
status = Status.OK();
} catch (Exception e) {
String message = e.getMessage() == null ? e.toString() : e.getMessage();
status.setInfo(message);
return status;
}
return status;
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DatabaseResource method deleteAllInOneDB.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("deleteAllInOneDB")
public Status deleteAllInOneDB(@Context HttpServletRequest request, @FormParam("allinonename") String allinonename) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
Status status = Status.OK();
DalGroupDBDao allDbDao = BeanGetter.getDaoOfDalGroupDB();
DalGroupDB groupDb = allDbDao.getGroupDBByDbName(allinonename);
LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
if (!validatePermision(user.getId(), groupDb.getDal_group_id())) {
status = Status.ERROR();
status.setInfo("你没有当前DataBase的操作权限.");
} else {
allDbDao.deleteDalGroupDB(groupDb.getId());
}
return status;
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
Aggregations