Search in sources :

Example 31 with Status

use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.

the class ConfigTemplateResource method deleteConfigTemplate.

@POST
@Path("deleteConfigTemplate")
public Status deleteConfigTemplate(@FormParam("id") String id) {
    Status status = Status.OK();
    if (id == null) {
        status = Status.ERROR();
        status.setInfo("Null parameters");
        return status;
    }
    try {
        int templateId = -1;
        templateId = Integer.parseInt(id);
        ConfigTemplate configTemplate = new ConfigTemplate();
        configTemplate.setId(templateId);
        BeanGetter.getConfigTemplateDao().deleteConfigTemplate(configTemplate);
        return status;
    } catch (Throwable e) {
        LoggerManager.getInstance().error(e);
        status = Status.ERROR();
        status.setInfo(e.getMessage());
        return status;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) ConfigTemplate(com.ctrip.platform.dal.daogen.entity.ConfigTemplate)

Example 32 with Status

use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.

the class ConfigTemplateResource method addConfigTemplate.

@POST
@Path("addConfigTemplate")
public Status addConfigTemplate(@FormParam("configType") String configType, @FormParam("langType") String langType, @FormParam("template") String template) {
    Status status = Status.OK();
    if (configType == null || langType == null || template == null) {
        status = Status.ERROR();
        status.setInfo("Null parameters.");
        return status;
    }
    try {
        int config_type = -1;
        config_type = Integer.parseInt(configType);
        int lang_type = -1;
        lang_type = Integer.parseInt(langType);
        ConfigTemplate configTemplate = new ConfigTemplate();
        configTemplate.setConfig_type(config_type);
        configTemplate.setLang_type(lang_type);
        configTemplate.setTemplate(template);
        BeanGetter.getConfigTemplateDao().insertConfigTemplate(configTemplate);
        return status;
    } catch (Throwable e) {
        LoggerManager.getInstance().error(e);
        status = Status.ERROR();
        status.setInfo(e.getMessage());
        return status;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) ConfigTemplate(com.ctrip.platform.dal.daogen.entity.ConfigTemplate)

Example 33 with Status

use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.

the class DalGroupDbResource method delete.

@POST
@Path("delete")
public Status delete(@Context HttpServletRequest request, @FormParam("groupId") String groupId, @FormParam("dbId") String dbId) throws Exception {
    try {
        String userNo = RequestUtil.getUserNo(request);
        if (userNo == null || groupId == null || dbId == null) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        int groupID = -1;
        int dbID = -1;
        groupID = Integer.parseInt(groupId);
        dbID = Integer.parseInt(dbId);
        if (!this.validatePermision(userNo, groupID)) {
            Status status = Status.ERROR();
            status.setInfo("你没有当前DAL Team的操作权限。");
            return status;
        }
        int ret = BeanGetter.getDaoOfDalGroupDB().updateGroupDB(dbID, -1);
        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 34 with Status

use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.

the class DalGroupDbResource method add.

@POST
@Path("add")
public Status add(@Context HttpServletRequest request, @FormParam("groupId") String groupId, @FormParam("dbname") String dbname, @FormParam("comment") String comment, @FormParam("gen_default_dbset") boolean gen_default_dbset) throws Exception {
    try {
        String userNo = RequestUtil.getUserNo(request);
        if (userNo == null || groupId == null || dbname == null) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        int groupID = -1;
        groupID = Integer.parseInt(groupId);
        if (!this.validatePermision(userNo, groupID)) {
            Status status = Status.ERROR();
            status.setInfo("你没有当前DAL Team的操作权限。");
            return status;
        }
        DalGroupDB groupdb = BeanGetter.getDaoOfDalGroupDB().getGroupDBByDbName(dbname);
        if (null != groupdb && groupdb.getDal_group_id() > 0) {
            DalGroup group = BeanGetter.getDaoOfDalGroup().getDalGroupById(groupdb.getDal_group_id());
            Status status = Status.ERROR();
            status.setInfo(groupdb.getDbname() + " is already added in " + group.getGroup_name());
            return status;
        }
        int ret = -1;
        if (null != groupdb) {
            ret = BeanGetter.getDaoOfDalGroupDB().updateGroupDB(groupdb.getId(), groupID);
            BeanGetter.getDaoOfDalGroupDB().updateGroupDB(groupdb.getId(), comment);
        } else {
            Status status = Status.ERROR();
            status.setInfo(dbname + " 不存在,请先到数据库一览界面添加DB。");
            return status;
        }
        if (ret <= 0) {
            Status status = Status.ERROR();
            status.setInfo("Add operation failed.");
            return status;
        }
        if (gen_default_dbset) {
            Status status = genDefaultDbset(groupID, dbname, null);
            if (status == Status.ERROR()) {
                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 35 with Status

use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.

the class DalGroupDbSetResource method deleteDbset.

@POST
@Path("deletedbset")
public Status deleteDbset(@Context HttpServletRequest request, @FormParam("groupId") int groupID, @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 ret1 = BeanGetter.getDaoOfDatabaseSet().deleteDatabaseSetEntryByDbsetId(dbsetID);
        int ret2 = BeanGetter.getDaoOfDatabaseSet().deleteDatabaseSetById(dbsetID);
        if (ret1 < 0 || ret2 < 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)

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