use of beans.response.DelMachineResponse in project MSEC by Tencent.
the class DelMachine method exec.
public DelMachineResponse exec(DelMachineRequest request) {
DelMachineResponse response = new DelMachineResponse();
response.setMessage("unkown error.");
response.setStatus(100);
String result = checkIdentity();
if (!result.equals("success")) {
response.setStatus(99);
response.setMessage(result);
return response;
}
if (request.getMachine_name() == null || request.getMachine_name().equals("")) {
response.setMessage("The name of machine to be deleted 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 = "delete from t_machine where machine_name=?";
List<Object> params = new ArrayList<Object>();
params.add(request.getMachine_name());
try {
int delNum = util.updateByPreparedStatement(sql, params);
if (delNum >= 0) {
response.setMessage("success");
response.setDeleteNumber(delNum);
response.setStatus(0);
return response;
}
} catch (SQLException e) {
response.setMessage("Delete record failed:" + e.toString());
response.setStatus(100);
e.printStackTrace();
return response;
} finally {
util.releaseConn();
}
return response;
}
Aggregations