Commit d9c47959 by shenjinzhu

优化查询,删除无用代码

parent 6c5a1ee3
...@@ -24,6 +24,8 @@ import com.mongodb.DBCursor; ...@@ -24,6 +24,8 @@ import com.mongodb.DBCursor;
import com.mongodb.DBObject; import com.mongodb.DBObject;
import com.mongodb.Mongo; import com.mongodb.Mongo;
import com.mongodb.MongoClient; import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.FindIterable; import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor; import com.mongodb.client.MongoCursor;
...@@ -177,7 +179,16 @@ public class DataDaoImpl implements DataDao { ...@@ -177,7 +179,16 @@ public class DataDaoImpl implements DataDao {
end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month); end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
System.out.println(end); System.out.println(end);
} }
MongoClient mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort()); MongoClient mongoClient = null;
if (ser.getDbUsername() != null) {
ServerAddress sa = new ServerAddress(ser.getDbHost(), ser.getDbPort());
List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(),
ser.getDbName(), ser.getDbPassword().toCharArray()));
new MongoClient(sa, mongoCredentialList);
mongoClient = new MongoClient(sa, mongoCredentialList);
} else
mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort());
// 连接到数据库 // 连接到数据库
MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName()); MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end)); DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
...@@ -193,7 +204,16 @@ public class DataDaoImpl implements DataDao { ...@@ -193,7 +204,16 @@ public class DataDaoImpl implements DataDao {
int month = cal.get(Calendar.MONTH) + 1; int month = cal.get(Calendar.MONTH) + 1;
end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month); end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
} }
MongoClient mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort()); MongoClient mongoClient = null;
if (ser.getDbUsername() != null) {
ServerAddress sa = new ServerAddress(ser.getDbHost(), ser.getDbPort());
List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(), ser.getDbName(),
ser.getDbPassword().toCharArray()));
new MongoClient(sa, mongoCredentialList);
mongoClient = new MongoClient(sa, mongoCredentialList);
} else
mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort());
MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName()); MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end)); DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
return mongo.getCollection(ser.getCollection() + end); return mongo.getCollection(ser.getCollection() + end);
...@@ -201,19 +221,19 @@ public class DataDaoImpl implements DataDao { ...@@ -201,19 +221,19 @@ public class DataDaoImpl implements DataDao {
} }
public static void main(String[] args) { public static void main(String[] args) {
MongoClient mongoClient = new MongoClient("1.119.44.206", 30000);
// 连接到数据库 // 连接到数据库
MongoDatabase mongo = mongoClient.getDatabase("wx_tanglihua"); ServerAddress sa = new ServerAddress("106.14.249.240", 26807);
MongoCollection<Document> col = mongo.getCollection("status_201712"); List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
Date start = new Date(); mongoCredentialList
start.setDate(15); .add(MongoCredential.createMongoCRCredential("zhiweidata", "spyPlat", "1q2w3e4r".toCharArray()));
Date end = new Date(); new MongoClient(sa, mongoCredentialList);
end.setDate(16); MongoClient mongoClient = new MongoClient(sa, mongoCredentialList);
Bson query = new BasicDBObject("time", new BasicDBObject("$gte", start).append("$lte", end)); MongoDatabase mongo = mongoClient.getDatabase("spyPlat");
MongoCollection<Document> col = mongo.getCollection("indexOfA");
Bson query = new BasicDBObject("code", "300104");
System.out.println(col.count(query)); System.out.println(col.count(query));
} }
@Override @Override
public int findBySourceFromLibrary(Date startTime, Date endTime, String source) { public int findBySourceFromLibrary(Date startTime, Date endTime, String source) {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
......
...@@ -82,14 +82,15 @@ public class MessageDaoImpl implements MessageDao { ...@@ -82,14 +82,15 @@ public class MessageDaoImpl implements MessageDao {
public List<Message> findAll(int pageNo, int pageSize, String pt) { public List<Message> findAll(int pageNo, int pageSize, String pt) {
return mongo.find( return mongo.find(
Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("handle").is(false))) Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("handle").is(false)))
.skip((pageNo - 1) * pageSize).with(new Sort(Sort.Direction.ASC, "templateLv")).limit(pageSize), .skip((pageNo - 1) * pageSize).with(new Sort(Sort.Direction.ASC, "templateLv"))
.with(new Sort(Sort.Direction.DESC, "createDate")).limit(pageSize),
Message.class); Message.class);
} }
@Override @Override
public List<Message> findByTmpName(String templateName, int pageNo, int pageSize, String pt) { public List<Message> findByTmpName(String templateName, int pageNo, int pageSize, String pt) {
return mongo.find(Query.query(Criteria.where("tempName").regex(templateName)).skip((pageNo - 1) * pageSize) return mongo.find(Query.query(Criteria.where("tempName").regex(templateName)).skip((pageNo - 1) * pageSize)
.limit(pageSize), Message.class); .limit(pageSize).with(new Sort(Sort.Direction.DESC, "createDate")), Message.class);
} }
@Override @Override
...@@ -120,7 +121,8 @@ public class MessageDaoImpl implements MessageDao { ...@@ -120,7 +121,8 @@ public class MessageDaoImpl implements MessageDao {
return mongo.find(Query return mongo.find(Query
.query(Criteria.where("tempName").regex(tempName) .query(Criteria.where("tempName").regex(tempName)
.andOperator(Criteria.where("handle").is(handle).andOperator(Criteria.where("pt").is(pt)))) .andOperator(Criteria.where("handle").is(handle).andOperator(Criteria.where("pt").is(pt))))
.skip((pageNo - 1) * pageSize).limit(pageSize), Message.class); .skip((pageNo - 1) * pageSize).limit(pageSize)
.with(new Sort(Sort.Direction.DESC, "handleDate")), Message.class);
} }
@Override @Override
......
...@@ -33,43 +33,15 @@ import com.zhiwei.manage.util.Change; ...@@ -33,43 +33,15 @@ import com.zhiwei.manage.util.Change;
public class TemplateDaoImpl implements TemplateDao { public class TemplateDaoImpl implements TemplateDao {
@Resource(name = "mongoTemplate") @Resource(name = "mongoTemplate")
private MongoTemplate mongo; private MongoTemplate mongo;
@Autowired
private DbDepot dbDepot;
@Override @Override
public boolean insert(Template template) { public boolean insert(Template template) {
// DBCollection con = getCollection(template.getPt());
// if (con == null) {
// return false;
// }
// DBObject obj = new BasicDBObject();
// Field[] fields = template.getClass().getDeclaredFields();
// for (int j = 0; j < fields.length; j++) {
// fields[j].setAccessible(true);
// try {
// if (fields[j].getName().equals("id")) {
// continue;
// }
// if (fields[j].get(template) != null)
// // 字段名,字段值
// obj.put(fields[j].getName(), fields[j].get(template));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// con.insert(obj);
mongo.insert(template); mongo.insert(template);
return true; return true;
} }
@Override @Override
public boolean update(Template template) { public boolean update(Template template) {
// DBCollection con = getCollection(template.getPt());
// if (con == null) {
// return false;
// }
// DBObject update = new BasicDBObject();
// DBObject obj = new BasicDBObject();
Update update = new Update(); Update update = new Update();
Field[] fields = template.getClass().getDeclaredFields(); Field[] fields = template.getClass().getDeclaredFields();
for (int j = 0; j < fields.length; j++) { for (int j = 0; j < fields.length; j++) {
...@@ -80,15 +52,10 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -80,15 +52,10 @@ public class TemplateDaoImpl implements TemplateDao {
} }
if (fields[j].get(template) != null) if (fields[j].get(template) != null)
update.set(fields[j].getName(), fields[j].get(template)); update.set(fields[j].getName(), fields[j].get(template));
// 字段名,字段值
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
// update.put("$set", obj);
// DBObject query = new BasicDBObject();
// query.put("_id", new ObjectId(template.getTemplateId()));
// WriteResult result = con.update(query, update, false, false);
WriteResult result = mongo.updateFirst(Query.query(Criteria.where("_id").is(template.getTemplateId())), update, WriteResult result = mongo.updateFirst(Query.query(Criteria.where("_id").is(template.getTemplateId())), update,
Template.class); Template.class);
return result.getN() == 1 ? true : false; return result.getN() == 1 ? true : false;
...@@ -96,17 +63,7 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -96,17 +63,7 @@ public class TemplateDaoImpl implements TemplateDao {
@Override @Override
public Template findById(String templateId, String pt) { public Template findById(String templateId, String pt) {
// DBCollection con = getCollection(pt);
// if (con == null) {
// return null;
// }
// Map<String, Object> map = (Map<String, Object>) con
// .findOne(new BasicDBObject("_id", new ObjectId(templateId)).append("pt",
// pt));
Template temp = mongo.findOne(Query.query(Criteria.where("_id").is(templateId)), Template.class); Template temp = mongo.findOne(Query.query(Criteria.where("_id").is(templateId)), Template.class);
// Template temp = new Template();
// temp = Change.toBean(Template.class, map);
// temp.setTemplateId(String.valueOf(map.get("_id")));
return temp; return temp;
} }
...@@ -115,32 +72,11 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -115,32 +72,11 @@ public class TemplateDaoImpl implements TemplateDao {
List<Template> list = mongo.find(Query.query(Criteria.where("tempName").regex(templateName)) List<Template> list = mongo.find(Query.query(Criteria.where("tempName").regex(templateName))
.skip((pageNo - 1) * pageSize).limit(pageSize).addCriteria(Criteria.where("pt").is(pt)), .skip((pageNo - 1) * pageSize).limit(pageSize).addCriteria(Criteria.where("pt").is(pt)),
Template.class); Template.class);
// List<Template> list = new ArrayList<Template>();
// DBCollection con = getCollection(pt);
// DBObject query = new BasicDBObject();
// query.put("tempName", new BasicDBObject("$regex", templateName));
// query.put("pt", pt);
// DBCursor cursor = con.find(query).sort(new BasicDBObject("createDate",
// -1)).skip((pageNo - 1) * pageSize)
// .limit(pageSize);
// while (cursor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) cursor.next();
// Template temp = new Template();
// temp = Change.toBean(Template.class, map);
// temp.setTemplateId(String.valueOf(map.get("_id")));
// list.add(temp);
// }
return list; return list;
} }
@Override @Override
public boolean delete(String templateId, String pt) { public boolean delete(String templateId, String pt) {
// DBCollection con = getCollection(pt);
// if (con == null) {
// return false;
// }
// WriteResult result = con.remove(new BasicDBObject("_id", new
// ObjectId(templateId)));
WriteResult result = mongo.remove(Query.query(Criteria.where("_id").is(templateId)), Template.class); WriteResult result = mongo.remove(Query.query(Criteria.where("_id").is(templateId)), Template.class);
return result.getN() == 0 ? true : false; return result.getN() == 0 ? true : false;
} }
...@@ -149,36 +85,9 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -149,36 +85,9 @@ public class TemplateDaoImpl implements TemplateDao {
public List<Template> findAll(int pageNo, int pageSize, String pt) { public List<Template> findAll(int pageNo, int pageSize, String pt) {
List<Template> list = mongo.find( List<Template> list = mongo.find(
Query.query(Criteria.where("pt").is(pt)).skip((pageNo - 1) * pageSize).limit(pageSize), Template.class); Query.query(Criteria.where("pt").is(pt)).skip((pageNo - 1) * pageSize).limit(pageSize), Template.class);
// List<Template> list = new ArrayList<Template>();
// DBCollection con = getCollection(pt);
// if (con == null) {
// return null;
// }
// DBObject obj = new BasicDBObject();
// obj.put("pt", pt);
// DBCursor currsor = con.find(obj).sort(new BasicDBObject("createDate",
// -1)).skip((pageNo - 1) * 10)
// .limit(pageSize);
// while (currsor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) currsor.next();
// Template temp = new Template();
// temp = Change.toBean(Template.class, map);
// temp.setTemplateId(String.valueOf(map.get("_id")));
// list.add(temp);
// }
return list; return list;
} }
public DBCollection getCollection(String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt + "temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "temp");
} else {
con = dbDepot.getDBCollection("temp", pt);
}
return con;
}
@Override @Override
public int allCount(String pt) { public int allCount(String pt) {
return (int) mongo.count(Query.query(Criteria.where("pt").is(pt)), Template.class); return (int) mongo.count(Query.query(Criteria.where("pt").is(pt)), Template.class);
......
package com.zhiwei.manage.handle; package com.zhiwei.manage.handle;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mongodb.DBCollection;
import com.zhiwei.manage.bean.ServerBean;
import com.zhiwei.manage.util.MongoConnect;
@Service("firstRun") @Service("firstRun")
public class DbDepot { public class DbDepot {
@Resource(name = "mongoTemplate") @Resource(name = "mongoTemplate")
private MongoTemplate mongo; private MongoTemplate mongo;
// 信息和检测模板切换链接
public static ConcurrentMap<String, Object> dbCons; public static ConcurrentMap<String, Object> dbCons;
public static ConcurrentMap<String, Object> newsCol; public static ConcurrentMap<String, Object> newsCol;
public static ConcurrentMap<String, Object> dataCol; public static ConcurrentMap<String, Object> dataCol;
public static String nowPt = "网媒";
public static int month = 0; public static int month = 0;
private static final Log log = LogFactory.getLog(DbDepot.class); private static final Log log = LogFactory.getLog(DbDepot.class);
...@@ -36,66 +24,6 @@ public class DbDepot { ...@@ -36,66 +24,6 @@ public class DbDepot {
dataCol = new ConcurrentHashMap<String, Object>(); dataCol = new ConcurrentHashMap<String, Object>();
dbCons = new ConcurrentHashMap<String, Object>(); dbCons = new ConcurrentHashMap<String, Object>();
newsCol = new ConcurrentHashMap<String, Object>(); newsCol = new ConcurrentHashMap<String, Object>();
List<ServerBean> list = mongo.find(Query.query(Criteria.where("pt").is(nowPt)), ServerBean.class);
Calendar cal = Calendar.getInstance();
month = cal.get(Calendar.MONTH + 1);
for (ServerBean sb : list) {
String end = "";
if (sb.isTable()) {
if (sb.getTableKind().equals("month")) {
int month=cal.get(Calendar.MONTH) + 1;
end = cal.get(Calendar.YEAR) + (month>9?""+month:"0"+month);
} else {
}
}
if (sb.getDbType().equals("mongo")) {
if (sb.getDbUsername() != null && !sb.getDbUsername().trim().equals("")) {
DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(),
sb.getDbPassword(), sb.getDbName()).getCollection(sb.getCollection() + end);
dbCons.put(sb.getPt()+sb.getOther(), con);
} else {
DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
.getCollection(sb.getCollection() + end);
dbCons.put(sb.getPt()+sb.getOther(), con);
}
}
}
System.out.println("连接初始化成功"); System.out.println("连接初始化成功");
} }
public DBCollection getDBCollection(String other,String pt) {
DBCollection con = null;
ServerBean sb = mongo.findOne(
Query.query(Criteria.where("pt").is(pt).orOperator(Criteria.where("other").is(other))),
ServerBean.class);
System.out.println(pt);
System.out.println(sb);
Calendar cal=Calendar.getInstance();
month=cal.get(Calendar.MONTH+1);
if (sb != null) {
if (sb.getDbType().equals("mongo")) {
String end="";
if(sb.isTable()) {
if(sb.getTableKind().equals("month")) {
int month=cal.get(Calendar.MONTH) + 1;
end = cal.get(Calendar.YEAR) + (month>9?""+month:"0"+month);
}else {
}
}
if (sb.getDbUsername() != null && !sb.getDbUsername().equals("")) {
con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(), sb.getDbPassword(),
sb.getDbName()).getCollection(sb.getCollection()+end);
dbCons.put(pt+sb.getOther(), con);
} else {
con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
.getCollection(sb.getCollection()+end);
dbCons.put(pt+sb.getOther(), con);
}
}
}
return con;
}
} }
...@@ -75,7 +75,6 @@ public class DataController { ...@@ -75,7 +75,6 @@ public class DataController {
long end=(long) map.get("end"); long end=(long) map.get("end");
String timeType=(String) map.get("timeType"); String timeType=(String) map.get("timeType");
String method=(String) map.get("method"); String method=(String) map.get("method");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar startd = Calendar.getInstance(); Calendar startd = Calendar.getInstance();
Calendar endTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance();
if (method == null) { if (method == null) {
...@@ -91,8 +90,6 @@ public class DataController { ...@@ -91,8 +90,6 @@ public class DataController {
} }
Calendar ds=Calendar.getInstance(); Calendar ds=Calendar.getInstance();
ds.setTimeInMillis(end); ds.setTimeInMillis(end);
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startd.getTime()));
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ds.getTime()));
String source = ""; String source = "";
List<Data> list = new ArrayList<Data>(); List<Data> list = new ArrayList<Data>();
startd.add(Calendar.HOUR, -8); startd.add(Calendar.HOUR, -8);
...@@ -127,8 +124,6 @@ public class DataController { ...@@ -127,8 +124,6 @@ public class DataController {
startd.setTimeInMillis(start); startd.setTimeInMillis(start);
endTime.setTimeInMillis(end); endTime.setTimeInMillis(end);
} }
System.out.println(sdf.format(startd.getTime()));
System.out.println(sdf.format(endTime.getTime()));
Channel channel = new Channel(); Channel channel = new Channel();
List<Data> list = new ArrayList<Data>(); List<Data> list = new ArrayList<Data>();
if (method.equals("source")) { if (method.equals("source")) {
...@@ -213,17 +208,4 @@ public class DataController { ...@@ -213,17 +208,4 @@ public class DataController {
JsonResult result = new JsonResult(true, 200, "参数错误"); JsonResult result = new JsonResult(true, 200, "参数错误");
return JSON.toJSONString(result); return JSON.toJSONString(result);
} }
@RequestMapping(value = "/getTest", produces = "application/json;charset=utf-8")
@ResponseBody
public String getTestData(@RequestBody Map<String, Object> map){
String value=(String) map.get("value");
String method=(String) map.get("method");
Calendar startTime=Calendar.getInstance();
startTime.add(Calendar.DATE, -6);
Calendar endTime=Calendar.getInstance();
List<Data> list=dataService.findByMethod(startTime.getTime(), endTime.getTime(), method, value);
JsonResult result = new JsonResult(true, 200, "获取成功",list);
return JSON.toJSONString(result);
}
} }
...@@ -58,7 +58,6 @@ public class FieldController { ...@@ -58,7 +58,6 @@ public class FieldController {
@RequestMapping(value = "/insertFields", produces = "application/json;charset=utf-8") @RequestMapping(value = "/insertFields", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String insertField(@RequestBody FieldBean fieldbean) { public String insertField(@RequestBody FieldBean fieldbean) {
System.out.println(fieldbean);
fs.insert(fieldbean); fs.insert(fieldbean);
JsonResult result = new JsonResult(true, 200, "添加成功"); JsonResult result = new JsonResult(true, 200, "添加成功");
return JSON.toJSONString(result); return JSON.toJSONString(result);
......
...@@ -30,7 +30,6 @@ public class MessageConteoller { ...@@ -30,7 +30,6 @@ public class MessageConteoller {
int pageNo = (int) map.get("pageNo"); int pageNo = (int) map.get("pageNo");
int pageSize = (int) map.get("pageSize"); int pageSize = (int) map.get("pageSize");
String pt = (String) map.get("pt"); String pt = (String) map.get("pt");
if (tempName == null || tempName.equals("")) { if (tempName == null || tempName.equals("")) {
PageEty page = msgService.findAll(pageNo, pageSize, pt); PageEty page = msgService.findAll(pageNo, pageSize, pt);
JsonResult result = new JsonResult(true, 200, "请求成功", page); JsonResult result = new JsonResult(true, 200, "请求成功", page);
......
...@@ -72,7 +72,6 @@ public class PersonController { ...@@ -72,7 +72,6 @@ public class PersonController {
Cookie[] cookies = req.getCookies(); Cookie[] cookies = req.getCookies();
String result = ""; String result = "";
for (Cookie cookie : cookies) { for (Cookie cookie : cookies) {
System.out.println(cookie.getName() + ":" + cookie.getValue());
result += cookie.getName() + ":" + cookie.getValue() + "\n"; result += cookie.getName() + ":" + cookie.getValue() + "\n";
} }
return JSON.toJSONString(result); return JSON.toJSONString(result);
...@@ -110,10 +109,6 @@ public class PersonController { ...@@ -110,10 +109,6 @@ public class PersonController {
@ResponseBody @ResponseBody
public String deletePerson(@RequestBody Map<String, Object> map){ public String deletePerson(@RequestBody Map<String, Object> map){
List<String> deleteList=(List<String>) map.get("personId"); List<String> deleteList=(List<String>) map.get("personId");
// List<String> deleteList=new ArrayList<>();
// for(String p:personId){
// deleteList.add(p);
// }
boolean b=personService.delete(deleteList); boolean b=personService.delete(deleteList);
JsonResult result=new JsonResult(b?true:false, 200, b?"操作成功":"操作失败"); JsonResult result=new JsonResult(b?true:false, 200, b?"操作成功":"操作失败");
return JSON.toJSONString(result); return JSON.toJSONString(result);
...@@ -122,7 +117,6 @@ public class PersonController { ...@@ -122,7 +117,6 @@ public class PersonController {
@RequestMapping(value = "/savePerson", produces = "application/json;charset=utf-8") @RequestMapping(value = "/savePerson", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String savePerson(HttpServletRequest req,@RequestBody Person person){ public String savePerson(HttpServletRequest req,@RequestBody Person person){
System.out.println(person);
Cookie[] cookies = req.getCookies(); Cookie[] cookies = req.getCookies();
for (Cookie cookie : cookies) { for (Cookie cookie : cookies) {
System.out.println(cookie.getName()); System.out.println(cookie.getName());
......
...@@ -56,7 +56,6 @@ public class ServerController { ...@@ -56,7 +56,6 @@ public class ServerController {
@RequestMapping(value = "/insertServer", produces = "application/json;charset=utf-8") @RequestMapping(value = "/insertServer", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String insertServer(@RequestBody ServerBean serverBean) { public String insertServer(@RequestBody ServerBean serverBean) {
System.out.println(serverBean);
ss.insert(serverBean); ss.insert(serverBean);
JsonResult result = new JsonResult(true, 200, "添加成功"); JsonResult result = new JsonResult(true, 200, "添加成功");
return JSON.toJSONString(result); return JSON.toJSONString(result);
...@@ -88,7 +87,6 @@ public class ServerController { ...@@ -88,7 +87,6 @@ public class ServerController {
@RequestMapping(value = "/insertChannel", produces = "application/json;charset=utf-8") @RequestMapping(value = "/insertChannel", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String insertChannel(@RequestBody Channel channel){ public String insertChannel(@RequestBody Channel channel){
System.out.println(channel);
ss.insertChannels(channel); ss.insertChannels(channel);
JsonResult result=new JsonResult(true, 200, "添加成功"); JsonResult result=new JsonResult(true, 200, "添加成功");
return JSON.toJSONString(result); return JSON.toJSONString(result);
......
...@@ -95,7 +95,6 @@ public class TemplateController { ...@@ -95,7 +95,6 @@ public class TemplateController {
boolean isDelete = false; boolean isDelete = false;
String results = ""; String results = "";
for (String l : templateId) { for (String l : templateId) {
System.out.println(l);
isDelete = ts.delete(l, pt); isDelete = ts.delete(l, pt);
MainThread.delete(l); MainThread.delete(l);
results += l + "\n"; results += l + "\n";
......
...@@ -51,7 +51,6 @@ public class Change { ...@@ -51,7 +51,6 @@ public class Change {
PropertyDescriptor descriptor = propertyDescriptors[i]; PropertyDescriptor descriptor = propertyDescriptors[i];
String propertyName = descriptor.getName(); String propertyName = descriptor.getName();
if (map.containsKey(propertyName)) { if (map.containsKey(propertyName)) {
// 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。
Object value = map.get(propertyName); Object value = map.get(propertyName);
if ("".equals(value)) { if ("".equals(value)) {
value = null; value = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment