use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalUserResource method delete.
@POST
@Path("delete")
public Status delete(@FormParam("userId") int userId) {
try {
int result = SpringBeanGetter.getDaoOfLoginUser().deleteUser(userId);
if (result < 1) {
log.error("Delete user failed, caused by db operation failed, pls check the log.");
Status status = Status.ERROR;
status.setInfo("Delete operation failed.");
return status;
}
} catch (Exception e) {
log.error(e.getMessage());
Status status = Status.ERROR;
status.setInfo(e.getMessage());
return status;
}
return Status.OK;
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class DalUserResource method update.
@POST
@Path("update")
public Status update(@FormParam("userId") int userId, @FormParam("userNo") String userNo, @FormParam("userName") String userName, @FormParam("userEmail") String userEmail) {
if (userNo == null) {
log.error(String.format("Update user failed, caused by illegal parameters:userNo=%s", userNo));
Status status = Status.ERROR;
status.setInfo("Illegal parameters.");
return status;
}
if (userName == null) {
log.error(String.format("Update user failed, caused by illegal parameters:userName=%s", userName));
Status status = Status.ERROR;
status.setInfo("Illegal parameters.");
return status;
}
if (userEmail == null) {
log.error(String.format("Update user failed, caused by illegal parameters:userEmail=%s", userEmail));
Status status = Status.ERROR;
status.setInfo("Illegal parameters.");
return status;
}
LoginUser user = new LoginUser();
user.setId(userId);
user.setUserNo(userNo);
user.setUserName(userName);
user.setUserEmail(userEmail);
try {
int result = SpringBeanGetter.getDaoOfLoginUser().updateUser(user);
if (result < 1) {
log.error("Update user failed, caused by db operation failed, pls check the log.");
Status status = Status.ERROR;
status.setInfo("Update operation failed.");
return status;
}
} catch (Exception e) {
log.error(e.getMessage());
Status status = Status.ERROR;
status.setInfo(e.getMessage());
return status;
}
return Status.OK;
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class GenTaskBySqlBuilderResource method getMockValue.
@POST
@Path("getMockValue")
public Status getMockValue(@FormParam("db_name") String set_name, @FormParam("table_name") String table_name, @FormParam("crud_type") String crud_type, @FormParam("fields") String fields, @FormParam("condition") String condition, @FormParam("pagination") boolean pagination) throws Exception {
Status status = Status.OK;
int[] sqlTypes = getSqlTypes(set_name, table_name, crud_type, fields, condition);
Object[] values = SQLValidation.mockStringValues(sqlTypes);
try {
status.setInfo(mapper.writeValueAsString(values));
} catch (JsonProcessingException e) {
status = Status.ERROR;
status.setInfo("获取mock value异常.");
}
return status;
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class GenTaskBySqlBuilderResource method buildPagingSQL.
@POST
@Path("buildPagingSQL")
public // dbset
Status buildPagingSQL(// dbset
@FormParam("db_name") String db_set_name, // C#风格或者Java风格
@FormParam("sql_style") String sql_style, @FormParam("sql_content") String sql_content) {
Status status = Status.OK;
try {
DatabaseSetEntry databaseSetEntry = SpringBeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(db_set_name);
CurrentLanguage lang = "java".equals(sql_style) ? CurrentLanguage.Java : CurrentLanguage.CSharp;
String pagingSQL = SqlBuilder.pagingQuerySql(sql_content, DbUtils.getDatabaseCategory(databaseSetEntry.getConnectionString()), lang);
status.setInfo(pagingSQL);
} catch (Exception e) {
status = Status.ERROR;
status.setInfo(e.getMessage());
return status;
}
return status;
}
use of com.ctrip.platform.dal.daogen.domain.Status in project dal by ctripcorp.
the class GenTaskBySqlBuilderResource method getDatabaseCategory.
@POST
@Path("getDatabaseCategory")
public Status getDatabaseCategory(@FormParam("db_set_name") String db_set_name) {
Status status = Status.OK;
DatabaseSetEntry databaseSetEntry = SpringBeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(db_set_name);
try {
DatabaseCategory category = DbUtils.getDatabaseCategory(databaseSetEntry.getConnectionString());
if (DatabaseCategory.MySql == category) {
status.setInfo("MySql");
} else {
status.setInfo("SqlServer");
}
} catch (Exception e) {
status = Status.ERROR;
status.setInfo(e.getMessage());
return status;
}
return status;
}
Aggregations