Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
tcm-system
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
TCM
tcm-system
Commits
e62f55c3
Commit
e62f55c3
authored
Aug 11, 2020
by
tangf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改注册流程
parent
070f27d6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
162 additions
and
9 deletions
+162
-9
LoginController.java
...om/pangding/web/authority/controller/LoginController.java
+4
-0
UserController.java
...com/pangding/web/authority/controller/UserController.java
+23
-0
CompanyDaoImpl.java
...a/com/pangding/web/authority/dao/impl/CompanyDaoImpl.java
+4
-0
UserService.java
.../java/com/pangding/web/authority/service/UserService.java
+10
-0
RegisterServiceImpl.java
...gding/web/authority/service/impl/RegisterServiceImpl.java
+2
-2
UserServiceImpl.java
.../pangding/web/authority/service/impl/UserServiceImpl.java
+119
-7
No files found.
src/main/java/com/pangding/web/authority/controller/LoginController.java
View file @
e62f55c3
...
@@ -6,6 +6,8 @@ import com.pangding.web.authority.vo.cloudvo.LoginResVo;
...
@@ -6,6 +6,8 @@ import com.pangding.web.authority.vo.cloudvo.LoginResVo;
import
com.pangding.web.vo.system.req.LoginReqVo
;
import
com.pangding.web.vo.system.req.LoginReqVo
;
import
com.yanzuoguang.util.helper.CheckerHelper
;
import
com.yanzuoguang.util.helper.CheckerHelper
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -21,6 +23,7 @@ import java.io.IOException;
...
@@ -21,6 +23,7 @@ import java.io.IOException;
*/
*/
@RestController
@RestController
@RequestMapping
(
value
=
"login"
)
@RequestMapping
(
value
=
"login"
)
@Api
(
value
=
"用户登录类"
)
public
class
LoginController
{
public
class
LoginController
{
@Autowired
@Autowired
RegisterService
registerServiceImpl
;
RegisterService
registerServiceImpl
;
...
@@ -34,6 +37,7 @@ public class LoginController {
...
@@ -34,6 +37,7 @@ public class LoginController {
* @param reqVo
* @param reqVo
* @return
* @return
*/
*/
@ApiOperation
(
value
=
"登录"
,
notes
=
"返回登录信息"
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
LoginResVo
>
mobile
(
@RequestBody
LoginReqVo
reqVo
)
throws
Exception
{
public
ResponseResult
<
LoginResVo
>
mobile
(
@RequestBody
LoginReqVo
reqVo
)
throws
Exception
{
CheckerHelper
.
newInstance
()
CheckerHelper
.
newInstance
()
...
...
src/main/java/com/pangding/web/authority/controller/UserController.java
View file @
e62f55c3
...
@@ -6,11 +6,14 @@ import com.pangding.web.authority.vo.reqvo.*;
...
@@ -6,11 +6,14 @@ import com.pangding.web.authority.vo.reqvo.*;
import
com.pangding.web.authority.service.UserService
;
import
com.pangding.web.authority.service.UserService
;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.util.RSAUtils
;
import
com.pangding.web.util.RSAUtils
;
import
com.pangding.web.vo.system.req.authority.SaveUserReqVo
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.CheckerHelper
;
import
com.yanzuoguang.util.helper.CheckerHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -105,4 +108,24 @@ public class UserController {
...
@@ -105,4 +108,24 @@ public class UserController {
return
ResponseResult
.
result
(
userServiceImpl
.
getUserById
(
webUserReqVo
.
getId
()));
return
ResponseResult
.
result
(
userServiceImpl
.
getUserById
(
webUserReqVo
.
getId
()));
}
}
/**
* 注册用户(新)
* @param //id
* @return
*/
@ApiOperation
(
value
=
"注册"
,
notes
=
"返回注册信息"
)
@RequestMapping
(
value
=
"/registerUser"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
String
>
registerUser
(
@RequestBody
SaveUserReqVo
saveUserReqVo
){
CheckerHelper
.
newInstance
()
.
notBlankCheck
(
"account"
,
saveUserReqVo
.
getAccount
())
.
notBlankCheck
(
"password"
,
saveUserReqVo
.
getPassword
())
.
notBlankCheck
(
"confirmPassword"
,
saveUserReqVo
.
getConfirmPassword
())
.
notBlankCheck
(
"companyType"
,
saveUserReqVo
.
getCompanyType
())
.
notBlankCheck
(
"invitationCode"
,
saveUserReqVo
.
getInvitationCode
())
.
checkException
();
return
userServiceImpl
.
registerSaveUser
(
saveUserReqVo
);
}
}
}
src/main/java/com/pangding/web/authority/dao/impl/CompanyDaoImpl.java
View file @
e62f55c3
...
@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl;
...
@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl;
import
com.pangding.web.authority.dao.CompanyDao
;
import
com.pangding.web.authority.dao.CompanyDao
;
import
com.pangding.web.authority.vo.reqvo.ListCompanyReqVo
;
import
com.pangding.web.authority.vo.reqvo.ListCompanyReqVo
;
import
com.pangding.web.vo.system.pd.company.CompanyVo
;
import
com.pangding.web.vo.system.pd.company.CompanyVo
;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.dao.impl.BaseDaoImpl
;
import
com.yanzuoguang.dao.impl.BaseDaoImpl
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -27,6 +28,9 @@ public class CompanyDaoImpl extends BaseDaoImpl implements CompanyDao {
...
@@ -27,6 +28,9 @@ public class CompanyDaoImpl extends BaseDaoImpl implements CompanyDao {
.
add
(
"companyAttribute"
,
"and company_attribute = ? "
)
.
add
(
"companyAttribute"
,
"and company_attribute = ? "
)
.
add
(
"examineStatus"
,
"and examine_status = ?"
)
.
add
(
"examineStatus"
,
"and examine_status = ?"
)
.
add
(
"companyId"
,
"and invitation_company_id = ? "
);
.
add
(
"companyId"
,
"and invitation_company_id = ? "
);
getSql
(
DaoConst
.
LOAD
).
addCode
(
"{FIELD}"
,
",b.*"
,
"{INNER}"
,
"INNER JOIN pd_compnay_extend b ON a.id = b.id"
);
}
}
@Override
@Override
...
...
src/main/java/com/pangding/web/authority/service/UserService.java
View file @
e62f55c3
...
@@ -5,7 +5,9 @@ import com.pangding.web.authority.vo.*;
...
@@ -5,7 +5,9 @@ import com.pangding.web.authority.vo.*;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.vo.system.pd.authority.RoleVo
;
import
com.pangding.web.vo.system.pd.authority.RoleVo
;
import
com.pangding.web.vo.system.pd.authority.UserVo
;
import
com.pangding.web.vo.system.pd.authority.UserVo
;
import
com.pangding.web.vo.system.req.authority.SaveUserReqVo
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
java.util.List
;
import
java.util.List
;
...
@@ -140,4 +142,12 @@ public interface UserService {
...
@@ -140,4 +142,12 @@ public interface UserService {
List
<
RoleVo
>
getRoleListByUserId
(
String
userId
);
List
<
RoleVo
>
getRoleListByUserId
(
String
userId
);
void
checkEmail
(
String
email
);
void
checkEmail
(
String
email
);
/**
* 用户注册(新tangfang)
* @param saveUserReqVo
* @return
*/
ResponseResult
<
String
>
registerSaveUser
(
SaveUserReqVo
saveUserReqVo
);
}
}
src/main/java/com/pangding/web/authority/service/impl/RegisterServiceImpl.java
View file @
e62f55c3
...
@@ -321,14 +321,14 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -321,14 +321,14 @@ public class RegisterServiceImpl implements RegisterService {
/*保存或更新商户表*/
/*保存或更新商户表*/
MerchantCreateReqVo
req
=
new
MerchantCreateReqVo
();
MerchantCreateReqVo
req
=
new
MerchantCreateReqVo
();
req
.
setReqId
(
StringHelper
.
getNewID
());
//
req.setReqId(StringHelper.getNewID());
req
.
setName
(
reqVo
.
getMerchantName
());
req
.
setName
(
reqVo
.
getMerchantName
());
req
.
setType
(
reqVo
.
getCompanyAttribute
());
req
.
setType
(
reqVo
.
getCompanyAttribute
());
req
.
setProductCompanyId
(
reqVo
.
getId
());
req
.
setProductCompanyId
(
reqVo
.
getId
());
req
.
setUserId
(
userVo
.
getId
());
req
.
setUserId
(
userVo
.
getId
());
req
.
setUsername
(
userVo
.
getAccount
());
req
.
setUsername
(
userVo
.
getAccount
());
if
(
null
==
reqVo
.
getMerchantId
()
||
""
.
equals
(
reqVo
.
getMerchantId
()))
{
if
(
null
==
reqVo
.
getMerchantId
()
||
""
.
equals
(
reqVo
.
getMerchantId
()))
{
req
.
setId
(
StringHelper
.
getNewID
());
//
req.setId(StringHelper.getNewID());
}
else
{
}
else
{
req
.
setId
(
reqVo
.
getMerchantId
());
req
.
setId
(
reqVo
.
getMerchantId
());
}
}
...
...
src/main/java/com/pangding/web/authority/service/impl/UserServiceImpl.java
View file @
e62f55c3
package
com
.
pangding
.
web
.
authority
.
service
.
impl
;
package
com
.
pangding
.
web
.
authority
.
service
.
impl
;
import
com.pangding.web.authority.dao.RoleDao
;
import
com.pangding.web.authority.dao.*
;
import
com.pangding.web.authority.dao.UserDao
;
import
com.pangding.web.authority.util.CompanyConstant
;
import
com.pangding.web.authority.dao.UserRoleDao
;
import
com.pangding.web.authority.util.RsaConstant
;
import
com.pangding.web.authority.util.RsaConstant
;
import
com.pangding.web.authority.vo.reqvo.*
;
import
com.pangding.web.authority.vo.reqvo.*
;
import
com.pangding.web.authority.service.UserService
;
import
com.pangding.web.authority.service.UserService
;
import
com.pangding.web.authority.vo.*
;
import
com.pangding.web.authority.vo.*
;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.authority.vo.resvo.WebUserResVo
;
import
com.pangding.web.constant.AuthorityConstant
;
import
com.pangding.web.util.RSAUtils
;
import
com.pangding.web.util.RSAUtils
;
import
com.pangding.web.vo.system.pd.authority.RoleAuthorityVo
;
import
com.pangding.web.vo.system.pd.authority.RoleVo
;
import
com.pangding.web.vo.system.pd.authority.RoleVo
;
import
com.pangding.web.vo.system.pd.authority.UserVo
;
import
com.pangding.web.vo.system.pd.authority.UserVo
;
import
com.pangding.web.vo.system.pd.company.CompanyExtendVo
;
import
com.pangding.web.vo.system.pd.company.CompanyVo
;
import
com.pangding.web.vo.system.req.authority.AuthorityReqVo
;
import
com.pangding.web.vo.system.req.authority.SaveUserReqVo
;
import
com.pangding.web.vo.system.req.authority.UserReqVo
;
import
com.pangding.web.vo.system.req.company.CompanyExtendReqVo
;
import
com.pangding.web.vo.system.req.company.CompanyReqVo
;
import
com.pangding.web.vo.system.res.authority.AuthorityResVo
;
import
com.pangding.web.vo.system.res.company.CompanyResVo
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -30,12 +43,18 @@ public class UserServiceImpl implements UserService {
...
@@ -30,12 +43,18 @@ public class UserServiceImpl implements UserService {
@Autowired
@Autowired
UserDao
userDao
;
UserDao
userDao
;
@Autowired
@Autowired
UserRoleDao
userRoleDao
;
UserRoleDao
userRoleDao
;
@Autowired
@Autowired
RoleDao
roleDao
;
RoleDao
roleDao
;
@Autowired
private
AuthorityDao
authorityDao
;
@Autowired
private
RoleAuthorityDao
roleAuthorityDao
;
@Autowired
private
CompanyDao
companyDao
;
@Autowired
private
CompanyExtendDao
companyExtendDao
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -113,8 +132,8 @@ public class UserServiceImpl implements UserService {
...
@@ -113,8 +132,8 @@ public class UserServiceImpl implements UserService {
this
.
isValid
(
webUserReqVo
.
getAccount
());
this
.
isValid
(
webUserReqVo
.
getAccount
());
this
.
checkAccount
(
webUserReqVo
);
this
.
checkAccount
(
webUserReqVo
);
this
.
checkPhone
(
webUserReqVo
);
this
.
checkPhone
(
webUserReqVo
);
ObjectHelper
.
writeWithFrom
(
userVo
,
webUserReqVo
);
ObjectHelper
.
writeWithFrom
(
userVo
,
webUserReqVo
);
}
else
{
}
else
{
userVo
.
setRemark
(
webUserReqVo
.
getPassword
());
userVo
.
setRemark
(
webUserReqVo
.
getPassword
());
userVo
.
setPassword
(
this
.
passwordEncoder
(
webUserReqVo
.
getPassword
()));
userVo
.
setPassword
(
this
.
passwordEncoder
(
webUserReqVo
.
getPassword
()));
}
}
...
@@ -304,4 +323,97 @@ public class UserServiceImpl implements UserService {
...
@@ -304,4 +323,97 @@ public class UserServiceImpl implements UserService {
}
}
return
null
;
return
null
;
}
}
/**
* tangfang
* 注册保存用户信息
*
* @param saveUserReqVo
*/
@Override
public
ResponseResult
<
String
>
registerSaveUser
(
SaveUserReqVo
saveUserReqVo
){
// 用户名是否存在
UserReqVo
userReqVo
=
new
UserReqVo
();
userReqVo
.
setAccount
(
saveUserReqVo
.
getAccount
());
UserVo
userVo
=
userDao
.
load
(
userReqVo
,
UserVo
.
class
);
if
(!
StringHelper
.
isEmpty
(
userVo
))
{
// 用户名已存在
return
ResponseResult
.
error
(
"99"
,
"该用户名已存在"
);
}
try
{
/*将RSA加密后的密码解密*/
String
password
=
RSAUtils
.
decryptionByPrivateKey
(
saveUserReqVo
.
getPassword
(),
RsaConstant
.
privateKey
);
String
confirmPassword
=
RSAUtils
.
decryptionByPrivateKey
(
saveUserReqVo
.
getConfirmPassword
(),
RsaConstant
.
privateKey
);
if
(!
StringHelper
.
compare
(
password
,
confirmPassword
))
{
return
ResponseResult
.
error
(
"99"
,
"两次填写的密码不相等"
);
}
// 验证邀请码是否正确
CompanyReqVo
companyReqVo
=
new
CompanyReqVo
();
companyReqVo
.
setInvitationCode
(
saveUserReqVo
.
getInvitationCode
());
CompanyResVo
companyResVo
=
companyDao
.
load
(
companyReqVo
,
CompanyResVo
.
class
);
if
(
StringHelper
.
isEmpty
(
companyResVo
)){
// 邀请码不正确
return
ResponseResult
.
error
(
"99"
,
"邀请码错误"
);
}
// TODO 是否需要判断商户的状态
String
companyId
=
StringHelper
.
getNewID
();
String
userId
=
StringHelper
.
getNewID
();
// 保存用户表
userVo
=
new
UserVo
();
userVo
.
setId
(
userId
);
userVo
.
setAccount
(
saveUserReqVo
.
getAccount
());
userVo
.
setPassword
(
this
.
passwordEncoder
(
password
));
userVo
.
setRemark
(
password
);
userVo
.
setCompanyId
(
companyId
);
userVo
.
setCreateTime
(
DateHelper
.
getNow
());
userVo
.
setCreateId
(
userId
);
userVo
.
setCreateName
(
saveUserReqVo
.
getAccount
());
userDao
.
create
(
userVo
);
// 保存公司表
CompanyVo
companyVo
=
new
CompanyVo
();
companyVo
.
setId
(
companyId
);
companyVo
.
setInvitationCompanyId
(
companyResVo
.
getId
());
companyVo
.
setStatus
(
CompanyConstant
.
COMPANY_STATUS_INIT
);
companyDao
.
create
(
companyVo
);
// 保存公司扩展信息表
CompanyExtendVo
companyExtendVo
=
new
CompanyExtendVo
();
companyExtendVo
.
setId
(
companyId
);
companyExtendDao
.
create
(
companyExtendVo
);
String
roleId
=
StringHelper
.
getNewID
();
// 保存角色表
RoleVo
roleVo
=
new
RoleVo
();
roleVo
.
setId
(
roleId
);
roleVo
.
setCompanyId
(
companyId
);
roleVo
.
setName
(
saveUserReqVo
+
"Admin"
);
roleVo
.
setRemark
(
saveUserReqVo
+
"Admin"
);
// 保存角色用户表
UserRoleVo
userRoleVo
=
new
UserRoleVo
();
userRoleVo
.
setId
(
StringHelper
.
getNewID
());
userRoleVo
.
setUserId
(
userId
);
userRoleVo
.
setRoleId
(
roleId
);
// 保存角色权限表 先查询默认权限,跟角色添加默认权限
AuthorityReqVo
authorityReqVo
=
new
AuthorityReqVo
();
authorityReqVo
.
setAuthorityLevel
(
AuthorityConstant
.
AUTHORITY_LEVEL_DEFAULT
);
List
<
AuthorityResVo
>
authorityResVoList
=
authorityDao
.
loadList
(
authorityReqVo
,
AuthorityResVo
.
class
);
for
(
int
i
=
0
;
i
<
authorityResVoList
.
size
();
i
++){
AuthorityResVo
authorityResVo
=
authorityResVoList
.
get
(
i
);
RoleAuthorityVo
roleAuthorityVo
=
new
RoleAuthorityVo
();
roleAuthorityVo
.
setId
(
StringHelper
.
getNewID
());
roleAuthorityVo
.
setAuthorityId
(
authorityResVo
.
getId
());
roleAuthorityVo
.
setRoleId
(
roleId
);
roleAuthorityDao
.
create
(
roleAuthorityVo
);
}
return
ResponseResult
.
result
(
"注册成功"
);
}
catch
(
Exception
e
){
return
ResponseResult
.
error
(
"99"
,
e
.
getMessage
());
}
}
}
}
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