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
0e149868
Commit
0e149868
authored
Jan 17, 2020
by
hanfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master_admin0117' into master_admin0117
parents
19ed2228
1c5a91d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
177 additions
and
0 deletions
+177
-0
AppUsersManageController.java
...wxiaoqi/security/admin/rest/AppUsersManageController.java
+30
-0
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+147
-0
No files found.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/AppUsersManageController.java
View file @
0e149868
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
rest
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageInfo
;
import
com.github.wxiaoqi.security.admin.biz.AppUserDetailBiz
;
import
com.github.wxiaoqi.security.admin.biz.AppUserLoginBiz
;
...
...
@@ -9,14 +10,17 @@ import com.github.wxiaoqi.security.admin.dto.AppUserManageDTO;
import
com.github.wxiaoqi.security.admin.entity.AppUserLogin
;
import
com.github.wxiaoqi.security.admin.entity.AppUserManage
;
import
com.github.wxiaoqi.security.admin.entity.User
;
import
com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService
;
import
com.github.wxiaoqi.security.admin.vo.AppUserManageVo
;
import
com.github.wxiaoqi.security.admin.vo.AppUserVo
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.auth.client.config.UserAuthConfig
;
import
com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil
;
import
com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -37,6 +41,9 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
@Autowired
private
AppUserLoginBiz
appUserLoginBiz
;
@Autowired
private
AppPermissionService
appPermissionService
;
@Autowired
private
AppUserDetailBiz
appUserDetailBiz
;
...
...
@@ -158,5 +165,28 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
}
}
/**
* 注册
* @param username
* @return
*/
@RequestMapping
(
value
=
"app/unauth/register"
,
method
=
RequestMethod
.
POST
)
@IgnoreUserToken
public
@ResponseBody
JSONObject
register
(
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
){
//默认昵称
String
nickname
=
SystemConfig
.
USER_NIKENAME_DEFAULT
+(
int
)((
Math
.
random
()*
9
+
1
)*
100000
);
String
headimgurl
=
SystemConfig
.
USER_HEADER_URL_DEFAULT
;
try
{
return
appPermissionService
.
adminRegister
(
username
,
username
,
headimgurl
,
nickname
,
null
,-
1
);
}
catch
(
Exception
e
)
{
log
.
error
(
"修改失败【{}】"
,
e
);
throw
new
BaseException
(
"修改失败"
);
}
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
0e149868
...
...
@@ -1197,6 +1197,15 @@ public class AppPermissionService {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
BaseUserMemberExportDTO
findUserMemberByUserIdAndPhone
(
String
phone
)
throws
Exception
{
List
<
BaseUserMemberExportDTO
>
memberExportDTOS
=
baseUserMemberExportBiz
.
findUserMemberExportDataByPhoneAndHashEffective
(
phone
);
if
(
CollectionUtils
.
isNotEmpty
(
memberExportDTOS
))
{
return
memberExportDTOS
.
get
(
0
);
}
return
null
;
}
private
void
insertUserMemberByExistUserMemberExportData
(
Integer
userId
,
List
<
BaseUserMemberExportDTO
>
userMemberExportDTOS
)
throws
Exception
{
UserMemberDTO
userMemberDTO
;
...
...
@@ -1244,4 +1253,142 @@ public class AppPermissionService {
}
/**
* 注册用户
*
* @param username
* @param password
* @param headimgurl
*/
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
JSONObject
adminRegister
(
String
username
,
String
password
,
String
headimgurl
,
String
nickname
,
String
code
,
Integer
channel
)
throws
Exception
{
log
.
info
(
"register------code====="
+
code
+
"----开始进入方法---time===="
+
System
.
currentTimeMillis
()/
1000L
);
String
activityCode
=
null
;
if
(
StringUtils
.
isNotBlank
(
code
)){
//判断处理活动关键字
String
[]
codes
=
code
.
split
(
"_"
);
if
(
codes
.
length
>
0
)
{
String
userCode
=
codes
[
0
];
if
(
appUserDetailBiz
.
getUserByCode
(
userCode
)==
0
)
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
NOTEXIST_CODE
,
"邀请人不存在"
);
}
}
}
// 是否已存在
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
username
);
if
(
null
!=
user
)
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
EXIST_CODE
,
"用户已存在"
);
}
BaseUserMemberExportDTO
exportDTO
=
findUserMemberByUserIdAndPhone
(
username
);
if
(
exportDTO
==
null
){
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
EXIST_CODE
,
"不是临时会员"
);
}
// 新增用户登录信息
try
{
Long
now
=
exportDTO
.
getCrtTime
()/
1000L
;
AppUserLogin
appUserLogin
=
new
AppUserLogin
();
appUserLogin
.
setUsername
(
username
);
appUserLogin
.
setPassword
(
password
);
appUserLogin
.
setIsdel
(
0
);
appUserLogin
.
setStatus
(
0
);
appUserLogin
.
setCreatetime
(
now
);
appUserLogin
.
setUpdatetime
(
now
);
appUserLoginBiz
.
insertSelective
(
appUserLogin
);
Integer
userid
=
appUserLogin
.
getId
();
log
.
info
(
"注册:新增登陆用户信息: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
// 新增用户详情
AppUserDetail
rsUserDetail
=
new
AppUserDetail
();
rsUserDetail
.
setUserid
(
userid
);
rsUserDetail
.
setNickname
(
nickname
);
rsUserDetail
.
setHeadimgurl
(
headimgurl
);
// 默认路径,待写
rsUserDetail
.
setCreatetime
(
now
);
rsUserDetail
.
setUpdatetime
(
now
);
rsUserDetail
.
setIsdel
(
0
);
rsUserDetail
.
setCrtHost
(
getIp
());
//setCreateIPInfo(rsUserDetail);
log
.
info
(
"注册:解析地址后: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
//邀请人id关系绑定
Integer
parentId
=
0
;
if
(
StringUtils
.
isNotBlank
(
code
)){
//判断处理活动关键字
String
[]
codes
=
code
.
split
(
"_"
);
if
(
codes
.
length
>
1
)
{
code
=
codes
[
0
];
activityCode
=
codes
[
1
];
}
parentId
=
appUserDetailBiz
.
getUserByCode
(
code
);
}
if
(
parentId
!=
null
&&
parentId
>
0
){
rsUserDetail
.
setSource
(
1
);
relationBiz
.
bindRelation
(
userid
,
parentId
,
1
);
if
(
StringUtils
.
isNotBlank
(
activityCode
)){
rsUserDetail
.
setInviterAccount
(
parentId
);
}
}
//生成邀请码 长度改为8 不然重复率太高
rsUserDetail
.
setCode
(
ReferralCodeUtil
.
encode
(
userid
));
rsUserDetail
.
setChannel
(
channel
);
appUserDetailBiz
.
insertSelective
(
rsUserDetail
);
log
.
info
(
"注册:新增用户详情: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
/* //绑定上下线关系
if(parentId!=null&&parentId>0){
relationBiz.bindRelation(userid,parentId,1);
}*/
//临时会员绑定
insertUserMemberByUserIdAndPhone
(
userid
,
username
);
log
.
info
(
"注册:临时会员绑定: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
//参加新人活动
jionActivity
(
userid
);
log
.
info
(
"注册:参加新人活动: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
//创建钱包
walletBiz
.
createWalletByUserId
(
appUserLogin
.
getId
());
log
.
info
(
"注册:创建钱包: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
//临时身份绑定
positionTempBiz
.
setPostionIdByPhone
(
username
);
// 登录结果要做做统一处理
JSONObject
data
=
autoLogin
(
userid
,
username
,
headimgurl
,
nickname
,
code
,
activityCode
,
1
);
log
.
info
(
"注册:登录结果要做做统一处理: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
// 到im注册,获取返回结果
Map
<
String
,
Object
>
map
=
registerIm
(
username
,
appUserLogin
.
getPassword
(),
nickname
);
log
.
info
(
"注册:到im注册: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
if
(
map
!=
null
)
{
Integer
imUserId
=
Integer
.
parseInt
(
map
.
get
(
"userId"
).
toString
());
//String access_token=map.get("access_token").toString();
String
imPassword
=
map
.
get
(
"password"
).
toString
();
if
(
imUserId
!=
null
&&
imUserId
>
0
&&
StringUtils
.
isNotBlank
(
imPassword
))
{
AppUserLogin
userLogin
=
new
AppUserLogin
();
userLogin
.
setId
(
userid
);
userLogin
.
setImPassword
(
imPassword
);
userLogin
.
setImUserid
(
imUserId
);
userLogin
.
setUsername
(
username
);
appUserLoginBiz
.
updateSelectiveById
(
userLogin
);
log
.
info
(
username
+
"----userLogin updateSelectiveById---username====="
+
username
+
"----imPassword===="
+
imPassword
);
}
//data.put("imToken",access_token);
data
.
put
(
"imUserId"
,
imUserId
);
}
log
.
info
(
"注册:处理im账号: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
if
(
data
!=
null
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"userId"
,
userid
);
jsonObject
.
put
(
"integralRuleCode"
,
"REGISTER"
);
log
.
info
(
"注册成功获取积分:发送消息 exchange = {}, routingKey = {}, json = {}"
,
RabbitConstant
.
INTEGRAL_TOPIC
,
RabbitConstant
.
INTEGRAL_ROUTING_KEY
,
jsonObject
.
toJSONString
());
mqSenderFeign
.
sendMessage
(
RabbitConstant
.
INTEGRAL_TOPIC
,
RabbitConstant
.
INTEGRAL_ROUTING_KEY
,
jsonObject
.
toJSONString
());
sendQueue
(
username
,
password
,
headimgurl
,
nickname
,
null
,
null
,
null
,
0
,
code
,
activityCode
,
userid
,
RegisterQueueDTO
.
SIGN_NEW
);
log
.
info
(
"注册:发消息队列: "
+
userid
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
return
JsonResultUtil
.
createSuccessResultWithObj
(
data
);
}
else
{
return
JsonResultUtil
.
createDefaultFail
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
EXCEPTION_CODE
,
"出现异常"
);
}
}
}
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