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
0a784ddc
Commit
0a784ddc
authored
Dec 26, 2025
by
tangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户,角色,权限
parent
37fec4be
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
579 additions
and
33 deletions
+579
-33
SystemApp.java
src/main/java/com/tcm/SystemApp.java
+1
-1
TcmAuthorityDaoImpl.java
...om/tcm/system/authority/dao/impl/TcmAuthorityDaoImpl.java
+6
-6
TcmRoleAuthorityDaoImpl.java
...cm/system/authority/dao/impl/TcmRoleAuthorityDaoImpl.java
+9
-9
TcmRoleDaoImpl.java
...ain/java/com/tcm/system/role/dao/impl/TcmRoleDaoImpl.java
+4
-4
TcmRoleService.java
...main/java/com/tcm/system/role/service/TcmRoleService.java
+5
-0
TcmRoleServiceImpl.java
.../com/tcm/system/role/service/impl/TcmRoleServiceImpl.java
+116
-1
TcmRoleSaveReqVo.java
...ain/java/com/tcm/system/role/vo/req/TcmRoleSaveReqVo.java
+28
-0
TcmRoleController.java
src/main/java/com/tcm/system/role/web/TcmRoleController.java
+32
-0
UserDao.java
src/main/java/com/tcm/system/user/dao/UserDao.java
+11
-0
UserDaoImpl.java
src/main/java/com/tcm/system/user/dao/impl/UserDaoImpl.java
+35
-4
KaptchConfig.java
src/main/java/com/tcm/system/user/service/KaptchConfig.java
+67
-0
UserService.java
src/main/java/com/tcm/system/user/service/UserService.java
+10
-0
ValidateCodeService.java
...java/com/tcm/system/user/service/ValidateCodeService.java
+1
-2
LoginServiceImpl.java
...va/com/tcm/system/user/service/impl/LoginServiceImpl.java
+5
-5
UserServiceImpl.java
...ava/com/tcm/system/user/service/impl/UserServiceImpl.java
+20
-0
swagger.java
src/main/java/com/tcm/system/user/swagger.java
+47
-0
TcmUserPageReqVo.java
...ain/java/com/tcm/system/user/vo/req/TcmUserPageReqVo.java
+102
-0
TcmUserResVo.java
src/main/java/com/tcm/system/user/vo/res/TcmUserResVo.java
+20
-0
LoginController.java
src/main/java/com/tcm/system/user/web/LoginController.java
+1
-1
TcmUserController.java
src/main/java/com/tcm/system/user/web/TcmUserController.java
+59
-0
No files found.
src/main/java/com/tcm/SystemApp.java
View file @
0a784ddc
...
...
@@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author Administrator
*/
@SpringBootApplication
(
scanBasePackages
=
{
"com..*"
,
"com.
tcm
.*"
,
"com.yanzuoguang.*"
,
"org.springframework.jdbc.*"
})
...
...
src/main/java/com/tcm/system/authority/dao/impl/TcmAuthorityDaoImpl.java
View file @
0a784ddc
...
...
@@ -22,13 +22,13 @@ public class TcmAuthorityDaoImpl extends BaseDaoImpl implements TcmAuthorityDao
register
(
TcmAuthorityVo
.
class
);
table
.
add
(
QUERY
,
"select * from
pd
_authority where 1=1"
)
.
add
(
"
id"
,
"and p
id = ? "
)
table
.
add
(
QUERY
,
"select * from
tcm_sys
_authority where 1=1"
)
.
add
(
"
authorityId"
,
"and authority_
id = ? "
)
.
add
(
"pid"
,
"and pid = ? "
)
.
add
(
"
sort"
,
"and
sort = ? "
)
.
add
(
"search"
,
"and (name like concat(?,'%') "
+
"or alias like concat(?,'%')) "
)
.
add
(
"levelOne"
,
"and pid = '' order by sort asc"
);
.
add
(
"
authoritySort"
,
"and authority_
sort = ? "
)
.
add
(
"search"
,
"and (
authority_
name like concat(?,'%') "
+
"or a
uthority_a
lias like concat(?,'%')) "
)
.
add
(
"levelOne"
,
"and pid = '' order by
authority_
sort asc"
);
}
...
...
src/main/java/com/tcm/system/authority/dao/impl/TcmRoleAuthorityDaoImpl.java
View file @
0a784ddc
...
...
@@ -16,15 +16,15 @@ public class TcmRoleAuthorityDaoImpl extends BaseDaoImpl implements TcmRoleAutho
protected
void
init
()
{
register
(
TcmRoleAuthorityVo
.
class
);
getSql
(
DaoConst
.
LOAD
).
setSql
(
"select
ra.role_id,ra.authority_id,a.id,a.pid,a.name,
"
+
"
a.type,a.alias,a.url,a.remark,a.open_mode,a.sort,a.attribute from pd_role_authority r
a "
+
"
RIGHT JOIN pd_authority a on ra.authority_id = a.
id {INNER} "
+
"
where 1=1 {WHERE} ORDER BY a.pid,a.sort,a
.attribute"
)
.
add
(
"userId"
,
"AND
b
.user_id = @userId"
,
"{INNER}"
,
"INNER JOIN
pd_user_role AS b ON ra.role_id = b
.role_id"
)
.
add
(
"role
"
,
" AND ra.role_id = @role
"
)
.
add
(
"authority
"
,
" AND ra.authority_id = @authority
"
)
.
add
(
"platformType"
,
" AND
a
.platform_type = @platformType"
)
getSql
(
DaoConst
.
LOAD
).
setSql
(
"select
a.role_id,b.*
"
+
"
from tcm_sys_role_authority
a "
+
"
RIGHT JOIN tcm_sys_authority b on a.authority_id = b.authority_
id {INNER} "
+
"
where 1=1 {WHERE} ORDER BY b.pid,b.authority_sort,b
.attribute"
)
.
add
(
"userId"
,
"AND
c
.user_id = @userId"
,
"{INNER}"
,
"INNER JOIN
tcm_sys_user AS c ON a.role_id = c
.role_id"
)
.
add
(
"role
Id"
,
" AND a.role_id = @roleId
"
)
.
add
(
"authority
Id"
,
" AND b.authority_id = @authorityId
"
)
.
add
(
"platformType"
,
" AND
b
.platform_type = @platformType"
)
;
}
...
...
src/main/java/com/tcm/system/role/dao/impl/TcmRoleDaoImpl.java
View file @
0a784ddc
...
...
@@ -17,10 +17,10 @@ public class TcmRoleDaoImpl extends BaseDaoImpl implements TcmRoleDao {
protected
void
init
()
{
register
(
TcmRoleVo
.
class
);
table
.
add
(
QUERY_LIST
,
"select COUNT(a.id) as userNum,a.* from
pd
_role a "
+
" LEFT JOIN
pd_user_role b on a.
id = b.role_id where 1=1 {WHERE}"
+
"GROUP BY a.id"
)
.
add
(
"
id"
,
" and a.
id = ? "
)
table
.
add
(
QUERY_LIST
,
"select COUNT(a.id) as userNum,a.* from
tcm_sys
_role a "
+
" LEFT JOIN
tcm_sys_user b on a.role_
id = b.role_id where 1=1 {WHERE}"
+
"GROUP BY a.
role_
id"
)
.
add
(
"
roleId"
,
" and a.role_
id = ? "
)
.
add
(
"companyId"
,
" and a.company_id = ? "
)
.
add
(
"roleName"
,
" and (a.name LIKE concat(?,'%') OR a.remark LIKE concat(?,'%') )"
);
}
...
...
src/main/java/com/tcm/system/role/service/TcmRoleService.java
View file @
0a784ddc
package
com
.
tcm
.
system
.
role
.
service
;
import
com.tcm.system.role.vo.req.TcmRolePageReqVo
;
import
com.tcm.system.role.vo.req.TcmRoleSaveReqVo
;
import
com.tcm.system.role.vo.res.TcmRoleListResVo
;
import
com.yanzuoguang.util.vo.PageSizeData
;
...
...
@@ -8,4 +9,8 @@ public interface TcmRoleService {
PageSizeData
<
TcmRoleListResVo
>
queryList
(
TcmRolePageReqVo
req
);
String
saveRole
(
TcmRoleSaveReqVo
req
);
void
delete
(
TcmRoleSaveReqVo
req
);
}
src/main/java/com/tcm/system/role/service/impl/TcmRoleServiceImpl.java
View file @
0a784ddc
package
com
.
tcm
.
system
.
role
.
service
.
impl
;
import
com.pangding.web.constant.CompanyConstant
;
import
com.pangding.web.vo.system.pd.authority.AuthorityVo
;
import
com.pangding.web.vo.system.pd.authority.RoleAuthorityVo
;
import
com.pangding.web.vo.system.pd.authority.RoleVo
;
import
com.tcm.system.authority.dao.TcmRoleAuthorityDao
;
import
com.tcm.system.authority.vo.TcmRoleAuthorityVo
;
import
com.tcm.system.authority.vo.req.TcmRoleAuthorityReqVo
;
import
com.tcm.system.role.dao.TcmRoleDao
;
import
com.tcm.system.role.service.TcmRoleService
;
import
com.tcm.system.role.vo.TcmRoleVo
;
import
com.tcm.system.role.vo.req.TcmRolePageReqVo
;
import
com.tcm.system.role.vo.req.TcmRoleSaveReqVo
;
import
com.tcm.system.role.vo.res.TcmRoleListResVo
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
public
class
TcmRoleServiceImpl
implements
TcmRoleService
{
private
TcmRoleDao
tcmRoleDao
;
private
TcmRoleAuthorityDao
tcmRoleAuthorityDao
;
public
TcmRoleServiceImpl
(
TcmRoleDao
tcmRoleDao
)
{
public
TcmRoleServiceImpl
(
TcmRoleDao
tcmRoleDao
,
TcmRoleAuthorityDao
tcmRoleAuthorityDao
)
{
this
.
tcmRoleDao
=
tcmRoleDao
;
this
.
tcmRoleAuthorityDao
=
tcmRoleAuthorityDao
;
}
public
PageSizeData
<
TcmRoleListResVo
>
queryList
(
TcmRolePageReqVo
req
)
{
...
...
@@ -22,5 +38,104 @@ public class TcmRoleServiceImpl implements TcmRoleService {
return
roleVoPageSizeData
;
}
/**
* 保存RoleVo对象,并保存角色权限的对应关系
*
* @param req
* @return 返回角色id
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
saveRole
(
TcmRoleSaveReqVo
req
)
{
// this.checkNameExist(roleVo);
if
(
StringHelper
.
isEmpty
(
req
.
getRoleId
())){
req
.
setRoleId
(
StringHelper
.
getNewID
());
tcmRoleDao
.
create
(
req
);
List
<
String
>
authorityIds
=
req
.
getAuthorityIds
();
if
(
authorityIds
!=
null
&&
!
authorityIds
.
isEmpty
())
{
for
(
String
authorityId
:
authorityIds
)
{
/*查看该权限是否有上级权限*/
// findParent(authorityId, webRoleReqVo.getId());
TcmRoleAuthorityVo
tcmRoleAuthorityVo
=
new
TcmRoleAuthorityVo
();
tcmRoleAuthorityVo
.
setAuthorityId
(
authorityId
);
tcmRoleAuthorityVo
.
setRoleId
(
req
.
getRoleId
());
tcmRoleAuthorityVo
.
setRoleAuthorityId
(
StringHelper
.
getNewID
());
tcmRoleAuthorityDao
.
create
(
tcmRoleAuthorityVo
);
}
}
}
else
{
TcmRoleVo
tcmRoleVo
=
tcmRoleDao
.
load
(
req
.
getRoleId
(),
TcmRoleVo
.
class
);
ObjectHelper
.
writeWithFromClass
(
tcmRoleVo
,
req
);
tcmRoleDao
.
update
(
tcmRoleVo
);
TcmRoleAuthorityReqVo
reqVo
=
new
TcmRoleAuthorityReqVo
();
reqVo
.
setRoleId
(
tcmRoleVo
.
getRoleId
());
List
<
TcmRoleAuthorityVo
>
roleAuthorityList
=
tcmRoleAuthorityDao
.
loadList
(
reqVo
,
TcmRoleAuthorityVo
.
class
);
if
(
roleAuthorityList
!=
null
&&
!
roleAuthorityList
.
isEmpty
())
{
for
(
TcmRoleAuthorityVo
roleAuthorityRelation
:
roleAuthorityList
)
{
RoleAuthorityVo
roleAuthorityVo
=
new
RoleAuthorityVo
();
roleAuthorityVo
.
setRoleId
(
roleAuthorityRelation
.
getRoleId
());
roleAuthorityVo
.
setAuthorityId
(
roleAuthorityRelation
.
getAuthorityId
());
tcmRoleAuthorityDao
.
remove
(
roleAuthorityVo
);
}
}
List
<
String
>
authorityIds
=
req
.
getAuthorityIds
();
if
(
authorityIds
!=
null
&&
!
authorityIds
.
isEmpty
())
{
for
(
String
authorityId
:
authorityIds
)
{
/*查看该权限是否有上级权限*/
// findParent(authorityId, webRoleReqVo.getId());
TcmRoleAuthorityVo
tcmRoleAuthorityVo
=
new
TcmRoleAuthorityVo
();
tcmRoleAuthorityVo
.
setAuthorityId
(
authorityId
);
tcmRoleAuthorityVo
.
setRoleId
(
req
.
getRoleId
());
tcmRoleAuthorityVo
.
setRoleAuthorityId
(
StringHelper
.
getNewID
());
tcmRoleAuthorityDao
.
create
(
tcmRoleAuthorityVo
);
}
}
}
return
"处理成功"
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
TcmRoleSaveReqVo
req
)
{
TcmRoleAuthorityReqVo
reqVo
=
new
TcmRoleAuthorityReqVo
();
reqVo
.
setRoleId
(
req
.
getRoleId
());
List
<
TcmRoleAuthorityVo
>
roleAuthorityList
=
tcmRoleAuthorityDao
.
loadList
(
reqVo
,
TcmRoleAuthorityVo
.
class
);
if
(
roleAuthorityList
!=
null
&&
!
roleAuthorityList
.
isEmpty
())
{
for
(
TcmRoleAuthorityVo
roleAuthorityRelation
:
roleAuthorityList
)
{
RoleAuthorityVo
roleAuthorityVo
=
new
RoleAuthorityVo
();
roleAuthorityVo
.
setRoleId
(
roleAuthorityRelation
.
getRoleId
());
roleAuthorityVo
.
setAuthorityId
(
roleAuthorityRelation
.
getAuthorityId
());
tcmRoleAuthorityDao
.
remove
(
roleAuthorityVo
);
}
}
tcmRoleDao
.
remove
(
req
);
}
// private void findParent(String authorityId, String roleId) {
// AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
// authorityGetReqVo.setId(authorityId);
// AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo, AuthorityVo.class);
// if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()) {
// String authorityPid = authorityVo.getPid();
// RoleAuthorityVo roleAuthorityVo = new RoleAuthorityVo();
// roleAuthorityVo.setAuthorityId(authorityPid);
// roleAuthorityVo.setRoleId(roleId);
// RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
// roleAuthorityGetReqVo.setRole(roleId);
// roleAuthorityGetReqVo.setAuthority(authorityPid);
// RoleAuthorityVo roleAuthorityVo1 = roleAuthorityDaoImpl.load(roleAuthorityGetReqVo, RoleAuthorityVo.class);
// if (null == roleAuthorityVo1) {
// roleAuthorityVo.setId(StringHelper.getNewID());
// roleAuthorityDaoImpl.create(roleAuthorityVo);
// findParent(authorityPid, roleId);
// }
// }
// }
}
src/main/java/com/tcm/system/role/vo/req/TcmRoleSaveReqVo.java
0 → 100644
View file @
0a784ddc
package
com
.
tcm
.
system
.
role
.
vo
.
req
;
import
com.tcm.system.role.vo.TcmRoleVo
;
import
java.util.List
;
public
class
TcmRoleSaveReqVo
extends
TcmRoleVo
{
private
String
reqId
;
private
List
<
String
>
authorityIds
;
public
String
getReqId
()
{
return
reqId
;
}
public
void
setReqId
(
String
reqId
)
{
this
.
reqId
=
reqId
;
}
public
List
<
String
>
getAuthorityIds
()
{
return
authorityIds
;
}
public
void
setAuthorityIds
(
List
<
String
>
authorityIds
)
{
this
.
authorityIds
=
authorityIds
;
}
}
src/main/java/com/tcm/system/role/web/TcmRoleController.java
View file @
0a784ddc
...
...
@@ -2,7 +2,9 @@ package com.tcm.system.role.web;
import
com.tcm.system.role.service.TcmRoleService
;
import
com.tcm.system.role.vo.req.TcmRolePageReqVo
;
import
com.tcm.system.role.vo.req.TcmRoleSaveReqVo
;
import
com.tcm.system.role.vo.res.TcmRoleListResVo
;
import
com.yanzuoguang.util.helper.CheckerHelper
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
org.springframework.http.MediaType
;
...
...
@@ -29,4 +31,34 @@ public class TcmRoleController {
return
ResponseResult
.
result
(
tcmRoleService
.
queryList
(
req
));
}
/**
* 新增角色
* 返回角色id
* @param req
* @return
*/
@RequestMapping
(
value
=
"/save"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
String
>
saveRole
(
@RequestBody
TcmRoleSaveReqVo
req
){
CheckerHelper
.
newInstance
()
.
notBlankCheck
(
"roleName"
,
req
.
getRoleName
())
.
notBlankCheck
(
"remark"
,
req
.
getRoleRemark
())
// .notBlankCheck("companyId",req.getCompanyId())
.
checkException
();
return
ResponseResult
.
result
(
tcmRoleService
.
saveRole
(
req
));
}
/**
* 删除角色
* @param
* @return
*/
@RequestMapping
(
value
=
"/delete"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
delete
(
@RequestBody
TcmRoleSaveReqVo
req
){
CheckerHelper
.
newInstance
()
.
notBlankCheck
(
"roleId"
,
req
.
getRoleId
())
.
checkException
();
tcmRoleService
.
delete
(
req
);
return
new
ResponseResult
();
}
}
src/main/java/com/tcm/system/user/dao/UserDao.java
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
.
dao
;
import
com.tcm.system.user.vo.req.TcmUserPageReqVo
;
import
com.tcm.system.user.vo.req.TcmUserReqVo
;
import
com.tcm.system.user.vo.res.TcmUserResVo
;
import
com.yanzuoguang.dao.BaseDao
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
java.util.List
;
public
interface
UserDao
extends
BaseDao
{
...
...
@@ -14,4 +18,11 @@ public interface UserDao extends BaseDao {
*/
TcmUserResVo
queryUser
(
TcmUserReqVo
req
);
PageSizeData
<
TcmUserResVo
>
findUserPage
(
TcmUserPageReqVo
req
);
List
<
TcmUserResVo
>
findUserList
(
TcmUserReqVo
req
);
TcmUserResVo
findUserInfo
(
TcmUserReqVo
req
);
}
src/main/java/com/tcm/system/user/dao/impl/UserDaoImpl.java
View file @
0a784ddc
...
...
@@ -2,31 +2,62 @@ package com.tcm.system.user.dao.impl;
import
com.tcm.system.user.dao.UserDao
;
import
com.tcm.system.user.vo.TcmUserVo
;
import
com.tcm.system.user.vo.req.TcmUserPageReqVo
;
import
com.tcm.system.user.vo.req.TcmUserReqVo
;
import
com.tcm.system.user.vo.res.TcmUserResVo
;
import
com.yanzuoguang.dao.impl.BaseDaoImpl
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
public
class
UserDaoImpl
extends
BaseDaoImpl
implements
UserDao
{
private
static
final
String
QUERY_USER
=
"QUERY_USER"
;
private
static
final
String
QUERY_LIST
=
"QUERY_LIST"
;
@Override
protected
void
init
()
{
register
(
TcmUserVo
.
class
);
table
.
add
(
QUERY_USER
,
"select * from
pd
_user where 1=1"
)
table
.
add
(
QUERY_USER
,
"select * from
tcm_sys
_user where 1=1"
)
.
add
(
"companyId"
,
"and company_id = ? "
)
.
add
(
"account"
,
"and
account
= ? "
)
.
add
(
"account"
,
"and
username
= ? "
)
.
add
(
"phone"
,
"and phone = ? "
)
.
add
(
"loginAccount"
,
"and (account = ? or phone = ?) "
)
.
add
(
"roleId"
,
" id in (select user_id from pd_user_role where role_id = ? )"
);
.
add
(
"loginAccount"
,
"and (username = ? or phone = ?) "
)
.
add
(
"roleId"
,
" role_id = ? "
);
table
.
add
(
QUERY_LIST
,
"select a.*,b.*,c.* from tcm_sys_user a "
+
" LEFT JOIN tcm_sys_role b on a.role_id = b.role_id "
+
" LEFT JOIN tcm_sys_position c on c.position_id = a.position_id "
+
" where 1=1 "
)
.
add
(
"companyId"
,
"and company_id = ? "
)
.
add
(
"account"
,
"and username = ? "
)
.
add
(
"phone"
,
"and phone = ? "
)
.
add
(
"loginAccount"
,
"and (username = ? or phone = ?) "
)
.
add
(
"roleId"
,
" role_id = ? "
);
}
@Override
public
TcmUserResVo
queryUser
(
TcmUserReqVo
req
)
{
return
this
.
queryFirst
(
TcmUserResVo
.
class
,
QUERY_USER
,
req
);
}
@Override
public
PageSizeData
<
TcmUserResVo
>
findUserPage
(
TcmUserPageReqVo
req
)
{
return
this
.
queryPage
(
TcmUserResVo
.
class
,
req
,
QUERY_LIST
,
req
);
}
@Override
public
List
<
TcmUserResVo
>
findUserList
(
TcmUserReqVo
req
)
{
return
this
.
query
(
TcmUserResVo
.
class
,
QUERY_LIST
,
req
);
}
@Override
public
TcmUserResVo
findUserInfo
(
TcmUserReqVo
req
)
{
return
this
.
queryFirst
(
TcmUserResVo
.
class
,
QUERY_LIST
,
req
);
}
}
src/main/java/com/tcm/system/user/service/KaptchConfig.java
0 → 100644
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
.
service
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
java.util.Properties
;
/**
* 验证码生成配置
*
* @author 颜佐光
*/
@Component
public
class
KaptchConfig
{
@Bean
public
DefaultKaptcha
getDefaultKaptcha
()
{
DefaultKaptcha
defaultKaptcha
=
new
DefaultKaptcha
();
Properties
properties
=
new
Properties
();
// 图片边框
properties
.
setProperty
(
"kaptcha.border"
,
"no"
);
// 边框颜色
properties
.
setProperty
(
"kaptcha.border.color"
,
"black"
);
//边框厚度
properties
.
setProperty
(
"kaptcha.border.thickness"
,
"1"
);
// 图片宽
properties
.
setProperty
(
"kaptcha.image.width"
,
"120"
);
// 图片高
properties
.
setProperty
(
"kaptcha.image.height"
,
"60"
);
//图片实现类
properties
.
setProperty
(
"kaptcha.producer.impl"
,
"com.google.code.kaptcha.impl.DefaultKaptcha"
);
//文本实现类
properties
.
setProperty
(
"kaptcha.textproducer.impl"
,
"com.google.code.kaptcha.text.impl.DefaultTextCreator"
);
//文本集合,验证码值从此集合中获取
// properties.setProperty("kaptcha.textproducer.char.string", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
properties
.
setProperty
(
"kaptcha.textproducer.char.string"
,
"23456789ABCDEFGHJKMNPQRSTUVWXYZ"
);
//验证码长度
properties
.
setProperty
(
"kaptcha.textproducer.char.length"
,
"4"
);
//字体
properties
.
setProperty
(
"kaptcha.textproducer.font.names"
,
"宋体"
);
//字体颜色
properties
.
setProperty
(
"kaptcha.textproducer.font.color"
,
"black"
);
//文字间隔
properties
.
setProperty
(
"kaptcha.textproducer.char.space"
,
"2"
);
//干扰实现类
properties
.
setProperty
(
"kaptcha.noise.impl"
,
"com.google.code.kaptcha.impl.DefaultNoise"
);
//干扰颜色
properties
.
setProperty
(
"kaptcha.noise.color"
,
"blue"
);
//干扰图片样式
properties
.
setProperty
(
"kaptcha.obscurificator.impl"
,
"com.google.code.kaptcha.impl.WaterRipple"
);
//背景实现类
properties
.
setProperty
(
"kaptcha.background.impl"
,
"com.google.code.kaptcha.impl.DefaultBackground"
);
// 验证码背景颜色(开始颜色)
properties
.
setProperty
(
"kaptcha.background-color.from"
,
"lightGray"
);
// 验证码背景颜色(结束颜色)
properties
.
setProperty
(
"kaptcha.background-color.to"
,
"white"
);
//背景颜色渐变,结束颜色
properties
.
setProperty
(
"kaptcha.background.clear.to"
,
"white"
);
//文字渲染器
properties
.
setProperty
(
"kaptcha.word.impl"
,
"com.google.code.kaptcha.text.impl.DefaultWordRenderer"
);
Config
config
=
new
Config
(
properties
);
defaultKaptcha
.
setConfig
(
config
);
return
defaultKaptcha
;
}
}
src/main/java/com/tcm/system/user/service/UserService.java
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
.
service
;
import
com.tcm.system.user.vo.req.TcmUserPageReqVo
;
import
com.tcm.system.user.vo.req.TcmUserReqVo
;
import
com.tcm.system.user.vo.req.TcmUserSaveReqVo
;
import
com.tcm.system.user.vo.res.TcmUserResVo
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
java.util.List
;
public
interface
UserService
{
...
...
@@ -13,6 +17,12 @@ public interface UserService {
*/
TcmUserResVo
queryUser
(
TcmUserReqVo
req
);
PageSizeData
<
TcmUserResVo
>
findUserPage
(
TcmUserPageReqVo
req
);
List
<
TcmUserResVo
>
findUserList
(
TcmUserReqVo
req
);
TcmUserResVo
findUserInfo
(
TcmUserReqVo
req
);
String
saveUser
(
TcmUserSaveReqVo
req
);
}
src/main/java/com/tcm/system/user/service/ValidateCodeService.java
View file @
0a784ddc
...
...
@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
@Component
public
class
ValidateCodeService
{
private
final
DefaultKaptcha
defaultKaptcha
;
private
DefaultKaptcha
defaultKaptcha
;
@CreateCache
(
name
=
CacheName
.
USER_PASSWORD_CODE
,
cacheType
=
CacheType
.
REMOTE
,
expire
=
60
,
timeUnit
=
TimeUnit
.
MINUTES
)
...
...
@@ -31,7 +31,6 @@ public class ValidateCodeService {
this
.
defaultKaptcha
=
defaultKaptcha
;
}
/**
* 生成验证码
*
...
...
src/main/java/com/tcm/system/user/service/impl/LoginServiceImpl.java
View file @
0a784ddc
...
...
@@ -54,10 +54,10 @@ public class LoginServiceImpl implements LoginService {
@Override
public
UserLoginResVo
login
(
UserLoginReqVo
reqVo
){
// 当输入用户名和密码时,检测验证码
List
<
String
>
items
=
new
ArrayList
<>();
items
.
add
(
reqVo
.
getAccountOrPhone
());
items
.
add
(
reqVo
.
getPassword
());
validateCodeService
.
validate
(
reqVo
.
getCodeId
(),
reqVo
.
getCodeValue
(),
items
);
//
List<String> items = new ArrayList<>();
//
items.add(reqVo.getAccountOrPhone());
//
items.add(reqVo.getPassword());
//
validateCodeService.validate(reqVo.getCodeId(), reqVo.getCodeValue(), items);
TcmUserReqVo
userReqVo
=
new
TcmUserReqVo
();
userReqVo
.
setLoginAccount
(
reqVo
.
getAccountOrPhone
());
...
...
@@ -97,7 +97,7 @@ public class LoginServiceImpl implements LoginService {
/*获取用户权限列表*/
TcmRoleAuthorityReqVo
roleAuthorityGetReqVo
=
new
TcmRoleAuthorityReqVo
();
roleAuthorityGetReqVo
.
setUserId
(
userVo
.
getUserId
());
List
<
TcmAuthorityListByLevelResVo
>
roleAuthorityVoList
=
tcmAuthorityService
.
findAuthority
ListByLevel
(
roleAuthorityGetReqVo
);
List
<
TcmAuthorityListByLevelResVo
>
roleAuthorityVoList
=
tcmAuthorityService
.
get
ListByLevel
(
roleAuthorityGetReqVo
);
resVo
.
setAuthorityListByLevel
(
roleAuthorityVoList
);
resVo
.
setCode
(
"00"
);
...
...
src/main/java/com/tcm/system/user/service/impl/UserServiceImpl.java
View file @
0a784ddc
...
...
@@ -6,14 +6,18 @@ import com.tcm.system.user.dao.UserDao;
import
com.tcm.system.user.service.UserService
;
import
com.tcm.system.user.vo.RsaContant
;
import
com.tcm.system.user.vo.TcmUserVo
;
import
com.tcm.system.user.vo.req.TcmUserPageReqVo
;
import
com.tcm.system.user.vo.req.TcmUserReqVo
;
import
com.tcm.system.user.vo.req.TcmUserSaveReqVo
;
import
com.tcm.system.user.vo.res.TcmUserResVo
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
UserServiceImpl
implements
UserService
{
...
...
@@ -29,6 +33,22 @@ public class UserServiceImpl implements UserService {
public
TcmUserResVo
queryUser
(
TcmUserReqVo
req
)
{
return
userDao
.
queryUser
(
req
);
}
@Override
public
PageSizeData
<
TcmUserResVo
>
findUserPage
(
TcmUserPageReqVo
req
){
return
userDao
.
findUserPage
(
req
);
}
@Override
public
List
<
TcmUserResVo
>
findUserList
(
TcmUserReqVo
req
){
return
userDao
.
findUserList
(
req
);
}
@Override
public
TcmUserResVo
findUserInfo
(
TcmUserReqVo
req
){
return
userDao
.
findUserInfo
(
req
);
}
@Override
public
String
saveUser
(
TcmUserSaveReqVo
req
)
{
this
.
isValid
(
req
.
getUsername
());
...
...
src/main/java/com/tcm/system/user/swagger.java
0 → 100644
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
;
import
com.yanzuoguang.util.helper.SwaggerHelper
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@Configuration
@EnableSwagger2
public
class
swagger
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
//为当前包路径
.
apis
(
SwaggerHelper
.
basePackage
(
"com.pangding.web.authority.web"
,
"com.pangding.web.user.web"
,
"com.pangding.web.role.web"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
// return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
}
//构建 api文档的详细信息函数,注意这里的注解引用的是哪个
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
//页面标题
.
title
(
"Spring Boot 使用 Swagger2 构建RESTful API"
)
//创建人
.
contact
(
new
Contact
(
"Bryan"
,
"http://blog.bianxh.top/"
,
""
))
//版本号
.
version
(
"1.0"
)
//描述
.
description
(
"API 描述"
)
.
build
();
}
}
src/main/java/com/tcm/system/user/vo/req/TcmUserPageReqVo.java
0 → 100644
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
.
vo
.
req
;
import
com.yanzuoguang.util.vo.PageSizeReqVo
;
import
io.swagger.annotations.ApiModelProperty
;
public
class
TcmUserPageReqVo
extends
PageSizeReqVo
{
@ApiModelProperty
(
notes
=
"用户编号"
)
private
String
userId
;
private
String
roleId
;
private
String
positionId
;
private
String
roleName
;
private
String
positionName
;
@ApiModelProperty
(
notes
=
"账户"
)
private
String
username
;
@ApiModelProperty
(
notes
=
"真实姓名"
)
private
String
realName
;
@ApiModelProperty
(
notes
=
"电话"
)
private
String
phone
;
@ApiModelProperty
(
notes
=
"状态:0-启用,1-禁用"
)
private
Integer
userStatus
;
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
String
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
String
roleId
)
{
this
.
roleId
=
roleId
;
}
public
String
getPositionId
()
{
return
positionId
;
}
public
void
setPositionId
(
String
positionId
)
{
this
.
positionId
=
positionId
;
}
public
String
getRoleName
()
{
return
roleName
;
}
public
void
setRoleName
(
String
roleName
)
{
this
.
roleName
=
roleName
;
}
public
String
getPositionName
()
{
return
positionName
;
}
public
void
setPositionName
(
String
positionName
)
{
this
.
positionName
=
positionName
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getRealName
()
{
return
realName
;
}
public
void
setRealName
(
String
realName
)
{
this
.
realName
=
realName
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
public
Integer
getUserStatus
()
{
return
userStatus
;
}
public
void
setUserStatus
(
Integer
userStatus
)
{
this
.
userStatus
=
userStatus
;
}
}
src/main/java/com/tcm/system/user/vo/res/TcmUserResVo.java
View file @
0a784ddc
...
...
@@ -3,4 +3,24 @@ package com.tcm.system.user.vo.res;
import
com.tcm.system.user.vo.TcmUserVo
;
public
class
TcmUserResVo
extends
TcmUserVo
{
private
String
roleName
;
private
String
positionName
;
public
String
getRoleName
()
{
return
roleName
;
}
public
void
setRoleName
(
String
roleName
)
{
this
.
roleName
=
roleName
;
}
public
String
getPositionName
()
{
return
positionName
;
}
public
void
setPositionName
(
String
positionName
)
{
this
.
positionName
=
positionName
;
}
}
src/main/java/com/tcm/system/user/web/LoginController.java
View file @
0a784ddc
...
...
@@ -38,7 +38,7 @@ public class LoginController {
CheckerHelper
.
newInstance
()
.
notBlankCheck
(
"account or phone"
,
req
.
getAccountOrPhone
())
.
notBlankCheck
(
"password"
,
req
.
getPassword
())
.
notBlankCheck
(
"loginType"
,
req
.
getLoginType
())
//
.notBlankCheck("loginType", req.getLoginType())
.
checkException
();
return
ResponseResult
.
result
(
loginService
.
login
(
req
));
}
...
...
src/main/java/com/tcm/system/user/web/TcmUserController.java
0 → 100644
View file @
0a784ddc
package
com
.
tcm
.
system
.
user
.
web
;
import
com.tcm.system.user.service.UserService
;
import
com.tcm.system.user.vo.req.TcmUserPageReqVo
;
import
com.tcm.system.user.vo.req.TcmUserReqVo
;
import
com.tcm.system.user.vo.req.TcmUserSaveReqVo
;
import
com.tcm.system.user.vo.res.TcmUserResVo
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.http.MediaType
;
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.RestController
;
import
java.util.List
;
@RestController
@RequestMapping
(
value
=
"/user"
)
@Api
(
value
=
"用户类"
)
public
class
TcmUserController
{
private
UserService
userService
;
public
TcmUserController
(
UserService
userService
)
{
this
.
userService
=
userService
;
}
/**
* 分页查询员工信息
* @param req
* @return
*/
@ApiOperation
(
value
=
"分页查询员工信息"
,
notes
=
"返回员工信息列表"
)
@RequestMapping
(
value
=
"/findUserPage"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
PageSizeData
<
TcmUserResVo
>>
findUserPage
(
@RequestBody
TcmUserPageReqVo
req
)
{
return
ResponseResult
.
result
(
userService
.
findUserPage
(
req
));
}
@ApiOperation
(
value
=
"查询员工信息"
,
notes
=
"返回员工信息列表"
)
@RequestMapping
(
value
=
"/findUserList"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
List
<
TcmUserResVo
>>
findUserList
(
@RequestBody
TcmUserReqVo
req
)
{
return
ResponseResult
.
result
(
userService
.
findUserList
(
req
));
}
@ApiOperation
(
value
=
"查询员工信息"
,
notes
=
"返回员工信息"
)
@RequestMapping
(
value
=
"/findUserInfo"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
TcmUserResVo
>
findUserInfo
(
@RequestBody
TcmUserReqVo
req
)
{
return
ResponseResult
.
result
(
userService
.
findUserInfo
(
req
));
}
@ApiOperation
(
value
=
"保存员工信息"
,
notes
=
"返回成功失败"
)
@RequestMapping
(
value
=
"/saveUser"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
ResponseResult
<
String
>
saveUser
(
@RequestBody
TcmUserSaveReqVo
req
)
{
return
ResponseResult
.
result
(
userService
.
saveUser
(
req
));
}
}
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