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
b44c9801
Commit
b44c9801
authored
Jul 13, 2019
by
zjy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user/role/tright 7.13
parent
b9c15408
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
132 additions
and
55 deletions
+132
-55
AuthorityServiceImpl.java
...ding/web/authority/service/impl/AuthorityServiceImpl.java
+63
-27
CompanyServiceImpl.java
...ngding/web/authority/service/impl/CompanyServiceImpl.java
+5
-13
DataServiceImpl.java
.../pangding/web/authority/service/impl/DataServiceImpl.java
+0
-14
RegisterServiceImpl.java
...gding/web/authority/service/impl/RegisterServiceImpl.java
+2
-1
RoleVo.java
src/main/java/com/pangding/web/authority/vo/RoleVo.java
+11
-0
UserVo.java
src/main/java/com/pangding/web/authority/vo/UserVo.java
+11
-0
AuthorityListReqVo.java
...m/pangding/web/authority/vo/reqvo/AuthorityListReqVo.java
+10
-0
RoleGetReqVo.java
...ava/com/pangding/web/authority/vo/reqvo/RoleGetReqVo.java
+20
-0
UserGetReqVo.java
...ava/com/pangding/web/authority/vo/reqvo/UserGetReqVo.java
+10
-0
No files found.
src/main/java/com/pangding/web/authority/service/impl/AuthorityServiceImpl.java
View file @
b44c9801
package
com
.
pangding
.
web
.
authority
.
service
.
impl
;
package
com
.
pangding
.
web
.
authority
.
service
.
impl
;
import
com.pangding.web.authority.dao.RoleAuthorityDao
;
import
com.pangding.web.authority.dao.*
;
import
com.pangding.web.authority.dao.AuthorityDao
;
import
com.pangding.web.authority.dao.UserDao
;
import
com.pangding.web.authority.dao.UserRoleDao
;
import
com.pangding.web.authority.util.RoleConstant
;
import
com.pangding.web.authority.util.RoleConstant
;
import
com.pangding.web.authority.vo.reqvo.*
;
import
com.pangding.web.authority.vo.reqvo.*
;
import
com.pangding.web.authority.service.AuthorityService
;
import
com.pangding.web.authority.service.AuthorityService
;
...
@@ -20,8 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -20,8 +17,7 @@ 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.*
;
import
java.util.List
;
/**
/**
* @author zhangjinyao
* @author zhangjinyao
...
@@ -37,6 +33,10 @@ public class AuthorityServiceImpl implements AuthorityService {
...
@@ -37,6 +33,10 @@ public class AuthorityServiceImpl implements AuthorityService {
UserDao
userDaoImpl
;
UserDao
userDaoImpl
;
@Autowired
@Autowired
UserRoleDao
userRoleDaoImpl
;
UserRoleDao
userRoleDaoImpl
;
@Autowired
private
RegisterServiceImpl
registerServiceImpl
;
@Autowired
private
RoleDao
roleDaoImpl
;
/**
/**
* 保存authorityVo对象数据
* 保存authorityVo对象数据
...
@@ -248,31 +248,67 @@ public class AuthorityServiceImpl implements AuthorityService {
...
@@ -248,31 +248,67 @@ public class AuthorityServiceImpl implements AuthorityService {
@Override
@Override
public
AuthorityListResVo
getListByLevel
(
AuthorityListReqVo
reqVo
)
{
public
AuthorityListResVo
getListByLevel
(
AuthorityListReqVo
reqVo
)
{
List
<
AuthorityVo
>
parentList
=
authorityDao
.
getLevelOne
(
reqVo
);
RoleGetReqVo
roleGetReqVo
=
new
RoleGetReqVo
();
if
(
null
==
parentList
||
parentList
.
isEmpty
()){
roleGetReqVo
.
setCompanyId
(
reqVo
.
getCompanyId
());
throw
new
CodeException
(
"暂无一级权限,请添加"
);
roleGetReqVo
.
setIsAdmin
(
1
);
}
RoleVo
roleVo
=
roleDaoImpl
.
load
(
roleGetReqVo
,
RoleVo
.
class
);
List
<
AuthorityListByLevelResVo
>
resVoList
=
new
ArrayList
();
if
(
roleVo
==
null
){
for
(
AuthorityVo
authorityVo:
parentList
)
{
throw
new
CodeException
(
"该公司用户未设置管理员角色"
);
AuthorityListByLevelResVo
resVo
=
new
AuthorityListByLevelResVo
();
}
ObjectHelper
.
writeWithFrom
(
resVo
,
authorityVo
);
Set
authorityIdSet
=
new
HashSet
();
List
<
AuthorityListByLevelResVo
>
childList
=
getChildList
(
authorityVo
.
getId
());
resVo
.
setChildList
(
childList
);
RoleAuthorityGetReqVo
roleAuthorityGetReqVo
=
new
RoleAuthorityGetReqVo
();
resVoList
.
add
(
resVo
);
roleAuthorityGetReqVo
.
setRoleId
(
roleVo
.
getId
());
List
<
RoleAuthorityVo
>
roleAuthorityVoList
=
roleAuthorityDao
.
loadList
(
roleAuthorityGetReqVo
,
RoleAuthorityVo
.
class
);
for
(
RoleAuthorityVo
roleAuthorityVo:
roleAuthorityVoList
)
{
authorityIdSet
.
add
(
roleAuthorityVo
.
getAuthorityId
());
}
}
/*返回对象*/
List
<
String
>
authorityIdList
=
new
ArrayList
<>();
Object
[]
objs
=
authorityIdSet
.
toArray
();
for
(
Object
obj:
objs
)
{
authorityIdList
.
add
((
String
)
obj
);
}
List
<
AuthorityVo
>
levelOneList
=
new
ArrayList
();
for
(
int
i
=
0
;
i
<
authorityIdList
.
size
();
i
++)
{
AuthorityGetReqVo
authorityGetReqVo
=
new
AuthorityGetReqVo
();
authorityGetReqVo
.
setId
(
authorityIdList
.
get
(
i
));
AuthorityVo
authorityVo
=
authorityDao
.
load
(
authorityGetReqVo
,
AuthorityVo
.
class
);
if
(
null
==
authorityVo
.
getPid
()
||
authorityVo
.
getPid
().
isEmpty
()){
levelOneList
.
add
(
authorityVo
);
authorityIdList
.
set
(
i
,
""
);
}
}
List
<
String
>
authorityIds
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
authorityIdList
.
size
();
i
++)
{
if
(!
""
.
equals
(
authorityIdList
.
get
(
i
))){
authorityIds
.
add
(
authorityIdList
.
get
(
i
));
}
}
Collections
.
sort
(
levelOneList
);
if
(
levelOneList
.
isEmpty
()){
throw
new
CodeException
(
"该用户暂无权限,请添加"
);
}
List
<
AuthorityListByLevelResVo
>
authorityListByLevel
=
new
ArrayList
<>();
for
(
AuthorityVo
authorityVo:
levelOneList
)
{
AuthorityListByLevelResVo
resVo1
=
new
AuthorityListByLevelResVo
();
ObjectHelper
.
writeWithFrom
(
resVo1
,
authorityVo
);
List
<
AuthorityListByLevelResVo
>
childList
=
registerServiceImpl
.
getChildList
(
authorityVo
,
authorityIds
);
resVo1
.
setChildList
(
childList
);
authorityListByLevel
.
add
(
resVo1
);
}
Collections
.
sort
(
authorityListByLevel
);
AuthorityListResVo
authorityListResVo
=
new
AuthorityListResVo
();
AuthorityListResVo
authorityListResVo
=
new
AuthorityListResVo
();
authorityListResVo
.
setAuthorityListByLevel
(
resVoList
);
authorityListResVo
.
setAuthorityListByLevel
(
authorityListByLevel
);
/*若roleId存在,则需要返回该角色拥有的权限列表*/
/*若roleId存在,则需要返回该角色拥有的权限列表*/
if
(
null
!=
reqVo
.
getRoleId
()
&&
!
reqVo
.
getRoleId
().
isEmpty
()){
if
(
null
!=
reqVo
.
getRoleId
()
&&
!
reqVo
.
getRoleId
().
isEmpty
()){
RoleAuthorityGetReqVo
roleAuthorityGetReqVo
=
new
RoleAuthorityGetReqVo
();
RoleAuthorityGetReqVo
roleAuthorityGetReqVo
1
=
new
RoleAuthorityGetReqVo
();
roleAuthorityGetReqVo
.
setRoleId
(
reqVo
.
getRoleId
());
roleAuthorityGetReqVo
1
.
setRoleId
(
reqVo
.
getRoleId
());
List
<
RoleAuthorityVo
>
roleAuthorityVo
List
=
roleAuthorityDao
.
loadList
(
roleAuthorityGetReqVo
,
RoleAuthorityVo
.
class
);
List
<
RoleAuthorityVo
>
roleAuthorityVo
s
=
roleAuthorityDao
.
loadList
(
roleAuthorityGetReqVo1
,
RoleAuthorityVo
.
class
);
List
<
AuthorityVo
>
authorityVoList
=
new
ArrayList
<>();
List
<
AuthorityVo
>
authorityVoList
=
new
ArrayList
<>();
if
(
null
!=
roleAuthorityVo
List
&&
!
roleAuthorityVoList
.
isEmpty
()){
if
(
null
!=
roleAuthorityVo
s
&&
!
roleAuthorityVos
.
isEmpty
()){
for
(
RoleAuthorityVo
roleAuthorityVo:
roleAuthorityVo
List
)
{
for
(
RoleAuthorityVo
roleAuthorityVo:
roleAuthorityVo
s
)
{
AuthorityGetReqVo
getReqVo
=
new
AuthorityGetReqVo
();
AuthorityGetReqVo
getReqVo
=
new
AuthorityGetReqVo
();
getReqVo
.
setId
(
roleAuthorityVo
.
getAuthorityId
());
getReqVo
.
setId
(
roleAuthorityVo
.
getAuthorityId
());
AuthorityVo
authorityVo
=
authorityDao
.
load
(
getReqVo
,
AuthorityVo
.
class
);
AuthorityVo
authorityVo
=
authorityDao
.
load
(
getReqVo
,
AuthorityVo
.
class
);
...
@@ -306,10 +342,10 @@ public class AuthorityServiceImpl implements AuthorityService {
...
@@ -306,10 +342,10 @@ public class AuthorityServiceImpl implements AuthorityService {
@Override
@Override
public
List
<
AuthorityListByLevelResVo
>
getCompanyAuthority
(
CompanyAuthorityReqVo
reqVo
)
{
public
List
<
AuthorityListByLevelResVo
>
getCompanyAuthority
(
CompanyAuthorityReqVo
reqVo
)
{
UserGet
SuperAdminReqVo
userGetSuperAdminReqVo
=
new
UserGetSuperAdmin
ReqVo
();
UserGet
ReqVo
userGetReqVo
=
new
UserGet
ReqVo
();
userGet
SuperAdmin
ReqVo
.
setCompanyId
(
reqVo
.
getCompanyId
());
userGetReqVo
.
setCompanyId
(
reqVo
.
getCompanyId
());
userGet
SuperAdminReqVo
.
setAdminRoleId
(
RoleConstant
.
SUPER_ADMIN_ROLE_ID
);
userGet
ReqVo
.
setIsFirst
(
1
);
UserVo
superAdmin
=
userDaoImpl
.
getAdmin
(
userGetSuperAdminReqVo
);
UserVo
superAdmin
=
userDaoImpl
.
load
(
userGetReqVo
,
UserVo
.
class
);
if
(
null
==
superAdmin
){
if
(
null
==
superAdmin
){
throw
new
CodeException
(
"暂无超级管理员"
);
throw
new
CodeException
(
"暂无超级管理员"
);
}
}
...
...
src/main/java/com/pangding/web/authority/service/impl/CompanyServiceImpl.java
View file @
b44c9801
...
@@ -96,13 +96,13 @@ public class CompanyServiceImpl implements CompanyService {
...
@@ -96,13 +96,13 @@ public class CompanyServiceImpl implements CompanyService {
public
CompanyResVo
pdGetDetail
(
CompanyGetReqVo
reqVo
)
{
public
CompanyResVo
pdGetDetail
(
CompanyGetReqVo
reqVo
)
{
CompanyResVo
resVo
=
getDetail
(
reqVo
);
CompanyResVo
resVo
=
getDetail
(
reqVo
);
/*获取用户表信息*/
/*获取用户表信息*/
/*UserGetSuperAdminReqVo req = new UserGetSuperAdmin
ReqVo();
UserGetReqVo
userGetReqVo
=
new
UserGet
ReqVo
();
req.setCompanyId(reqVo.getId()
);
userGetReqVo
.
setIsFirst
(
1
);
req.setAdminRoleId(RoleConstant.ADMIN_ROLE_ID
);
userGetReqVo
.
setCompanyId
(
reqVo
.
getId
()
);
UserVo userVo = userDaoImpl.
getAdmin(req
);
UserVo
userVo
=
userDaoImpl
.
load
(
userGetReqVo
,
UserVo
.
class
);
if
(
null
!=
userVo
)
{
if
(
null
!=
userVo
)
{
resVo
.
setUserVo
(
userVo
);
resVo
.
setUserVo
(
userVo
);
}
*/
}
return
resVo
;
return
resVo
;
}
}
...
@@ -268,14 +268,6 @@ public class CompanyServiceImpl implements CompanyService {
...
@@ -268,14 +268,6 @@ public class CompanyServiceImpl implements CompanyService {
userServiceImpl
.
checkPhone
(
userVo
);
userServiceImpl
.
checkPhone
(
userVo
);
userDaoImpl
.
create
(
userVo
);
userDaoImpl
.
create
(
userVo
);
/*将该用户设置为超级管理员*/
UserRoleVo
userRoleVo
=
new
UserRoleVo
();
userRoleVo
.
setId
(
StringHelper
.
getNewID
());
userRoleVo
.
setUserId
(
userVo
.
getId
());
userRoleVo
.
setRoleId
(
RoleConstant
.
SUPER_ADMIN_ROLE_ID
);
userRoleDaoImpl
.
create
(
userRoleVo
);
resVo
.
setUserId
(
userVo
.
getId
());
resVo
.
setUserId
(
userVo
.
getId
());
return
resVo
;
return
resVo
;
...
...
src/main/java/com/pangding/web/authority/service/impl/DataServiceImpl.java
View file @
b44c9801
...
@@ -115,23 +115,9 @@ public class DataServiceImpl implements DataService {
...
@@ -115,23 +115,9 @@ public class DataServiceImpl implements DataService {
UserVo
userVo1
=
userDaoImpl
.
load
(
userGetReqVo
,
UserVo
.
class
);
UserVo
userVo1
=
userDaoImpl
.
load
(
userGetReqVo
,
UserVo
.
class
);
if
(
null
==
userVo1
){
if
(
null
==
userVo1
){
userDaoImpl
.
create
(
userVo
);
userDaoImpl
.
create
(
userVo
);
/*给用户分配管理员角色*/
UserRoleVo
userRoleVo
=
new
UserRoleVo
();
userRoleVo
.
setUserId
(
userVo
.
getId
());
userRoleVo
.
setRoleId
(
RoleConstant
.
ADMIN_ROLE_ID
);
userRoleDaoImpl
.
create
(
userRoleVo
);
}
else
{
}
else
{
userVo
.
setId
(
userVo1
.
getId
());
userVo
.
setId
(
userVo1
.
getId
());
userDaoImpl
.
update
(
userVo
);
userDaoImpl
.
update
(
userVo
);
/*给用户分配管理员角色*/
UserRoleVo
userRoleVo
=
new
UserRoleVo
();
userRoleVo
.
setUserId
(
userVo1
.
getId
());
userRoleVo
.
setRoleId
(
RoleConstant
.
ADMIN_ROLE_ID
);
UserRoleVo
userRoleVo1
=
userRoleDaoImpl
.
load
(
userRoleVo
,
UserRoleVo
.
class
);
if
(
null
==
userRoleVo1
){
userRoleVo
.
setId
(
StringHelper
.
getNewID
());
userRoleDaoImpl
.
create
(
userRoleVo
);
}
}
}
/*保存公司扩展表*/
/*保存公司扩展表*/
...
...
src/main/java/com/pangding/web/authority/service/impl/RegisterServiceImpl.java
View file @
b44c9801
...
@@ -118,6 +118,7 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -118,6 +118,7 @@ public class RegisterServiceImpl implements RegisterService {
userVo
.
setId
(
StringHelper
.
getNewID
());
userVo
.
setId
(
StringHelper
.
getNewID
());
userVo
.
setRemark
(
password
);
userVo
.
setRemark
(
password
);
userVo
.
setCompanyId
(
companyId
);
userVo
.
setCompanyId
(
companyId
);
userVo
.
setIsFirst
(
1
);
userDaoImpl
.
create
(
userVo
);
userDaoImpl
.
create
(
userVo
);
/*保存公司*/
/*保存公司*/
...
@@ -462,7 +463,7 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -462,7 +463,7 @@ public class RegisterServiceImpl implements RegisterService {
return
resVo
;
return
resVo
;
}
}
p
rivate
List
<
AuthorityListByLevelResVo
>
getChildList
(
AuthorityVo
authorityVo
,
List
<
String
>
authorityIds
){
p
ublic
List
<
AuthorityListByLevelResVo
>
getChildList
(
AuthorityVo
authorityVo
,
List
<
String
>
authorityIds
){
List
<
AuthorityListByLevelResVo
>
resVoList
=
new
ArrayList
<>();
List
<
AuthorityListByLevelResVo
>
resVoList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
authorityIds
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
authorityIds
.
size
();
i
++)
{
AuthorityGetReqVo
authorityGetReqVo
=
new
AuthorityGetReqVo
();
AuthorityGetReqVo
authorityGetReqVo
=
new
AuthorityGetReqVo
();
...
...
src/main/java/com/pangding/web/authority/vo/RoleVo.java
View file @
b44c9801
...
@@ -20,9 +20,20 @@ public class RoleVo extends BaseVo {
...
@@ -20,9 +20,20 @@ public class RoleVo extends BaseVo {
private
String
remark
;
private
String
remark
;
@TableAnnotation
(
"is_admin"
)
private
Integer
isAdmin
;
@TableAnnotation
(
"company_id"
)
@TableAnnotation
(
"company_id"
)
private
String
companyId
;
private
String
companyId
;
public
Integer
getIsAdmin
()
{
return
isAdmin
;
}
public
void
setIsAdmin
(
Integer
isAdmin
)
{
this
.
isAdmin
=
isAdmin
;
}
public
String
getCompanyId
()
{
public
String
getCompanyId
()
{
return
companyId
;
return
companyId
;
}
}
...
...
src/main/java/com/pangding/web/authority/vo/UserVo.java
View file @
b44c9801
...
@@ -44,6 +44,17 @@ public class UserVo extends BaseVo implements InitDao {
...
@@ -44,6 +44,17 @@ public class UserVo extends BaseVo implements InitDao {
private
String
email
;
private
String
email
;
@TableAnnotation
(
"is_first"
)
private
Integer
isFirst
;
public
Integer
getIsFirst
()
{
return
isFirst
;
}
public
void
setIsFirst
(
Integer
isFirst
)
{
this
.
isFirst
=
isFirst
;
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
...
src/main/java/com/pangding/web/authority/vo/reqvo/AuthorityListReqVo.java
View file @
b44c9801
...
@@ -13,6 +13,16 @@ public class AuthorityListReqVo {
...
@@ -13,6 +13,16 @@ public class AuthorityListReqVo {
private
Integer
attribute
;
private
Integer
attribute
;
private
String
companyId
;
public
String
getCompanyId
()
{
return
companyId
;
}
public
void
setCompanyId
(
String
companyId
)
{
this
.
companyId
=
companyId
;
}
public
Integer
getAttribute
()
{
public
Integer
getAttribute
()
{
return
attribute
;
return
attribute
;
}
}
...
...
src/main/java/com/pangding/web/authority/vo/reqvo/RoleGetReqVo.java
View file @
b44c9801
...
@@ -11,6 +11,26 @@ public class RoleGetReqVo {
...
@@ -11,6 +11,26 @@ public class RoleGetReqVo {
private
String
name
;
private
String
name
;
private
String
CompanyId
;
private
Integer
isAdmin
;
public
String
getCompanyId
()
{
return
CompanyId
;
}
public
void
setCompanyId
(
String
companyId
)
{
CompanyId
=
companyId
;
}
public
Integer
getIsAdmin
()
{
return
isAdmin
;
}
public
void
setIsAdmin
(
Integer
isAdmin
)
{
this
.
isAdmin
=
isAdmin
;
}
public
String
getReqId
()
{
public
String
getReqId
()
{
return
reqId
;
return
reqId
;
}
}
...
...
src/main/java/com/pangding/web/authority/vo/reqvo/UserGetReqVo.java
View file @
b44c9801
...
@@ -18,6 +18,16 @@ public class UserGetReqVo {
...
@@ -18,6 +18,16 @@ public class UserGetReqVo {
private
String
phone
;
private
String
phone
;
private
Integer
isFirst
;
public
Integer
getIsFirst
()
{
return
isFirst
;
}
public
void
setIsFirst
(
Integer
isFirst
)
{
this
.
isFirst
=
isFirst
;
}
public
String
getReqId
()
{
public
String
getReqId
()
{
return
reqId
;
return
reqId
;
}
}
...
...
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