Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
c1cd8817
Commit
c1cd8817
authored
Jul 01, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
applet登录注册
parent
992d784b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
126 additions
and
8 deletions
+126
-8
AuthController.java
...thub/wxiaoqi/security/auth/controller/AuthController.java
+36
-0
IUserService.java
.../com/github/wxiaoqi/security/auth/feign/IUserService.java
+19
-4
AuthService.java
...com/github/wxiaoqi/security/auth/service/AuthService.java
+17
-0
AppAuthServiceImpl.java
...xiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
+10
-0
AuthServiceImpl.java
...b/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
+5
-0
AppUserLoginBiz.java
...om/github/wxiaoqi/security/admin/biz/AppUserLoginBiz.java
+1
-3
AppUserRest.java
...va/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
+17
-0
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+21
-1
No files found.
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/controller/AuthController.java
View file @
c1cd8817
...
...
@@ -166,4 +166,40 @@ public class AuthController {
}
/**
* 根据用户id登录 Unbelievable ! ! !
* @param userId
* @return
* @throws Exception
*/
@PostMapping
(
value
=
"/applet/uid/login"
)
public
JSONObject
appletLoginByUserId
(
@RequestParam
(
"userId"
)
Integer
userId
)
throws
Exception
{
JSONObject
data
=
appAuthService
.
appletLoginByUserId
(
userId
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JSONObject
result
=
data
.
getJSONObject
(
"data"
);
if
(
result
==
null
){
data
.
put
(
"status"
,
1001
);
}
else
{
String
token
=
appAuthService
.
getToken
(
String
.
valueOf
(
data
.
get
(
"username"
)),
data
.
getInteger
(
"userId"
));
data
.
put
(
"token"
,
token
);
}
}
return
data
;
}
@PostMapping
(
value
=
"/applet/registry"
)
public
JSONObject
registryWithApplet
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"pwd"
)
String
pwd
,
@RequestParam
(
"code"
)
String
code
)
throws
Exception
{
JSONObject
data
=
appAuthService
.
appletRegistry
(
phone
,
pwd
,
code
);
if
(
data
!=
null
&&
data
.
getInteger
(
"status"
)==
ResultCode
.
SUCCESS_CODE
){
JSONObject
result
=
data
.
getJSONObject
(
"data"
);
if
(
result
==
null
){
data
.
put
(
"status"
,
1001
);
}
else
{
String
token
=
appAuthService
.
getToken
(
String
.
valueOf
(
data
.
get
(
"username"
)),
data
.
getInteger
(
"userId"
));
data
.
put
(
"token"
,
token
);
}
}
return
data
;
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/feign/IUserService.java
View file @
c1cd8817
...
...
@@ -6,10 +6,7 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import
com.github.wxiaoqi.security.auth.configuration.FeignConfiguration
;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.*
;
/**
...
...
@@ -51,4 +48,22 @@ public interface IUserService {
public
JSONObject
reset
(
@RequestParam
(
value
=
"username"
)
String
username
,
@RequestParam
(
value
=
"mobilecode"
)
String
mobilecode
,
@RequestParam
(
value
=
"password"
)
String
password
);
/**
* 小程序通过用户id登录登录
* @param userid
* @return
*/
@PostMapping
(
"/api/app/applet/uid/login"
)
JSONObject
appletLogin
(
@RequestParam
(
value
=
"userid"
)
Integer
userid
);
/**
* 小程序注册
* @param phone
* @param pwd
* @param code
* @return
*/
@PostMapping
(
"/api/app/applet/registry"
)
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"phone"
)
String
phone
,
@RequestParam
(
"pwd"
)
String
pwd
,
@RequestParam
(
"code"
)
String
code
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/AuthService.java
View file @
c1cd8817
...
...
@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.auth.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
import
org.springframework.web.bind.annotation.RequestParam
;
public
interface
AuthService
{
String
login
(
JwtAuthenticationRequest
authenticationRequest
)
throws
Exception
;
...
...
@@ -16,4 +17,20 @@ public interface AuthService {
JSONObject
tlogin
(
String
username
,
String
password
,
String
mobilecode
,
Integer
type
)
throws
Exception
;
String
getToken
(
String
username
,
Integer
id
)
throws
Exception
;
JSONObject
reset
(
String
username
,
String
mobilecode
,
String
password
)
throws
Exception
;
/**
* 使用用户id登录 Unbelievable ! ! !
* @param userid
* @return
*/
JSONObject
appletLoginByUserId
(
Integer
userid
);
/**
* 通过小程序注册
* @param phone
* @param pwd
* @param code
* @return
*/
JSONObject
appletRegistry
(
String
phone
,
String
pwd
,
String
code
);
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AppAuthServiceImpl.java
View file @
c1cd8817
...
...
@@ -86,4 +86,14 @@ public class AppAuthServiceImpl implements AuthService {
return
userService
.
reset
(
username
,
mobilecode
,
password
);
}
@Override
public
JSONObject
appletLoginByUserId
(
Integer
userid
)
{
return
userService
.
appletLogin
(
userid
);
}
@Override
public
JSONObject
appletRegistry
(
String
phone
,
String
pwd
,
String
code
)
{
return
userService
.
appletRegistry
(
phone
,
pwd
,
code
);
}
}
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/service/impl/AuthServiceImpl.java
View file @
c1cd8817
...
...
@@ -83,4 +83,9 @@ public class AuthServiceImpl implements AuthService {
public
JSONObject
reset
(
String
username
,
String
mobilecode
,
String
password
)
throws
Exception
{
return
userService
.
reset
(
username
,
mobilecode
,
password
);
}
@Override
public
JSONObject
loginWithUserId
(
Integer
userid
)
{
return
userService
.
login
(
userid
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserLoginBiz.java
View file @
c1cd8817
...
...
@@ -100,7 +100,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public
AppUserLogin
checkeUserLogin
(
String
username
)
{
Example
example
=
new
Example
(
AppUserLogin
.
class
);
example
.
createCriteria
().
andEqualTo
(
"username"
,
username
).
andEqualTo
(
"isdel"
,
0
);
example
.
createCriteria
().
andEqualTo
(
"username"
,
username
).
andEqualTo
(
"isdel"
,
0
)
.
andEqualTo
(
"status"
,
0
)
;
List
<
AppUserLogin
>
userLoginList
=
mapper
.
selectByExample
(
example
);
if
(
userLoginList
!=
null
&&
userLoginList
.
size
()
!=
0
)
{
return
userLoginList
.
get
(
0
);
...
...
@@ -149,6 +149,4 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public
AppUserLogin
getUserById
(
Integer
userId
){
return
mapper
.
selectByPrimaryKey
(
userId
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
View file @
c1cd8817
...
...
@@ -171,5 +171,22 @@ public class AppUserRest {
return
appPermissionService
.
upAuthentication
(
userId
,
name
,
idNumber
,
status
);
}
/**
* 通过用户id登录 unbelievable! ! !
* @param userid
* @return
*/
@PostMapping
(
"/applet/uid/login"
)
public
JSONObject
appletLogin
(
@RequestParam
(
value
=
"userid"
)
Integer
userid
){
return
appPermissionService
.
appletLoginByUserId
(
userid
);
}
@PostMapping
(
"/applet/registry"
)
public
JSONObject
appletRegistry
(
@RequestParam
(
value
=
"phone"
)
String
phone
,
@RequestParam
(
"pwd"
)
String
pwd
,
@RequestParam
(
"code"
)
String
code
){
//默认昵称
String
nickname
=
SystemConfig
.
USER_NIKENAME_DEFAULT
+(
int
)((
Math
.
random
()*
9
+
1
)*
100000
);
return
appPermissionService
.
appletRegistry
(
phone
,
nickname
,
pwd
,
code
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
c1cd8817
...
...
@@ -283,7 +283,7 @@ public class AppPermissionService {
//userRedisTemplate.opsForValue().set("imtoken_" + userid,imtoken_,SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
// 返回结果
// data.put("token", token);
data
.
put
(
"username"
,
username
);
data
.
put
(
"username"
,
StringUtils
.
isNotEmpty
(
username
)?
username:
userLoign
.
getUsername
()
);
data
.
put
(
"userId"
,
userid
);
}
...
...
@@ -657,4 +657,24 @@ public class AppPermissionService {
}
/**
* 通过用户id登录*** Unbelievable! ! !
* @param uid
* @return
*/
public
JSONObject
appletLoginByUserId
(
Integer
uid
)
{
return
autoLogin
(
uid
,
null
,
null
,
null
);
}
/**
*通过小程序注册
* @param phone
* @param pwd
* @param code
* @return
*/
public
JSONObject
appletRegistry
(
String
phone
,
String
nickname
,
String
pwd
,
String
code
){
return
register
(
phone
,
pwd
,
null
,
nickname
,
code
,
null
,
null
,
null
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment