use of beans.response.DelOddSecondLevelServiceIPInfoResponse in project MSEC by Tencent.
the class DelOddSecondLevelServiceIPInfo method exec.
public DelOddSecondLevelServiceIPInfoResponse exec(DelOddSecondLevelServiceIPInfoRequest request) {
DelOddSecondLevelServiceIPInfoResponse response = new DelOddSecondLevelServiceIPInfoResponse();
response.setMessage("unkown error.");
response.setStatus(100);
String result = checkIdentity();
if (!result.equals("success")) {
response.setStatus(99);
response.setMessage(result);
return response;
}
if (request.getIps() == null || request.getIps().length == 0) {
response.setMessage("IP /port 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;
}
try {
for (int i = 0; i < request.getIps().length; ++i) {
String sql = "delete from t_second_level_service_ipinfo where ip=? and port=? and status='disabled'";
List<Object> params = new ArrayList<Object>();
params.add(request.getIps()[i].getIp());
params.add(request.getIps()[i].getPort());
try {
int delNum = util.updateByPreparedStatement(sql, params);
if (delNum <= 0) {
response.setMessage("delete record number is " + delNum);
response.setDelNumber(delNum);
response.setStatus(100);
return response;
}
} catch (SQLException e) {
response.setMessage("Delete record failed:" + e.toString());
response.setStatus(100);
e.printStackTrace();
return response;
}
}
response.setMessage("success");
response.setStatus(0);
return response;
} finally {
util.releaseConn();
}
}
Aggregations