Search in sources :

Example 1 with DalGroup

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;
}
Also used : DalGroup(com.ctrip.platform.dal.daogen.entity.DalGroup) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with DalGroup

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;
}
Also used : DalGroup(com.ctrip.platform.dal.daogen.entity.DalGroup) Timestamp(java.sql.Timestamp)

Example 3 with DalGroup

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;
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) DalGroup(com.ctrip.platform.dal.daogen.entity.DalGroup) LoginUser(com.ctrip.platform.dal.daogen.entity.LoginUser) SQLException(java.sql.SQLException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

DalGroup (com.ctrip.platform.dal.daogen.entity.DalGroup)3 Status (com.ctrip.platform.dal.daogen.domain.Status)1 LoginUser (com.ctrip.platform.dal.daogen.entity.LoginUser)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1