use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalGroupDbSetResource method deleteDbsetEntry.
@POST
@Path("deletedbsetEntry")
public Status deleteDbsetEntry(@Context HttpServletRequest request, @FormParam("groupId") int groupID, @FormParam("dbsetEntryId") int dbsetEntryID, @FormParam("dbsetId") int dbsetID) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (!this.validatePermision(userNo, groupID)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的操作权限.");
return status;
}
if (!validatePermision(userNo, groupID, dbsetID)) {
Status status = Status.ERROR();
status.setInfo("你只能操作你们组创建的逻辑数据库.");
return status;
}
int ret = BeanGetter.getDaoOfDatabaseSet().deleteDatabaseSetEntryById(dbsetEntryID);
if (ret < 0) {
Status status = Status.ERROR();
status.setInfo("Delete 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 DalGroupDbSetResource method updateDbsetEntry.
@POST
@Path("updateDbsetEntry")
public Status updateDbsetEntry(@Context HttpServletRequest request, @FormParam("id") int dbsetEntyID, @FormParam("name") String name, @FormParam("databaseType") String databaseType, @FormParam("sharding") String sharding, @FormParam("connectionString") String connectionString, @FormParam("dbsetId") int dbsetID, @FormParam("groupId") int groupID) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (!this.validatePermision(userNo, groupID)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的操作权限.");
return status;
}
if (!validatePermision(userNo, groupID, dbsetID)) {
Status status = Status.ERROR();
status.setInfo("你只能操作你们组创建的逻辑数据库.");
return status;
}
int ret = -1;
DatabaseSetEntry dbsetEntry = new DatabaseSetEntry();
dbsetEntry.setId(dbsetEntyID);
dbsetEntry.setName(name);
dbsetEntry.setDatabaseType(databaseType);
dbsetEntry.setSharding(sharding);
dbsetEntry.setConnectionString(connectionString);
dbsetEntry.setDatabaseSet_Id(dbsetID);
dbsetEntry.setUpdate_time(new Timestamp(System.currentTimeMillis()));
LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
String upNo = user.getUserName() + "(" + userNo + ")";
dbsetEntry.setUpdate_user_no(upNo);
ret = BeanGetter.getDaoOfDatabaseSet().updateDatabaseSetEntry(dbsetEntry);
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 DalGroupMemberResource method delete.
@POST
@Path("delete")
public Status delete(@Context HttpServletRequest request, @FormParam("groupId") int currentGroupId, @FormParam("userId") int userId, @FormParam("isDalTeam") boolean isDalTeam) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (!this.validatePermision(userNo, currentGroupId)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的组员操作权限.");
return status;
}
if (isDalTeam) {
int childGroupId = userId;
int ret = BeanGetter.getGroupRelationDao().deleteChildGroupByCurrentGroupIdAndChildGroupId(currentGroupId, childGroupId);
if (ret <= 0) {
Status status = Status.ERROR();
status.setInfo("Delete operation failed.");
return status;
}
return Status.OK();
}
int ret = BeanGetter.getDalUserGroupDao().deleteUserFromGroup(userId, currentGroupId);
if (ret <= 0) {
Status status = Status.ERROR();
status.setInfo("Delete 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 DalGroupMemberResource method update.
@POST
@Path("update")
public Status update(@Context HttpServletRequest request, @FormParam("groupId") int currentGroupId, @FormParam("userId") int userID, @FormParam("user_role") int user_role, @FormParam("allowAddUser") boolean allowAddUser) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (!this.validatePermision(userNo, currentGroupId)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的组员操作权限.");
return status;
}
if (!this.validatePermision(userNo, currentGroupId, user_role)) {
Status status = Status.ERROR();
status.setInfo("你所授予的权限大于你所拥有的权限.");
return status;
}
int adduser = allowAddUser == true ? 1 : 2;
int ret = BeanGetter.getDalUserGroupDao().updateUserPersimion(userID, currentGroupId, user_role, adduser);
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 DalGroupMemberResource method addGroup.
@POST
@Path("addGroup")
public Status addGroup(@Context HttpServletRequest request, @FormParam("currentGroupId") int currentGroupId, @FormParam("childGroupId") int childGroupId, @FormParam("child_group_role") int child_group_role, @FormParam("allowGroupAddUser") boolean allowGroupAddUser) throws Exception {
try {
String userNo = RequestUtil.getUserNo(request);
if (userNo == null) {
Status status = Status.ERROR();
status.setInfo("Illegal parameters.");
return status;
}
if (currentGroupId == childGroupId) {
Status status = Status.ERROR();
status.setInfo("不能将当前组加入当前组.");
return status;
}
if (!this.validatePermision(userNo, currentGroupId)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的组员操作权限.");
return status;
}
if (!this.validatePermision(userNo, currentGroupId, child_group_role)) {
Status status = Status.ERROR();
status.setInfo("你所授予的权限大于你所拥有的权限.");
return status;
}
GroupRelation relation = BeanGetter.getGroupRelationDao().getGroupRelationByCurrentGroupIdAndChildGroupId(currentGroupId, childGroupId);
if (relation != null) {
DalGroup dalGroup = BeanGetter.getDaoOfDalGroup().getDalGroupById(childGroupId);
Status status = Status.ERROR();
status.setInfo("DAL Team[" + dalGroup.getGroup_name() + "]已经加入当前DAL Team.");
return status;
}
int adduser = allowGroupAddUser == true ? 1 : 2;
relation = new GroupRelation();
relation.setAdduser(adduser);
relation.setChild_group_id(childGroupId);
relation.setChild_group_role(child_group_role);
relation.setCurrent_group_id(currentGroupId);
relation.setUpdate_time(new Timestamp(System.currentTimeMillis()));
LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
String upNo = user.getUserName() + "(" + userNo + ")";
relation.setUpdate_user_no(upNo);
int ret = BeanGetter.getGroupRelationDao().insertChildGroup(relation);
if (ret <= 0) {
Status status = Status.ERROR();
status.setInfo("Add operation failed.");
return status;
}
return Status.OK();
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
Aggregations