use of com.ctrip.platform.dal.daogen.entity.DalGroup in project dal by ctripcorp.
the class DalGroupProjectResource method getGroups.
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<DalGroup> getGroups(@QueryParam("root") boolean root) {
List<DalGroup> groups = SpringBeanGetter.getDaoOfDalGroup().getAllGroups();
for (DalGroup group : groups) {
group.setText(group.getGroup_name());
group.setIcon("glyphicon glyphicon-folder-open");
group.setChildren(true);
}
return groups;
}
use of com.ctrip.platform.dal.daogen.entity.DalGroup in project dal by ctripcorp.
the class SetupDBResource method setupAdmin.
private boolean setupAdmin(DalGroup dalGroup, LoginUser user) throws Exception {
boolean result = false;
String groupName = dalGroup.getGroup_name();
if (groupName == null || groupName.isEmpty()) {
return result;
}
String userName = user.getUserName();
if (userName == null || userName.isEmpty()) {
return result;
}
int userResult = SpringBeanGetter.getDaoOfLoginUser().insertUser(user);
if (userResult <= 0) {
return result;
}
user = SpringBeanGetter.getDaoOfLoginUser().getUserByNo(user.getUserNo());
DalGroup group = new DalGroup();
group.setId(DalGroupResource.SUPER_GROUP_ID);
group.setGroup_name(dalGroup.getGroup_name());
group.setGroup_comment(dalGroup.getGroup_comment());
group.setCreate_user_no(user.getUserNo());
group.setCreate_time(new Timestamp(System.currentTimeMillis()));
int groupResult = SpringBeanGetter.getDaoOfDalGroup().insertDalGroup(group);
if (groupResult <= 0) {
return result;
}
int userGroupResult = SpringBeanGetter.getDalUserGroupDao().insertUserGroup(user.getId(), DalGroupResource.SUPER_GROUP_ID, RoleType.Admin.getValue(), AddUser.Allow.getValue());
if (userGroupResult <= 0) {
return result;
}
return true;
}
use of com.ctrip.platform.dal.daogen.entity.DalGroup in project dal by ctripcorp.
the class SetupDBResource method initializeDb.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("initializeDb")
public Status initializeDb(@Context HttpServletRequest request, @FormParam("dbaddress") String dbaddress, @FormParam("dbport") String dbport, @FormParam("dbuser") String dbuser, @FormParam("dbpassword") String dbpassword, @FormParam("dbcatalog") String dbcatalog, @FormParam("groupName") String groupName, @FormParam("groupComment") String groupComment, @FormParam("adminNo") String adminNo, @FormParam("adminName") String adminName, @FormParam("adminEmail") String adminEmail, @FormParam("adminPass") String adminPass) {
Status status = Status.OK;
try {
boolean jdbcResult = initializeJdbcProperties(dbaddress, dbport, dbuser, dbpassword, dbcatalog);
if (!jdbcResult) {
status = Status.ERROR;
status.setInfo("Error occured while initializing the jdbc.properties file.");
return status;
}
//to be deleted
initializeConfig();
boolean isSetupTables = setupTables();
if (!isSetupTables) {
status = Status.ERROR;
status.setInfo("Error occured while setting up the tables.");
return status;
}
DalGroup group = new DalGroup();
group.setGroup_name(groupName);
group.setGroup_comment(groupComment);
LoginUser user = new LoginUser();
user.setUserNo(adminNo);
user.setUserName(adminName);
user.setUserEmail(adminEmail);
user.setPassword(MD5Util.parseStrToMd5L32(adminPass));
boolean isSetupAdmin = setupAdmin(group, user);
if (!isSetupAdmin) {
status = Status.ERROR;
status.setInfo("Error occured while setting up the admin.");
return status;
}
} catch (Exception e) {
status = Status.ERROR;
status.setInfo(e.getMessage());
}
return status;
}
Aggregations