Browse Source

Merge branch 'master' of http://old.hlzaojia.com:3000/root/k-server

root 5 years ago
parent
commit
c3f5531e45

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

@@ -34,15 +34,10 @@ public class CustomUserDetailsService implements UserDetailsService {
34 34
     @Autowired
35 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 45
     @Override
51 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 52
         if(null == user )
57 53
             throw new UsernameNotFoundException("用户不存在!");
58 54
 
59 55
         String appid = this.request.getParameter("app_id");
60
-        if(null == appid)
61
-            appid = default_app_id;
62 56
         Map condition = new HashMap();
63 57
         condition.put("u_id",user.get("id").toString());
64 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 61
         if(null == appuser )
68 62
             throw new UsernameNotFoundException("用户没有权限!");
69 63
 
@@ -74,4 +68,19 @@ public class CustomUserDetailsService implements UserDetailsService {
74 68
 
75 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
 }

+ 4 - 0
src/main/java/com/kingkong/bljs/service/CommonService.java

@@ -111,5 +111,9 @@ public class CommonService {
111 111
         return Long.parseLong( result.get(0).get("id").toString());
112 112
     }
113 113
 
114
+    public void log(Object object){
115
+        System.out.println(object);
116
+    }
117
+
114 118
 
115 119
 }

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

@@ -18,7 +18,7 @@
18 18
 </head>
19 19
 <body>
20 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 22
         <h2>中联医院信息管理系统登录</h2>
23 23
         <div class="alert alert-danger" role="alert" th:text="${error}" th:if="${error}"></div>
24 24
         <form class="form-horizontal" method="post" action="" id="login-form">