Search in sources :

Example 36 with Status

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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status)

Example 37 with 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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) Timestamp(java.sql.Timestamp)

Example 38 with 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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status)

Example 39 with 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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status)

Example 40 with 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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) Timestamp(java.sql.Timestamp)

Aggregations

Status (com.ctrip.platform.dal.daogen.domain.Status)63 Timestamp (java.sql.Timestamp)13 SQLException (java.sql.SQLException)7 LoginUser (com.ctrip.platform.dal.daogen.entity.LoginUser)6 DalGroupDBDao (com.ctrip.platform.dal.daogen.dao.DalGroupDBDao)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ConfigTemplate (com.ctrip.platform.dal.daogen.entity.ConfigTemplate)3 CurrentLanguage (com.ctrip.platform.dal.daogen.enums.CurrentLanguage)2 DatabaseCategory (com.ctrip.platform.dal.daogen.enums.DatabaseCategory)2 ValidateResult (com.ctrip.platform.dal.daogen.sql.validate.ValidateResult)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 HashSet (java.util.HashSet)2 EmailException (org.apache.commons.mail.EmailException)2 HtmlEmail (org.apache.commons.mail.HtmlEmail)2 VelocityContext (org.apache.velocity.VelocityContext)2 CodeGenContext (com.ctrip.platform.dal.daogen.CodeGenContext)1 DalGenerator (com.ctrip.platform.dal.daogen.DalGenerator)1 StoredProcedure (com.ctrip.platform.dal.daogen.domain.StoredProcedure)1 TableSpNames (com.ctrip.platform.dal.daogen.domain.TableSpNames)1