コード例 #1
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/postfriendlabledelete",
      method = RequestMethod.POST,
      produces = "text/plain;charset=UTF-8")
  @ResponseBody
  public static String put(HttpServletRequest request) throws Exception {
    String data = request.getParameter("info");
    String content = AESUtils.decrypt4AES(data, AESUtils.key);
    LogRecord.info("SolrFriendLableDelete类postfriendlabledelete接口接收的参数:" + content);
    long start = System.currentTimeMillis();
    String middletimes = "";
    String bug_one = "";
    String ccid = "";
    String ffid = "";
    String fflid = "";
    List<Map<String, FriendLabel>> lists = Transformation.friendlableLol(content);
    for (Map<String, FriendLabel> cardMap : lists) {
      for (String key : cardMap.keySet()) {
        switch (key) {
          case "cid":
            ccid = cardMap.get(key) + "";
            break;
          case "fid":
            ffid = cardMap.get(key) + "";
            break;
          case "flid":
            fflid = cardMap.get(key) + "";
            break;
          default:
            break;
        }
      }
    }
    try {
      SolrUpdateFriendLabel.solrqueryresult(fflid, ffid, ccid);
    } catch (Exception e) {
      bug_one = e.getMessage();
      LogRecord.info("Exception :" + e + ",Msg :" + e.getMessage());
    }

    long end = System.currentTimeMillis();
    middletimes = (end - start) + "";

    // 计算当前的时间,格式为"yyyy/MM/dd HH:mm:ss"可以任意修改格式
    Date now = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); // 可以方便地修改日期格式
    String messageid = dateFormat.format(now);

    ResultDelete result = new ResultDelete(true, messageid, "删除成功!", "000000", middletimes);
    ResultDelete resultfalse = new ResultDelete(true, messageid, "删除失败!", "060002", middletimes);

    String cardjsonsucess = AESUtils.encrypt4AES(JSON.toJSONString(result), AESUtils.key);
    String cardjsonfalse = AESUtils.encrypt4AES(JSON.toJSONString(resultfalse), AESUtils.key);
    String str = bug_one.length() > 0 ? cardjsonfalse : cardjsonsucess;
    LogRecord.info(
        "SolrFriendLableDelete类postfriendlabledelete接口返回的值:"
            + AESUtils.decrypt4AES(str, AESUtils.key));
    return str;
  }
コード例 #2
0
 @Override
 public void loginQueryImpl(Map<String, String> loginmap) {
   Connection conn = null;
   String sql = "";
   String key = "";
   String values = "";
   try {
     conn = Dbtool.getConnection();
     for (Entry<String, String> entry : loginmap.entrySet()) {
       key += entry.getKey() + ",";
       values += "'" + entry.getValue() + "'" + ",";
     }
     String k = key.substring(0, key.length() - 1);
     String v = values.substring(0, values.length() - 1);
     sql = "insert into login (" + k + ") values (" + v + ")";
     PreparedStatement pstmt = conn.prepareStatement(sql);
     pstmt.executeUpdate();
   } catch (SQLException e) {
     LogRecord.error(loginImpl.class, e);
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
         LogRecord.error(loginImpl.class, e);
       }
     }
   }
 }
コード例 #3
0
 @Override
 public void loginUpdateImpl(String lid, String state) {
   Connection conn = null;
   String sql = "";
   try {
     conn = Dbtool.getConnection();
     sql = "UPDATE login SET state = " + state + " WHERE lid = " + "'" + lid + "'";
     PreparedStatement pstmt = conn.prepareStatement(sql);
     pstmt.executeUpdate();
   } catch (SQLException e) {
     LogRecord.error(loginImpl.class, e);
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
         LogRecord.error(loginImpl.class, e);
       }
     }
   }
 }
コード例 #4
0
 @RequestMapping(
     value = "/postupdatelogin",
     method = RequestMethod.POST,
     produces = "text/plain;charset=UTF-8")
 @ResponseBody
 public static String solrqueryresult(HttpServletRequest request) {
   loginDao logindao = new loginImpl();
   String data = request.getParameter("info");
   String cid = "";
   String lid = "";
   String state = "";
   String account = "";
   String bug_one = "";
   List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
   List<SolrLogin> results = new ArrayList<SolrLogin>();
   ModifiableSolrParams params = new ModifiableSolrParams();
   data = data.replaceAll("\\{|\"|\\}", "").trim();
   String[] data1 = data.split(",");
   for (String s : data1) {
     if (s.contains("cid")) {
       String[] s1 = s.split(":");
       cid = s1[1];
     }
     if (s.contains("account")) {
       String[] s1 = s.split(":");
       account = s1[1];
     }
   }
   //		params.add("q",  "cid" + ":" + cid + " AND " + "account" + ":" + account);
   params.add("q", "account" + ":" + account);
   params.add("start", "0"); // 记录开始位置
   params.add("rows", "3001"); // 查询的行数
   try {
     QueryResponse rsp = server.query(params);
     long p = rsp.getResults().getNumFound();
     if (p > 0) {
       results = rsp.getBeans(SolrLogin.class);
       for (SolrLogin bean : results) {
         SolrInputDocument doc = new SolrInputDocument();
         String beanjson = JSON.toJSONString(bean, false);
         beanjson = beanjson.replaceAll("\\{|\\}|\"", "").trim();
         String[] bjson = beanjson.split(",");
         cid = bean.cid;
         for (String s : bjson) {
           String[] w = s.split(":");
           if (s.contains("lid")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
               lid = s1[1];
             } else {
               doc.setField(s1[0], "");
             }
             continue;
           }
           if (s.contains("account")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("password")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("cid")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("state")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               state = "0";
               doc.setField(s1[0], "0");
             } else {
               doc.setField(s1[0], "0");
             }
             continue;
           }
           if (s.contains("type")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("integral")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("createTime")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("modifyTime")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if ("headspace".equals(w[0])) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("headspace1")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("headspace2")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("headspace3")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
           if (s.contains("headspace4")) {
             String[] s1 = s.split(":");
             if (s1.length > 1) {
               doc.addField(s1[0], s1[1]);
             } else {
               doc.addField(s1[0], "");
             }
             continue;
           }
         }
         docs.add(doc);
       }
     }
     try {
       server.add(docs);
       server.commit();
       logindao.loginUpdateImpl(lid, state);
     } catch (Exception e) {
       LogRecord.error(updatelogin.class, e);
       bug_one = e.getMessage();
     }
   } catch (SolrServerException e) {
     LogRecord.error(updatelogin.class, e);
     bug_one = e.getMessage();
   }
   return bug_one.length() > 1
       ? "{\"errorCode\":\"060002\",\"msg\":\"操作失败\"}"
       : "{\"errorCode\":\"000000\",\"cid\":\"" + cid + "\",\"msg\":\"操作成功\"}";
 }