|
@@ -1,14 +1,22 @@
|
|
package com.nokia.hb.utils;
|
|
package com.nokia.hb.utils;
|
|
|
|
|
|
import com.nokia.hb.Pojo.Col;
|
|
import com.nokia.hb.Pojo.Col;
|
|
-import com.nokia.hb.Pojo.TreeNode;
|
|
|
|
import com.nokia.hb.Pojo.RetData;
|
|
import com.nokia.hb.Pojo.RetData;
|
|
|
|
+import com.nokia.hb.Pojo.TreeNode;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.util.DigestUtils;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpSession;
|
|
import java.sql.*;
|
|
import java.sql.*;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class DbUtil {
|
|
public class DbUtil {
|
|
|
|
+ private static final Logger log= LoggerFactory.getLogger(DbUtil.class);
|
|
private static Connection conn = null;
|
|
private static Connection conn = null;
|
|
|
|
|
|
|
|
|
|
@@ -516,6 +524,36 @@ public class DbUtil {
|
|
return sb.toString();
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static Object userLogin(String username, String password, HttpSession session) {
|
|
|
|
+ String passwordMd5 = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
|
+ log.debug("username: {}, password: {}, passwordMd5: {}", username, password, passwordMd5);
|
|
|
|
+ String sql = "select * from pm_parse.user where username='" + username + "'";
|
|
|
|
+ PreparedStatement psmt = null;
|
|
|
|
+ try {
|
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
|
+ psmt.setQueryTimeout(60 * 10);
|
|
|
|
+ ResultSet rs = psmt.executeQuery();
|
|
|
|
+ // 没有查到数据
|
|
|
|
+ if (!rs.next()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String passwordStore = rs.getString("password");
|
|
|
|
+ log.debug("passwordStore: {}", passwordStore);
|
|
|
|
+ // 密码正确
|
|
|
|
+ if (passwordMd5.equals(passwordStore)) {
|
|
|
|
+ session.setMaxInactiveInterval(30*60);
|
|
|
|
+ session.setAttribute("username", username);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
// public static List<String> initCitys(String type, String province) {
|
|
// public static List<String> initCitys(String type, String province) {
|
|
// PreparedStatement psmt = null;
|
|
// PreparedStatement psmt = null;
|