Search in sources :

Example 41 with Status

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

the class DalGroupResource method update.

@POST
@Path("update")
public Status update(@Context HttpServletRequest request, @FormParam("groupId") String id, @FormParam("groupName") String groupName, @FormParam("groupComment") String groupComment) throws Exception {
    try {
        String userNo = RequestUtil.getUserNo(request);
        if (userNo == null || id == null || id.isEmpty()) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        if (!this.validate(userNo)) {
            Status status = Status.ERROR();
            status.setInfo("你没有当前DAL Team的操作权限.");
            return status;
        }
        int groupId = -1;
        try {
            groupId = Integer.parseInt(id);
        } catch (NumberFormatException ex) {
            Status status = Status.ERROR();
            status.setInfo("Illegal group id");
            return status;
        }
        DalGroup group = BeanGetter.getDaoOfDalGroup().getDalGroupById(groupId);
        if (null == group) {
            Status status = Status.ERROR();
            status.setInfo("Group id not existed");
            return status;
        }
        if (null != groupName && !groupName.trim().isEmpty()) {
            group.setGroup_name(groupName);
        }
        if (null != groupComment && !groupComment.trim().isEmpty()) {
            group.setGroup_comment(groupComment);
        }
        group.setCreate_time(new Timestamp(System.currentTimeMillis()));
        int ret = BeanGetter.getDaoOfDalGroup().updateDalGroup(group);
        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;
    }
}
Also used : Status(com.ctrip.platform.dal.daogen.domain.Status) Timestamp(java.sql.Timestamp)

Example 42 with Status

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

the class DalUserResource method isUserExists.

@POST
@Path("exist")
public Status isUserExists(@FormParam("userNo") String userNo) {
    try {
        Status status = Status.ERROR();
        if (userNo == null || userNo.isEmpty()) {
            status.setInfo(userNumberNullMessage);
            return status;
        }
        try {
            LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
            if (user != null && user.getUserNo().equals(userNo)) {
                status.setInfo(userNumberExistMessage);
                return status;
            }
        } catch (Exception e) {
            String message = e.getMessage() == null ? e.toString() : e.getMessage();
            status.setInfo(message);
            return status;
        }
        status = Status.OK();
        return status;
    } 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) LoginUser(com.ctrip.platform.dal.daogen.entity.LoginUser) SQLException(java.sql.SQLException)

Example 43 with Status

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

the class DalUserResource method addUser.

@POST
@Path("add")
public Status addUser(@FormParam("userNo") String userNo, @FormParam("userName") String userName, @FormParam("userEmail") String userEmail, @FormParam("password") String password) {
    try {
        if (userNo == null) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        if (userName == null) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        if (userEmail == null) {
            Status status = Status.ERROR();
            status.setInfo("Illegal parameters.");
            return status;
        }
        password = MD5Util.parseStrToMd5L32(password);
        LoginUser user = new LoginUser();
        user.setUserNo(userNo);
        user.setUserName(userName);
        user.setUserEmail(userEmail);
        user.setPassword(password);
        try {
            int result = BeanGetter.getDaoOfLoginUser().insertUser(user);
            if (result < 1) {
                Status status = Status.ERROR();
                status.setInfo("Add operation failed.");
                return status;
            }
        } catch (Exception e) {
            Status status = Status.ERROR();
            status.setInfo(e.getMessage());
            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) LoginUser(com.ctrip.platform.dal.daogen.entity.LoginUser) SQLException(java.sql.SQLException)

Example 44 with Status

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

the class DalUserResource method userSignUp.

@POST
@Path("signup")
public Status userSignUp(@Context HttpServletRequest request, @FormParam("userNo") String userNo, @FormParam("userName") String userName, @FormParam("userEmail") String userEmail, @FormParam("password") String password) {
    try {
        Status status = Status.ERROR();
        if (userNo == null || userNo.isEmpty()) {
            status.setInfo(userNumberNullMessage);
            return status;
        }
        if (userName == null || userName.isEmpty()) {
            status.setInfo(userNameNullMessage);
            return status;
        }
        if (password == null || password.isEmpty()) {
            status.setInfo(passwordNullMessage);
            return status;
        }
        if (userEmail == null || userEmail.isEmpty()) {
            status.setInfo(emailNullMessage);
            return status;
        }
        password = MD5Util.parseStrToMd5L32(password);
        LoginUser user = new LoginUser();
        user.setUserNo(userNo);
        user.setUserName(userName);
        user.setUserEmail(userEmail);
        user.setPassword(password);
        try {
            int result = BeanGetter.getDaoOfLoginUser().insertUser(user);
            if (result < 1) {
                status.setInfo("用户创建失败");
                return status;
            }
            setSession(request, user);
            status = Status.OK();
        } catch (Exception e) {
            String message = e.getMessage() == null ? e.toString() : e.getMessage();
            status.setInfo(message);
            return status;
        }
        return status;
    } 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) LoginUser(com.ctrip.platform.dal.daogen.entity.LoginUser) SQLException(java.sql.SQLException)

Example 45 with Status

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

the class DatabaseResource method deleteAllInOneDB.

@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("deleteAllInOneDB")
public Status deleteAllInOneDB(@Context HttpServletRequest request, @FormParam("allinonename") String allinonename) throws Exception {
    try {
        String userNo = RequestUtil.getUserNo(request);
        Status status = Status.OK();
        DalGroupDBDao allDbDao = BeanGetter.getDaoOfDalGroupDB();
        DalGroupDB groupDb = allDbDao.getGroupDBByDbName(allinonename);
        LoginUser user = BeanGetter.getDaoOfLoginUser().getUserByNo(userNo);
        if (!validatePermision(user.getId(), groupDb.getDal_group_id())) {
            status = Status.ERROR();
            status.setInfo("你没有当前DataBase的操作权限.");
        } else {
            allDbDao.deleteDalGroupDB(groupDb.getId());
        }
        return status;
    } 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) DalGroupDBDao(com.ctrip.platform.dal.daogen.dao.DalGroupDBDao)

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