Search in sources :

Example 1 with DelReleasePlanResponse

use of beans.response.DelReleasePlanResponse in project MSEC by Tencent.

the class DelReleasePlan method exec.

public DelReleasePlanResponse exec(ReleasePlan request) {
    Logger logger = Logger.getLogger(this.getClass().getName());
    DelReleasePlanResponse response = new DelReleasePlanResponse();
    response.setMessage("unkown error.");
    response.setStatus(100);
    String result = checkIdentity();
    if (!result.equals("success")) {
        response.setStatus(99);
        response.setMessage(result);
        return response;
    }
    if (request.getPlan_id() == null || request.getPlan_id().equals("")) {
        response.setMessage("Plan ID  should NOT be empty.");
        response.setStatus(100);
        return response;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        response.setMessage("DB connect failed.");
        response.setStatus(100);
        return response;
    }
    String sql;
    List<Object> params = new ArrayList<Object>();
    sql = "delete from t_release_plan where plan_id=?";
    logger.info(sql);
    params.add(request.getPlan_id());
    try {
        int delNum = util.updateByPreparedStatement(sql, params);
        if (delNum == 1) {
            response.setDelNumber(delNum);
            response.setMessage("success");
            response.setStatus(0);
            return response;
        } else {
            response.setDelNumber(delNum);
            response.setMessage("delete record number is " + delNum);
            response.setStatus(100);
            return response;
        }
    } catch (SQLException e) {
        response.setMessage("del record failed:" + e.toString());
        response.setStatus(100);
        e.printStackTrace();
        return response;
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) DelReleasePlanResponse(beans.response.DelReleasePlanResponse) Logger(org.apache.log4j.Logger)

Aggregations

DelReleasePlanResponse (beans.response.DelReleasePlanResponse)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DBUtil (ngse.org.DBUtil)1 Logger (org.apache.log4j.Logger)1