|
@@ -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
|
}
|