Browse Source

三方登录

root 5 years ago
parent
commit
b097afd13f

+ 21 - 12
src/main/java/com/kingkong/bljs/security/CustomUserDetailsService.java

@@ -34,15 +34,10 @@ public class CustomUserDetailsService implements UserDetailsService {
34
     @Autowired
34
     @Autowired
35
     private HttpServletRequest request;
35
     private HttpServletRequest request;
36
 
36
 
37
-    @Value("${app.table.user}")
38
-    private String k_user;
39
 
37
 
40
-    @Value("${app.table.app_user}")
41
-    private String k_app_user;
42
-
43
-    @Value("${app.default.app_id}")
44
-    private String default_app_id;
45
 
38
 
39
+    @Value("${app.type}")
40
+    private int appType ;
46
 
41
 
47
 
42
 
48
 
43
 
@@ -50,20 +45,19 @@ public class CustomUserDetailsService implements UserDetailsService {
50
     @Override
45
     @Override
51
     public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
46
     public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
52
 
47
 
53
-        Map user = queryService.first(k_user,"name=" + s);
54
-
48
+        if(1== appType)
49
+            return this.zlUser(s);
55
 
50
 
51
+        Map user = queryService.first("k_user","name=" + s);
56
         if(null == user )
52
         if(null == user )
57
             throw new UsernameNotFoundException("用户不存在!");
53
             throw new UsernameNotFoundException("用户不存在!");
58
 
54
 
59
         String appid = this.request.getParameter("app_id");
55
         String appid = this.request.getParameter("app_id");
60
-        if(null == appid)
61
-            appid = default_app_id;
62
         Map condition = new HashMap();
56
         Map condition = new HashMap();
63
         condition.put("u_id",user.get("id").toString());
57
         condition.put("u_id",user.get("id").toString());
64
         condition.put("app_id",appid);
58
         condition.put("app_id",appid);
65
 
59
 
66
-        Map appuser = queryService.first(k_app_user,condition);
60
+        Map appuser = queryService.first("k_app_user",condition);
67
         if(null == appuser )
61
         if(null == appuser )
68
             throw new UsernameNotFoundException("用户没有权限!");
62
             throw new UsernameNotFoundException("用户没有权限!");
69
 
63
 
@@ -74,4 +68,19 @@ public class CustomUserDetailsService implements UserDetailsService {
74
 
68
 
75
         return customUser;
69
         return customUser;
76
     }
70
     }
71
+
72
+    private CustomUser zlUser(String userName) throws UsernameNotFoundException{
73
+        String strSQL =  "select user_id id,username name,DECODE(t.username,'ZLHIS',1,0) is_super,100 app_id\n" +
74
+                        "from all_users t,上机人员表 z\n" +
75
+                        "where t.username='{0}' and t.username = z.用户名";
76
+
77
+        Map user = this.queryService.find(strSQL,userName);
78
+        if(null == user)
79
+            throw new UsernameNotFoundException("用户不存在!");
80
+        CustomUser customUser =   new CustomUser();
81
+
82
+        customUser.setUser(user);
83
+        customUser.setAppid("100");
84
+        return customUser;
85
+    }
77
 }
86
 }

+ 1 - 1
src/main/resources/templates/login.html

@@ -18,7 +18,7 @@
18
 </head>
18
 </head>
19
 <body>
19
 <body>
20
 <div class="row" style="margin-top: 10px;">
20
 <div class="row" style="margin-top: 10px;">
21
-    <div class="col-xs-4 col-xs-offset-4" style="padding: 20px; border: 1px solid #ddd">
21
+    <div class="col-xs-8 col-xs-offset-2 col-md-4 col-md-offset-4" style="padding: 20px; border: 1px solid #ddd">
22
         <h2>中联医院信息管理系统登录</h2>
22
         <h2>中联医院信息管理系统登录</h2>
23
         <div class="alert alert-danger" role="alert" th:text="${error}" th:if="${error}"></div>
23
         <div class="alert alert-danger" role="alert" th:text="${error}" th:if="${error}"></div>
24
         <form class="form-horizontal" method="post" action="" id="login-form">
24
         <form class="form-horizontal" method="post" action="" id="login-form">