use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class ConfigTemplateResource method updateConfigTemplate.
@POST
@Path("updateConfigTemplate")
public Status updateConfigTemplate(@FormParam("id") String id, @FormParam("configType") String configType, @FormParam("langType") String langType, @FormParam("template") String template) {
Status status = Status.OK();
if (id == null || configType == null || langType == null || template == null) {
status = Status.ERROR();
status.setInfo("Null parameters");
return status;
}
try {
int templateId = -1;
templateId = Integer.parseInt(id);
int config_type = -1;
config_type = Integer.parseInt(configType);
int lang_type = -1;
lang_type = Integer.parseInt(langType);
ConfigTemplate configTemplate = new ConfigTemplate();
configTemplate.setId(templateId);
configTemplate.setConfig_type(config_type);
configTemplate.setLang_type(lang_type);
configTemplate.setTemplate(template);
BeanGetter.getConfigTemplateDao().updateConfigTemplate(configTemplate);
return status;
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
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 DalGroupDbResource method genDefaultDbset.
/**
* 生成默认的databaseSet和databaseSet Entry
*
* @param dbname
*/
public static Status genDefaultDbset(int groupId, String dbname, String dbProvider) throws Exception {
Status status = Status.OK();
List<DatabaseSet> exist = BeanGetter.getDaoOfDatabaseSet().getAllDatabaseSetByName(dbname);
if (exist != null && exist.size() > 0) {
status = Status.ERROR();
status.setInfo("数据库" + dbname + "已添加成功。由于已存在名为" + dbname + "的逻辑数据库,所以无法默认生成同名的逻辑库,请到逻辑数据库管理页面中手动添加不同名称的逻辑库。请点击关闭按钮以关闭窗口。");
return status;
}
DatabaseSet dbset = new DatabaseSet();
dbset.setName(dbname);
dbset.setProvider("sqlProvider");
if (dbProvider != null && dbProvider.length() > 0) {
if (dbProvider.equals("SQLServer"))
dbset.setProvider("sqlProvider");
if (dbProvider.equals("MySQL"))
dbset.setProvider("mySqlProvider");
}
dbset.setGroupId(groupId);
int ret = BeanGetter.getDaoOfDatabaseSet().insertDatabaseSet(dbset);
if (ret > 0) {
dbset = BeanGetter.getDaoOfDatabaseSet().getAllDatabaseSetByName(dbname).get(0);
DatabaseSetEntry entry = new DatabaseSetEntry();
entry.setDatabaseSet_Id(dbset.getId());
entry.setDatabaseType("Master");
entry.setName(dbname);
entry.setConnectionString(dbname);
BeanGetter.getDaoOfDatabaseSet().insertDatabaseSetEntry(entry);
}
return status;
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalGroupDbResource method update.
@POST
@Path("update")
public Status update(@Context HttpServletRequest request, @FormParam("groupId") String groupId, @FormParam("dbId") String dbId, @FormParam("comment") String comment) 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;
dbID = Integer.parseInt(dbId);
groupID = Integer.parseInt(groupId);
if (!this.validatePermision(userNo, groupID)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DAL Team的操作权限。");
return status;
}
int ret = BeanGetter.getDaoOfDalGroupDB().updateGroupDB(dbID, comment);
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 DalGroupDbResource method transferdb.
@POST
@Path("transferdb")
public Status transferdb(@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.validateTransferPermision(userNo, dbID)) {
Status status = Status.ERROR();
status.setInfo("你没有当前DataBase的操作权限。");
return status;
}
int ret = BeanGetter.getDaoOfDalGroupDB().updateGroupDB(dbID, groupID);
if (ret <= 0) {
Status status = Status.ERROR();
status.setInfo("transfer 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 updateDbset.
@POST
@Path("updateDbset")
public Status updateDbset(@Context HttpServletRequest request, @FormParam("id") int iD, @FormParam("name") String name, @FormParam("provider") String provider, @FormParam("shardingStrategy") String shardingStrategy, @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, iD)) {
Status status = Status.ERROR();
status.setInfo("你只能操作你们组创建的逻辑数据库.");
return status;
}
List<DatabaseSet> dbsets = BeanGetter.getDaoOfDatabaseSet().getAllDatabaseSetByName(name);
if (null != dbsets && dbsets.size() > 0) {
for (DatabaseSet dbset : dbsets) {
if (dbset.getId() != iD) {
Status status = Status.ERROR();
status.setInfo("databaseSet Name --> " + name + "已经存在,请重新命名!");
return status;
}
}
}
int ret = -1;
DatabaseSet dbset = new DatabaseSet();
dbset.setId(iD);
dbset.setName(name);
dbset.setProvider(provider);
dbset.setShardingStrategy(shardingStrategy);
dbset.setGroupId(groupID);
dbset.setUpdate_time(new Timestamp(System.currentTimeMillis()));
LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
String upNo = user.getUserName() + "(" + userNo + ")";
dbset.setUpdate_user_no(upNo);
ret = BeanGetter.getDaoOfDatabaseSet().updateDatabaseSet(dbset);
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;
}
}
Aggregations