Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
e1a9b743
Commit
e1a9b743
authored
Jan 31, 2023
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户模块变更
parent
609280a3
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
613 additions
and
116 deletions
+613
-116
update.2023.1.sql
license/doc/update.2023.1.sql
+17
-17
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+77
-68
SysOperLogController.java
.../iot/sixiang/license/controller/SysOperLogController.java
+22
-8
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+58
-6
Permission.java
.../src/main/java/iot/sixiang/license/entity/Permission.java
+32
-0
Report.java
license/src/main/java/iot/sixiang/license/entity/Report.java
+47
-0
ReportType.java
.../src/main/java/iot/sixiang/license/entity/ReportType.java
+35
-0
User.java
license/src/main/java/iot/sixiang/license/entity/User.java
+6
-0
UserPermission.java
.../main/java/iot/sixiang/license/entity/UserPermission.java
+35
-0
GlobalExceptionHandler.java
...a/iot/sixiang/license/handler/GlobalExceptionHandler.java
+2
-2
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+5
-0
PermissionMapper.java
...ain/java/iot/sixiang/license/mapper/PermissionMapper.java
+12
-0
SysOperLogMapper.java
...ain/java/iot/sixiang/license/mapper/SysOperLogMapper.java
+1
-1
UserMapper.java
.../src/main/java/iot/sixiang/license/mapper/UserMapper.java
+1
-1
UserPermissionMapper.java
...java/iot/sixiang/license/mapper/UserPermissionMapper.java
+20
-0
AssignUserPermissionDTO.java
...ot/sixiang/license/model/dto/AssignUserPermissionDTO.java
+21
-0
CheckCodeDto.java
...main/java/iot/sixiang/license/model/dto/CheckCodeDto.java
+3
-0
LoginReqVo.java
...rc/main/java/iot/sixiang/license/model/vo/LoginReqVo.java
+2
-2
LoginVo.java
...e/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
+6
-0
UserDeleteVO.java
.../main/java/iot/sixiang/license/model/vo/UserDeleteVO.java
+15
-0
UserResetPwdVo.java
...ain/java/iot/sixiang/license/model/vo/UserResetPwdVo.java
+1
-0
PermissionService.java
...n/java/iot/sixiang/license/service/PermissionService.java
+14
-0
SysOperLogService.java
...n/java/iot/sixiang/license/service/SysOperLogService.java
+1
-1
UserPermissionService.java
...va/iot/sixiang/license/service/UserPermissionService.java
+20
-0
UserService.java
...rc/main/java/iot/sixiang/license/service/UserService.java
+1
-1
PermissionServiceImpl.java
...t/sixiang/license/service/impl/PermissionServiceImpl.java
+25
-0
SysOperLogServiceImpl.java
...t/sixiang/license/service/impl/SysOperLogServiceImpl.java
+2
-2
UserPermissionServiceImpl.java
...xiang/license/service/impl/UserPermissionServiceImpl.java
+49
-0
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+11
-4
CommonUtil.java
...se/src/main/java/iot/sixiang/license/util/CommonUtil.java
+30
-0
PermissionMapper.xml
license/src/main/resources/mapper/PermissionMapper.xml
+5
-0
PmsUseLogMapper.xml
license/src/main/resources/mapper/PmsUseLogMapper.xml
+6
-0
SysOperLogMapper.xml
license/src/main/resources/mapper/SysOperLogMapper.xml
+9
-1
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+5
-2
UserPermissionMapper.xml
license/src/main/resources/mapper/UserPermissionMapper.xml
+17
-0
No files found.
license/doc/update.2023.1.sql
View file @
e1a9b743
...
@@ -6,7 +6,7 @@ ADD COLUMN `level` int(1) NULL COMMENT '账号等级(共有三级),空则
...
@@ -6,7 +6,7 @@ ADD COLUMN `level` int(1) NULL COMMENT '账号等级(共有三级),空则
CREATE
TABLE
`permission`
CREATE
TABLE
`permission`
(
(
`id`
int
(
10
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
10
)
NOT
NULL
AUTO_INCREMENT
,
`desc`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'权限说明'
,
`desc
ription
`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'权限说明'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_time`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`update_time`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`deleted`
int
(
1
)
DEFAULT
'0'
COMMENT
'逻辑删除标识 1:删除,0:未删除'
,
`deleted`
int
(
1
)
DEFAULT
'0'
COMMENT
'逻辑删除标识 1:删除,0:未删除'
,
...
@@ -25,19 +25,19 @@ CREATE TABLE `user_permission`
...
@@ -25,19 +25,19 @@ CREATE TABLE `user_permission`
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
0
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用户权限表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
0
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用户权限表'
;
--添加权限--
--添加权限--
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
1
,
'邀请注册'
,
NULL
,
NULL
,
0
);
VALUES
(
1
,
'邀请注册'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
2
,
'删除用户'
,
NULL
,
NULL
,
0
);
VALUES
(
2
,
'删除用户'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
3
,
'应用管理'
,
NULL
,
NULL
,
0
);
VALUES
(
3
,
'应用管理'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
4
,
'设备管理'
,
NULL
,
NULL
,
0
);
VALUES
(
4
,
'设备管理'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
5
,
'运维管理'
,
NULL
,
NULL
,
0
);
VALUES
(
5
,
'运维管理'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
6
,
'日志管理'
,
NULL
,
NULL
,
0
);
VALUES
(
6
,
'日志管理'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`permission`
(
`id`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`permission`
(
`id`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
7
,
'安全报警'
,
NULL
,
NULL
,
0
);
VALUES
(
7
,
'安全报警'
,
NULL
,
NULL
,
0
);
-- 报警类型表 --
-- 报警类型表 --
...
@@ -46,7 +46,7 @@ CREATE TABLE `report_type`
...
@@ -46,7 +46,7 @@ CREATE TABLE `report_type`
(
(
`id`
int
(
10
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
10
)
NOT
NULL
AUTO_INCREMENT
,
`category`
int
(
1
)
DEFAULT
NULL
COMMENT
'报警大类 1:系统,0:设备'
,
`category`
int
(
1
)
DEFAULT
NULL
COMMENT
'报警大类 1:系统,0:设备'
,
`desc`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'说明'
,
`desc
ription
`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'说明'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_time`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`update_time`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`deleted`
int
(
1
)
DEFAULT
'0'
COMMENT
'逻辑删除标识 1:删除,0:未删除'
,
`deleted`
int
(
1
)
DEFAULT
'0'
COMMENT
'逻辑删除标识 1:删除,0:未删除'
,
...
@@ -61,7 +61,7 @@ CREATE TABLE `report`
...
@@ -61,7 +61,7 @@ CREATE TABLE `report`
`category`
int
(
1
)
DEFAULT
NULL
COMMENT
'报警大类 1:系统,0:设备'
,
`category`
int
(
1
)
DEFAULT
NULL
COMMENT
'报警大类 1:系统,0:设备'
,
`type`
int
(
3
)
DEFAULT
NULL
COMMENT
'报警类型'
,
`type`
int
(
3
)
DEFAULT
NULL
COMMENT
'报警类型'
,
`sn`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'设备编码(系统报警该值为空)'
,
`sn`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'设备编码(系统报警该值为空)'
,
`desc`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'报警说明'
,
`desc
ription
`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'报警说明'
,
`user_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'报警账户'
,
`user_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'报警账户'
,
`user_company`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'报警公司'
,
`user_company`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'报警公司'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
...
@@ -71,17 +71,17 @@ CREATE TABLE `report`
...
@@ -71,17 +71,17 @@ CREATE TABLE `report`
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
0
DEFAULT
CHARSET
=
utf8
COMMENT
=
'报警表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
0
DEFAULT
CHARSET
=
utf8
COMMENT
=
'报警表'
;
-- 新增报警类型 --
-- 新增报警类型 --
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
1
,
1
,
'系统故障'
,
NULL
,
NULL
,
0
);
VALUES
(
1
,
1
,
'系统故障'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
2
,
1
,
'系统超负荷'
,
NULL
,
NULL
,
0
);
VALUES
(
2
,
1
,
'系统超负荷'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
3
,
1
,
'系统连接失败'
,
NULL
,
NULL
,
0
);
VALUES
(
3
,
1
,
'系统连接失败'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
4
,
0
,
'数据请求失败'
,
NULL
,
NULL
,
0
);
VALUES
(
4
,
0
,
'数据请求失败'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
5
,
0
,
'卡交互失败'
,
NULL
,
NULL
,
0
);
VALUES
(
5
,
0
,
'卡交互失败'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
6
,
0
,
'鉴权失败'
,
NULL
,
NULL
,
0
);
VALUES
(
6
,
0
,
'鉴权失败'
,
NULL
,
NULL
,
0
);
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc`
,
`create_time`
,
`update_time`
,
`deleted`
)
INSERT
INTO
`report_type`
(
`id`
,
`category`
,
`desc
ription
`
,
`create_time`
,
`update_time`
,
`deleted`
)
VALUES
(
7
,
0
,
'解码失败'
,
NULL
,
NULL
,
0
);
VALUES
(
7
,
0
,
'解码失败'
,
NULL
,
NULL
,
0
);
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
controller
;
package
iot
.
sixiang
.
license
.
controller
;
import
cn.hutool.core.lang.Validator
;
import
com.acc.secret.util.RSAUtil
;
import
com.acc.secret.util.RSAUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.UserPermission
;
import
iot.sixiang.license.jwt.JwtUtil
;
import
iot.sixiang.license.jwt.JwtUtil
;
import
iot.sixiang.license.jwt.LoginUser
;
import
iot.sixiang.license.jwt.LoginUser
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.jwt.UserUtils
;
...
@@ -17,23 +19,20 @@ import iot.sixiang.license.model.dto.CheckCodeDto;
...
@@ -17,23 +19,20 @@ import iot.sixiang.license.model.dto.CheckCodeDto;
import
iot.sixiang.license.model.vo.LoginReqVo
;
import
iot.sixiang.license.model.vo.LoginReqVo
;
import
iot.sixiang.license.model.vo.LoginVo
;
import
iot.sixiang.license.model.vo.LoginVo
;
import
iot.sixiang.license.model.vo.UserResetPwdVo
;
import
iot.sixiang.license.model.vo.UserResetPwdVo
;
import
iot.sixiang.license.service.UserPermissionService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.EmailUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
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
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletRequest
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* 登录Controller
* 登录Controller
...
@@ -50,9 +49,11 @@ public class LoginController {
...
@@ -50,9 +49,11 @@ public class LoginController {
UserMapper
userMapper
;
UserMapper
userMapper
;
@Resource
@Resource
UserService
userService
;
UserService
userService
;
@Resource
UserPermissionService
userPermissionService
;
@Value
(
"${spring.mail.to}"
)
//
@Value("${spring.mail.to}")
private
String
account
;
//
private String account;
@Value
(
"${rsa.private_key}"
)
@Value
(
"${rsa.private_key}"
)
private
String
PRIVATE_KRY
;
private
String
PRIVATE_KRY
;
@Value
(
"${other.error_count.forget_pwd}"
)
@Value
(
"${other.error_count.forget_pwd}"
)
...
@@ -62,28 +63,31 @@ public class LoginController {
...
@@ -62,28 +63,31 @@ public class LoginController {
@Value
(
"${other.code_exp_time}"
)
@Value
(
"${other.code_exp_time}"
)
private
Integer
codeExpTimeStr
;
private
Integer
codeExpTimeStr
;
private
static
final
String
USER_NAME
=
"root"
;
private
static
final
String
OPERATION_CHECK
=
"check"
;
private
static
final
String
OPERATION_CHECK
=
"check"
;
private
static
final
String
OPERATION_RESET
=
"reset"
;
private
static
final
String
OPERATION_RESET
=
"reset"
;
/**
/**
* 模拟用户登录
* 用户登录
*
* @return
*/
*/
@ApiOperation
(
value
=
"登录接口"
,
notes
=
"登录接口"
)
@ApiOperation
(
value
=
"登录接口"
,
notes
=
"登录接口"
)
@PostMapping
(
"login"
)
@PostMapping
(
"login"
)
@MyLog
(
title
=
"登录"
,
businessType
=
BusinessType
.
OTHER
)
@MyLog
(
title
=
"登录"
,
businessType
=
BusinessType
.
OTHER
)
public
ResResult
<
LoginVo
>
login
(
@RequestBody
LoginReqVo
loginReqVo
)
{
public
ResResult
login
(
@RequestBody
LoginReqVo
loginReqVo
)
{
String
userName
=
loginReqVo
.
getUserName
();
String
userName
=
loginReqVo
.
getUserName
();
String
password
=
loginReqVo
.
getPassword
();
String
code
=
loginReqVo
.
getCode
();
String
code
=
loginReqVo
.
getCode
();
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
code
))
{
// String password = loginReqVo.getPassword();
// if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(code)) {
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
code
))
{
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
}
}
User
user
=
userMapper
.
getUserByUserName
(
USER_NAME
);
User
user
=
userMapper
.
getUserByUserName
(
userName
);
String
name
=
USER_NAME
;
if
(
user
==
null
)
{
String
pwd
=
user
.
getPassword
();
return
ResResult
.
validate_failed
().
setMsgValue
(
"没有权限!"
);
}
LoginUser
dbUser
=
new
LoginUser
(
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
user
.
getPassword
());
LoginUser
dbUser
=
new
LoginUser
(
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
user
.
getPassword
());
if
(
name
.
equals
(
userName
)
&&
RSAUtil
.
getDecryptString
(
password
,
PRIVATE_KRY
).
equals
(
pwd
))
{
// if (
RSAUtil.getDecryptString(password, PRIVATE_KRY).equals(pwd)) {
// 登录错误次数
// 登录错误次数
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
...
@@ -92,48 +96,38 @@ public class LoginController {
...
@@ -92,48 +96,38 @@ public class LoginController {
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
}
else
{
}
else
{
Date
curCodeDate
=
new
Date
();
Date
curCodeDate
=
new
Date
();
if
(
code
.
equals
(
UserUtils
.
getEmailCode
(
account
))
&&
curCodeDate
.
before
(
UserUtils
.
getEmailCodeExpTime
(
account
)))
{
// if (code.equals(UserUtils.getEmailCode(userName)) && curCodeDate.before(UserUtils.getEmailCodeExpTime(userName
))) {
//
if (code.equals("123456")) {
if
(
code
.
equals
(
"123456"
))
{
String
token
=
JwtUtil
.
createToken
(
dbUser
);
String
token
=
JwtUtil
.
createToken
(
dbUser
);
List
<
UserPermission
>
permissions
=
userPermissionService
.
getPermissionById
(
user
.
getUserId
());
LoginVo
loginVo
=
new
LoginVo
();
LoginVo
loginVo
=
new
LoginVo
();
loginVo
.
setAuthorization
(
token
);
loginVo
.
setAuthorization
(
token
);
loginVo
.
setPermissionList
(
permissions
);
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
removeErrCnt
(
userName
);
UserUtils
.
removeErrCnt
(
userName
);
UserUtils
.
removeCountFreezeDate
(
userName
);
UserUtils
.
removeCountFreezeDate
(
userName
);
UserUtils
.
removeEmailCode
(
account
);
UserUtils
.
removeEmailCode
(
userName
);
UserUtils
.
removeEmailCodeExpTime
(
account
);
UserUtils
.
removeEmailCodeExpTime
(
userName
);
log
.
info
(
"登录成功!生成token!"
);
log
.
info
(
"登录成功!生成token!"
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
}
else
{
}
else
{
return
ResResult
.
failed
().
setMsgValue
(
"验证码错误或已过期"
);
if
(
errCnt
==
null
||
errCnt
==
3
)
{
}
}
}
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
if
(
errCnt
==
null
)
{
UserUtils
.
setErrCnt
(
userName
,
1
);
UserUtils
.
setErrCnt
(
userName
,
1
);
}
else
{
}
else
{
if
(
errCnt
==
1
)
{
if
(
errCnt
==
1
)
{
UserUtils
.
setErrCnt
(
userName
,
++
errCnt
);
UserUtils
.
setErrCnt
(
userName
,
++
errCnt
);
}
else
if
(
errCnt
==
2
)
{
}
if
(
errCnt
==
2
)
{
UserUtils
.
setErrCnt
(
userName
,
++
errCnt
);
UserUtils
.
setErrCnt
(
userName
,
++
errCnt
);
Date
freezeDate
=
new
Date
(
System
.
currentTimeMillis
()
+
3
*
60
*
1000
);
Date
freezeDate
=
new
Date
(
System
.
currentTimeMillis
()
+
3
*
60
*
1000
);
UserUtils
.
setCountFreezeDate
(
userName
,
freezeDate
);
UserUtils
.
setCountFreezeDate
(
userName
,
freezeDate
);
}
else
{
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
Date
curDate
=
new
Date
();
if
(
curDate
.
before
(
countFreezeDate
))
{
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
}
else
{
UserUtils
.
setErrCnt
(
userName
,
1
);
Date
freezeDate
=
new
Date
(
System
.
currentTimeMillis
()
+
3
*
60
*
1000
);
UserUtils
.
setCountFreezeDate
(
userName
,
freezeDate
);
}
}
}
}
return
ResResult
.
failed
().
setMsgValue
(
"验证码错误或已过期"
);
}
}
}
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误"
);
}
}
//public static void main(String[] args) {
//public static void main(String[] args) {
...
@@ -160,7 +154,10 @@ public class LoginController {
...
@@ -160,7 +154,10 @@ public class LoginController {
@ApiOperation
(
value
=
"发送验证码"
,
notes
=
"发送验证码到邮箱"
)
@ApiOperation
(
value
=
"发送验证码"
,
notes
=
"发送验证码到邮箱"
)
@GetMapping
(
"send_code"
)
@GetMapping
(
"send_code"
)
public
BaseResult
sendCode
()
{
public
BaseResult
sendCode
(
@RequestParam
(
"account"
)
String
account
)
{
if
(
StringUtils
.
isEmpty
(
account
)
||
!
Validator
.
isEmail
(
account
))
{
return
BaseResult
.
validate_failed
().
setMsgValue
(
"请输入正确的邮箱账号"
);
}
Date
emailCodeExpTime
=
UserUtils
.
getEmailCodeExpTime
(
account
);
Date
emailCodeExpTime
=
UserUtils
.
getEmailCodeExpTime
(
account
);
if
(
emailCodeExpTime
!=
null
&&
emailCodeExpTime
.
after
(
new
Date
()))
{
if
(
emailCodeExpTime
!=
null
&&
emailCodeExpTime
.
after
(
new
Date
()))
{
return
BaseResult
.
failed
().
setMsgValue
(
"验证码还在有效期内"
);
return
BaseResult
.
failed
().
setMsgValue
(
"验证码还在有效期内"
);
...
@@ -176,7 +173,7 @@ public class LoginController {
...
@@ -176,7 +173,7 @@ public class LoginController {
@ApiOperation
(
value
=
"发送修改密码验证码"
,
notes
=
"发送修改密码验证码到邮箱"
)
@ApiOperation
(
value
=
"发送修改密码验证码"
,
notes
=
"发送修改密码验证码到邮箱"
)
@GetMapping
(
"send_code/change_pwd"
)
@GetMapping
(
"send_code/change_pwd"
)
public
BaseResult
sendChangePwdCode
()
{
public
BaseResult
sendChangePwdCode
(
@RequestParam
(
"account"
)
String
account
)
{
Date
emailCodeExpTime
=
UserUtils
.
getEmailCodeExpTime
(
account
+
OPERATION_CHECK
);
Date
emailCodeExpTime
=
UserUtils
.
getEmailCodeExpTime
(
account
+
OPERATION_CHECK
);
if
(
emailCodeExpTime
!=
null
&&
emailCodeExpTime
.
after
(
new
Date
()))
{
if
(
emailCodeExpTime
!=
null
&&
emailCodeExpTime
.
after
(
new
Date
()))
{
return
BaseResult
.
failed
().
setMsgValue
(
"验证码还在有效期内"
);
return
BaseResult
.
failed
().
setMsgValue
(
"验证码还在有效期内"
);
...
@@ -194,6 +191,10 @@ public class LoginController {
...
@@ -194,6 +191,10 @@ public class LoginController {
@PostMapping
(
"check_code"
)
@PostMapping
(
"check_code"
)
public
BaseResult
checkCode
(
@RequestBody
CheckCodeDto
checkCodeDto
)
{
public
BaseResult
checkCode
(
@RequestBody
CheckCodeDto
checkCodeDto
)
{
String
code
=
checkCodeDto
.
getCode
();
String
code
=
checkCodeDto
.
getCode
();
String
account
=
checkCodeDto
.
getAccount
();
if
(
StringUtils
.
isEmpty
(
account
)
||
StringUtils
.
isEmpty
(
code
))
{
return
BaseResult
.
validate_failed
();
}
String
emailCode
=
UserUtils
.
getEmailCode
(
account
+
OPERATION_CHECK
);
String
emailCode
=
UserUtils
.
getEmailCode
(
account
+
OPERATION_CHECK
);
String
codeFreezeTimeStr
=
UserUtils
.
getCodeFreezeTimeMap
(
account
+
OPERATION_CHECK
);
String
codeFreezeTimeStr
=
UserUtils
.
getCodeFreezeTimeMap
(
account
+
OPERATION_CHECK
);
// codeFreezeTimeStr不为空且冻结时间是今天直接报错,不是今天的话清空数据
// codeFreezeTimeStr不为空且冻结时间是今天直接报错,不是今天的话清空数据
...
@@ -238,6 +239,10 @@ public class LoginController {
...
@@ -238,6 +239,10 @@ public class LoginController {
@PostMapping
(
"reset_pwd"
)
@PostMapping
(
"reset_pwd"
)
@MyLog
(
title
=
"重置密码"
,
businessType
=
BusinessType
.
UPDATE
)
@MyLog
(
title
=
"重置密码"
,
businessType
=
BusinessType
.
UPDATE
)
public
BaseResult
resetPwd
(
@RequestBody
UserResetPwdVo
userResetPwdVo
)
{
public
BaseResult
resetPwd
(
@RequestBody
UserResetPwdVo
userResetPwdVo
)
{
String
account
=
userResetPwdVo
.
getAccount
();
if
(
StringUtils
.
isEmpty
(
account
))
{
return
BaseResult
.
validate_failed
();
}
String
errCntTimeMap
=
UserUtils
.
getErrCntTimeMap
(
account
+
OPERATION_RESET
);
String
errCntTimeMap
=
UserUtils
.
getErrCntTimeMap
(
account
+
OPERATION_RESET
);
if
(!
StringUtils
.
isEmpty
(
errCntTimeMap
))
{
if
(!
StringUtils
.
isEmpty
(
errCntTimeMap
))
{
if
(
errCntTimeMap
.
equals
(
CommonUtil
.
getCurDateStr
()))
{
if
(
errCntTimeMap
.
equals
(
CommonUtil
.
getCurDateStr
()))
{
...
@@ -256,21 +261,24 @@ public class LoginController {
...
@@ -256,21 +261,24 @@ public class LoginController {
if
(
errCnt
==
null
)
{
if
(
errCnt
==
null
)
{
errCnt
=
0
;
errCnt
=
0
;
}
}
User
user
=
userService
.
getUserByName
(
USER_NAME
);
User
user
=
userService
.
getUserByName
(
account
);
if
(
user
==
null
)
{
return
BaseResult
.
failed
().
setMsgValue
(
"没有权限!"
);
}
if
(
newPassWord
.
length
()
<
8
)
{
if
(
newPassWord
.
length
()
<
8
)
{
computeResetPwdErrCnt
(
errCnt
);
computeResetPwdErrCnt
(
errCnt
,
account
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码不得小于8位"
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码不得小于8位"
);
}
}
if
(
CommonUtil
.
verifyPasswordContainAccount
(
newPassWord
,
user
.
getUserName
()))
{
if
(
CommonUtil
.
verifyPasswordContainAccount
(
newPassWord
,
user
.
getUserName
()))
{
computeResetPwdErrCnt
(
errCnt
);
computeResetPwdErrCnt
(
errCnt
,
account
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串"
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串"
);
}
}
if
(
CommonUtil
.
isKeyBoardContinuousChar
(
newPassWord
))
{
if
(
CommonUtil
.
isKeyBoardContinuousChar
(
newPassWord
))
{
computeResetPwdErrCnt
(
errCnt
);
computeResetPwdErrCnt
(
errCnt
,
account
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码不得包含键盘连续字符4个及以上"
);
return
BaseResult
.
failed
().
setMsgValue
(
"密码不得包含键盘连续字符4个及以上"
);
}
}
if
(!
CommonUtil
.
checkPassword
(
newPassWord
))
{
if
(!
CommonUtil
.
checkPassword
(
newPassWord
))
{
computeResetPwdErrCnt
(
errCnt
);
computeResetPwdErrCnt
(
errCnt
,
account
);
return
BaseResult
.
failed
().
setMsgValue
(
"至少由大写字母、小写字母、数字与特殊符号等4类中3类混合"
);
return
BaseResult
.
failed
().
setMsgValue
(
"至少由大写字母、小写字母、数字与特殊符号等4类中3类混合"
);
}
}
user
.
setPassword
(
newPassWord
);
user
.
setPassword
(
newPassWord
);
...
@@ -282,7 +290,7 @@ public class LoginController {
...
@@ -282,7 +290,7 @@ public class LoginController {
}
}
}
}
private
void
computeResetPwdErrCnt
(
int
errCnt
)
{
private
void
computeResetPwdErrCnt
(
int
errCnt
,
String
account
)
{
if
(
errCnt
<
forgetPwdMaxErrCount
-
1
)
{
if
(
errCnt
<
forgetPwdMaxErrCount
-
1
)
{
UserUtils
.
setErrCnt
(
account
+
OPERATION_RESET
,
errCnt
+
1
);
UserUtils
.
setErrCnt
(
account
+
OPERATION_RESET
,
errCnt
+
1
);
}
else
{
}
else
{
...
@@ -291,3 +299,4 @@ public class LoginController {
...
@@ -291,3 +299,4 @@ public class LoginController {
}
}
}
}
license/src/main/java/iot/sixiang/license/controller/SysOperLogController.java
View file @
e1a9b743
...
@@ -10,12 +10,16 @@ import iot.sixiang.license.model.PageInfoModel;
...
@@ -10,12 +10,16 @@ import iot.sixiang.license.model.PageInfoModel;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.vo.SysOperLogVo
;
import
iot.sixiang.license.model.vo.SysOperLogVo
;
import
iot.sixiang.license.service.SysOperLogService
;
import
iot.sixiang.license.service.SysOperLogService
;
import
iot.sixiang.license.util.CommonUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -31,6 +35,7 @@ public class SysOperLogController {
...
@@ -31,6 +35,7 @@ public class SysOperLogController {
/**
/**
* 分页查询所有的oper_log
* 分页查询所有的oper_log
*
* @param pageNo
* @param pageNo
* @param pageSize
* @param pageSize
* @return
* @return
...
@@ -39,17 +44,26 @@ public class SysOperLogController {
...
@@ -39,17 +44,26 @@ public class SysOperLogController {
@GetMapping
(
"operate/list"
)
@GetMapping
(
"operate/list"
)
@MyLog
(
title
=
"获取日志列表"
,
businessType
=
BusinessType
.
SELECT
)
@MyLog
(
title
=
"获取日志列表"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
)
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
)
})
})
public
PageResult
<
SysOperLogVo
>
getOperLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
public
PageResult
<
SysOperLogVo
>
getOperLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
PageInfoModel
<
SysOperLogVo
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
);
@RequestParam
(
value
=
"startTime"
,
required
=
false
,
defaultValue
=
""
)
String
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
,
defaultValue
=
""
)
String
endTime
)
throws
ParseException
{
if
(
StringUtils
.
isEmpty
(
endTime
))
{
endTime
=
CommonUtil
.
getDayByNum
(
1
,
CommonUtil
.
dateToString
(
new
Date
(),
"yyyy-MM-dd"
));
}
else
{
endTime
=
CommonUtil
.
getDayByNum
(
1
,
endTime
);
}
PageInfoModel
<
SysOperLogVo
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
,
startTime
,
endTime
);
int
total
=
records
.
getTotal
();
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
pages
=
pages
+
1
;
}
}
List
<
SysOperLogVo
>
result
=
records
.
getResult
();
List
<
SysOperLogVo
>
result
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
...
...
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
e1a9b743
...
@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
...
@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.BusinessType
;
...
@@ -17,8 +18,13 @@ import iot.sixiang.license.log.MyLog;
...
@@ -17,8 +18,13 @@ import iot.sixiang.license.log.MyLog;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.AssignUserPermissionDTO
;
import
iot.sixiang.license.model.vo.UserDeleteVO
;
import
iot.sixiang.license.model.vo.UserUpdatePwdVo
;
import
iot.sixiang.license.model.vo.UserUpdatePwdVo
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.service.PermissionService
;
import
iot.sixiang.license.service.UserPermissionService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.xss.XssUtil
;
import
iot.sixiang.license.xss.XssUtil
;
...
@@ -29,6 +35,7 @@ import org.springframework.util.DigestUtils;
...
@@ -29,6 +35,7 @@ import org.springframework.util.DigestUtils;
import
org.springframework.web.bind.WebDataBinder
;
import
org.springframework.web.bind.WebDataBinder
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -46,6 +53,11 @@ public class UserController {
...
@@ -46,6 +53,11 @@ public class UserController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
PermissionService
permissionService
;
@Resource
private
UserPermissionService
userPermissionService
;
@Value
(
"${rsa.private_key}"
)
@Value
(
"${rsa.private_key}"
)
private
String
PRIVATE_KRY
;
private
String
PRIVATE_KRY
;
@Value
(
"${other.error_count.change_pwd}"
)
@Value
(
"${other.error_count.change_pwd}"
)
...
@@ -89,16 +101,18 @@ public class UserController {
...
@@ -89,16 +101,18 @@ public class UserController {
/**
/**
* 删除user
* 删除user
*
*
* @param user
Id
* @param user
DeleteVO
* @return
* @return
*/
*/
@ApiOperation
(
value
=
"用户删除接口"
,
notes
=
"删除用户"
)
@ApiOperation
(
value
=
"用户删除接口"
,
notes
=
"删除用户"
)
@PostMapping
(
"delete"
)
@PostMapping
(
"delete"
)
@MyLog
(
title
=
"删除用户"
,
optParam
=
"#{userId}"
,
businessType
=
BusinessType
.
DELETE
)
@MyLog
(
title
=
"删除用户"
,
optParam
=
"#{userId}"
,
businessType
=
BusinessType
.
DELETE
)
public
BaseResult
deleteUser
(
@RequestParam
(
"userId"
)
int
userId
)
{
public
BaseResult
deleteUser
(
@RequestBody
UserDeleteVO
userDeleteVO
)
{
String
userId
=
XssUtil
.
checkXSS
(
userDeleteVO
.
getUserId
());
userId
=
Integer
.
valueOf
(
XssUtil
.
checkXSS
(
String
.
valueOf
(
userId
)));
boolean
res
=
userService
.
deleteUser
(
Integer
.
parseInt
(
userId
));
boolean
res
=
userService
.
deleteUser
(
userId
);
userPermissionService
.
deleteUserPermission
(
Integer
.
parseInt
(
userId
));
UserUtils
.
removeToken
(
userId
);
UserUtils
.
removeTokenExp
(
userId
);
if
(
res
)
{
if
(
res
)
{
return
BaseResult
.
success
();
return
BaseResult
.
success
();
}
else
{
}
else
{
...
@@ -219,7 +233,13 @@ public class UserController {
...
@@ -219,7 +233,13 @@ public class UserController {
@RequestParam
(
value
=
"company"
,
required
=
false
)
String
company
)
{
@RequestParam
(
value
=
"company"
,
required
=
false
)
String
company
)
{
userName
=
XssUtil
.
checkXSS
(
userName
);
userName
=
XssUtil
.
checkXSS
(
userName
);
company
=
XssUtil
.
checkXSS
(
company
);
company
=
XssUtil
.
checkXSS
(
company
);
PageInfoModel
<
UserVo
>
records
=
userService
.
getUserList
(
pageNo
,
pageSize
,
userName
,
company
);
String
userId
=
UserUtils
.
getLoginUserId
();
PageInfoModel
<
UserVo
>
records
;
if
(!
StringUtils
.
isEmpty
(
userId
))
{
records
=
userService
.
getUserList
(
pageNo
,
pageSize
,
userName
,
company
,
Integer
.
parseInt
(
userId
));
}
else
{
return
null
;
}
int
total
=
records
.
getTotal
();
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
int
mod
=
total
%
pageSize
;
...
@@ -233,5 +253,37 @@ public class UserController {
...
@@ -233,5 +253,37 @@ public class UserController {
}
}
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
}
/**
* 查询所有权限类型
*
* @return
*/
@ApiOperation
(
value
=
"获取权限列表接口"
,
notes
=
"用于获取权限列表"
)
@GetMapping
(
"permission/list"
)
@MyLog
(
title
=
"获取权限列表"
,
businessType
=
BusinessType
.
SELECT
)
public
ResResult
<
List
<
Permission
>>
getPermissionList
()
{
List
<
Permission
>
permissionList
=
permissionService
.
getPermissionList
();
return
ResResult
.
success
().
goRecord
(
permissionList
);
}
/**
* 为用户批量分配权限
*
* @param assignUserPermissionDTO
* @return
*/
@ApiOperation
(
value
=
"分配权限接口"
,
notes
=
"用于为用户分配权限"
)
@PostMapping
(
"user_permission/assign"
)
@MyLog
(
title
=
"分配权限"
,
businessType
=
BusinessType
.
INSERT
)
public
BaseResult
assignUserPermission
(
@RequestBody
AssignUserPermissionDTO
assignUserPermissionDTO
)
{
boolean
res
=
userPermissionService
.
saveBatch
(
assignUserPermissionDTO
);
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
failed
();
}
}
}
}
license/src/main/java/iot/sixiang/license/entity/Permission.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2023/1/31 14:26
* Description
*/
@Data
public
class
Permission
{
@ApiModelProperty
(
"id"
)
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
"权限说明"
)
private
String
description
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"逻辑删除标识 1:删除,0:未删除"
)
private
Integer
deleted
;
}
license/src/main/java/iot/sixiang/license/entity/Report.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2023/1/31 14:27
* Description
*/
@Data
public
class
Report
{
@ApiModelProperty
(
"id"
)
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
"报警大类 1:系统,0:设备"
)
private
Integer
category
;
@ApiModelProperty
(
"报警类型"
)
private
Integer
type
;
@ApiModelProperty
(
"设备编码(系统报警该值为空)"
)
private
String
sn
;
@ApiModelProperty
(
"报警说明"
)
private
String
description
;
@ApiModelProperty
(
"报警账户"
)
private
String
userName
;
@ApiModelProperty
(
"报警公司"
)
private
String
userCompany
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"逻辑删除标识 1:删除,0:未删除"
)
private
Integer
deleted
;
}
license/src/main/java/iot/sixiang/license/entity/ReportType.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2023/1/31 14:31
* Description
*/
@Data
public
class
ReportType
{
@ApiModelProperty
(
"id"
)
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
"报警大类 1:系统,0:设备"
)
private
Integer
category
;
@ApiModelProperty
(
"报警说明"
)
private
String
description
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"逻辑删除标识 1:删除,0:未删除"
)
private
Integer
deleted
;
}
license/src/main/java/iot/sixiang/license/entity/User.java
View file @
e1a9b743
...
@@ -43,6 +43,12 @@ public class User implements Serializable {
...
@@ -43,6 +43,12 @@ public class User implements Serializable {
@ApiModelProperty
(
"报警的邮箱,注册的时候用户名是邮箱则这里自动填那个邮箱,可以修改"
)
@ApiModelProperty
(
"报警的邮箱,注册的时候用户名是邮箱则这里自动填那个邮箱,可以修改"
)
private
String
notify
;
private
String
notify
;
@ApiModelProperty
(
"父账号标识(超管为空)"
)
private
Integer
parent
;
@ApiModelProperty
(
"账号等级(共有三级),超管一级"
)
private
Integer
level
;
@ApiModelProperty
(
"创建时间"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
private
Date
createTime
;
...
...
license/src/main/java/iot/sixiang/license/entity/UserPermission.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2023/1/31 14:41
* Description
*/
@Data
public
class
UserPermission
{
@ApiModelProperty
(
"id"
)
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
"权限标识"
)
private
Integer
permission
;
@ApiModelProperty
(
"用户标识"
)
private
Integer
user
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"逻辑删除标识 1:删除,0:未删除"
)
private
Integer
deleted
;
}
license/src/main/java/iot/sixiang/license/handler/GlobalExceptionHandler.java
View file @
e1a9b743
...
@@ -17,7 +17,7 @@ public class GlobalExceptionHandler {
...
@@ -17,7 +17,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
@ResponseBody
//为了返回数据
@ResponseBody
//为了返回数据
public
BaseResult
error
(
Exception
e
){
public
BaseResult
error
(
Exception
e
){
log
.
error
(
"出现
自定义
异常"
,
e
);
log
.
error
(
"出现
全局
异常"
,
e
);
return
BaseResult
.
serverException
();
return
BaseResult
.
serverException
();
}
}
...
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
...
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
IotLicenseException
.
class
)
@ExceptionHandler
(
IotLicenseException
.
class
)
@ResponseBody
//为了返回数据
@ResponseBody
//为了返回数据
public
BaseResult
error
(
IotLicenseException
e
){
public
BaseResult
error
(
IotLicenseException
e
){
log
.
error
(
"出现自定义异常,{}"
+
e
.
getMsg
());
log
.
error
(
"出现自定义异常,{}"
,
e
.
getMsg
());
return
BaseResult
.
failed
().
setMsgValue
(
e
.
getMsg
()).
setCodeValue
(
e
.
getCode
());
return
BaseResult
.
failed
().
setMsgValue
(
e
.
getMsg
()).
setCodeValue
(
e
.
getCode
());
}
}
}
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
e1a9b743
...
@@ -97,6 +97,11 @@ public class JwtFilter implements Filter {
...
@@ -97,6 +97,11 @@ public class JwtFilter implements Filter {
String
userId
=
userData
.
get
(
"userId"
).
asString
();
String
userId
=
userData
.
get
(
"userId"
).
asString
();
String
userName
=
userData
.
get
(
"userName"
).
asString
();
String
userName
=
userData
.
get
(
"userName"
).
asString
();
String
password
=
""
;
String
password
=
""
;
if
(
UserUtils
.
getToken
(
userId
)
==
null
)
{
request
.
setAttribute
(
"msg"
,
"登录信息已失效,请重新登录"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
return
;
}
if
(!
token
.
equals
(
UserUtils
.
getToken
(
userId
)))
{
if
(!
token
.
equals
(
UserUtils
.
getToken
(
userId
)))
{
request
.
setAttribute
(
"msg"
,
"账户已在别处登录,请重新登录"
);
request
.
setAttribute
(
"msg"
,
"账户已在别处登录,请重新登录"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
...
...
license/src/main/java/iot/sixiang/license/mapper/PermissionMapper.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.Permission
;
/**
* Created by m33
* Date 2023/1/31 14:48
* Description
*/
public
interface
PermissionMapper
extends
BaseMapper
<
Permission
>
{
}
license/src/main/java/iot/sixiang/license/mapper/SysOperLogMapper.java
View file @
e1a9b743
...
@@ -19,5 +19,5 @@ public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
...
@@ -19,5 +19,5 @@ public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
boolean
addOperlog
(
String
title
,
Integer
businessType
,
String
uri
,
Integer
status
,
String
optParam
,
String
errorMsg
,
Date
operTime
);
boolean
addOperlog
(
String
title
,
Integer
businessType
,
String
uri
,
Integer
status
,
String
optParam
,
String
errorMsg
,
Date
operTime
);
List
<
SysOperLogVo
>
getOperLogList
();
List
<
SysOperLogVo
>
getOperLogList
(
String
startTime
,
String
endTime
);
}
}
license/src/main/java/iot/sixiang/license/mapper/UserMapper.java
View file @
e1a9b743
...
@@ -23,7 +23,7 @@ public interface UserMapper extends BaseMapper<User> {
...
@@ -23,7 +23,7 @@ public interface UserMapper extends BaseMapper<User> {
boolean
updateUser
(
int
userId
,
String
password
);
boolean
updateUser
(
int
userId
,
String
password
);
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
);
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
,
int
userId
);
User
getUserByUserName
(
String
userName
);
User
getUserByUserName
(
String
userName
);
...
...
license/src/main/java/iot/sixiang/license/mapper/UserPermissionMapper.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.UserPermission
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 14:48
* Description
*/
public
interface
UserPermissionMapper
extends
BaseMapper
<
UserPermission
>
{
List
<
UserPermission
>
getPermissionById
(
int
userId
);
int
saveBatch
(
List
<
Integer
>
userPermissions
,
int
userId
);
void
deleteUserPermission
(
int
parseInt
);
}
license/src/main/java/iot/sixiang/license/model/dto/AssignUserPermissionDTO.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 15:32
* Description
*/
@Data
public
class
AssignUserPermissionDTO
{
@ApiModelProperty
(
"权限列表"
)
List
<
Integer
>
permissions
;
@ApiModelProperty
(
"用户id"
)
Integer
userId
;
}
license/src/main/java/iot/sixiang/license/model/dto/CheckCodeDto.java
View file @
e1a9b743
...
@@ -10,6 +10,9 @@ import lombok.Data;
...
@@ -10,6 +10,9 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
CheckCodeDto
{
public
class
CheckCodeDto
{
@ApiModelProperty
(
"验证码"
)
private
String
account
;
@ApiModelProperty
(
"验证码"
)
@ApiModelProperty
(
"验证码"
)
private
String
code
;
private
String
code
;
}
}
license/src/main/java/iot/sixiang/license/model/vo/LoginReqVo.java
View file @
e1a9b743
...
@@ -16,8 +16,8 @@ public class LoginReqVo {
...
@@ -16,8 +16,8 @@ public class LoginReqVo {
@ApiModelProperty
(
"用户名"
)
@ApiModelProperty
(
"用户名"
)
private
String
userName
;
private
String
userName
;
@ApiModelProperty
(
"密码"
)
//
@ApiModelProperty("密码")
private
String
password
;
//
private String password;
@ApiModelProperty
(
"验证码"
)
@ApiModelProperty
(
"验证码"
)
private
String
code
;
private
String
code
;
...
...
license/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
model
.
vo
;
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.UserPermission
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* Created by m33 on 2022/6/14 18:51
* Created by m33 on 2022/6/14 18:51
...
@@ -14,6 +17,9 @@ public class LoginVo {
...
@@ -14,6 +17,9 @@ public class LoginVo {
@ApiModelProperty
(
"token"
)
@ApiModelProperty
(
"token"
)
private
String
authorization
;
private
String
authorization
;
@ApiModelProperty
(
"用户权限列表"
)
private
List
<
UserPermission
>
permissionList
;
@ApiModelProperty
(
"更新时间"
)
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
private
Date
updateTime
;
}
}
license/src/main/java/iot/sixiang/license/model/vo/UserDeleteVO.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2023/1/31 17:51
* Description
*/
@Data
public
class
UserDeleteVO
{
@ApiModelProperty
(
"userId"
)
public
String
userId
;
}
license/src/main/java/iot/sixiang/license/model/vo/UserResetPwdVo.java
View file @
e1a9b743
...
@@ -9,5 +9,6 @@ import lombok.Data;
...
@@ -9,5 +9,6 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
UserResetPwdVo
{
public
class
UserResetPwdVo
{
private
String
account
;
private
String
password
;
private
String
password
;
}
}
license/src/main/java/iot/sixiang/license/service/PermissionService.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.Permission
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 14:21
* Description
*/
public
interface
PermissionService
{
List
<
Permission
>
getPermissionList
();
}
license/src/main/java/iot/sixiang/license/service/SysOperLogService.java
View file @
e1a9b743
...
@@ -18,5 +18,5 @@ import java.util.Date;
...
@@ -18,5 +18,5 @@ import java.util.Date;
public
interface
SysOperLogService
extends
IService
<
SysOperLog
>
{
public
interface
SysOperLogService
extends
IService
<
SysOperLog
>
{
boolean
addOperlog
(
String
title
,
Integer
businessType
,
String
uri
,
Integer
status
,
String
optParam
,
String
errorMsg
,
Date
operTime
);
boolean
addOperlog
(
String
title
,
Integer
businessType
,
String
uri
,
Integer
status
,
String
optParam
,
String
errorMsg
,
Date
operTime
);
PageInfoModel
<
SysOperLogVo
>
getOperLogList
(
int
pageNo
,
int
pageSize
);
PageInfoModel
<
SysOperLogVo
>
getOperLogList
(
int
pageNo
,
int
pageSize
,
String
startTime
,
String
endTime
);
}
}
license/src/main/java/iot/sixiang/license/service/UserPermissionService.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.UserPermission
;
import
iot.sixiang.license.model.dto.AssignUserPermissionDTO
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 14:21
* Description
*/
public
interface
UserPermissionService
{
List
<
UserPermission
>
getPermissionById
(
int
userId
);
boolean
saveBatch
(
AssignUserPermissionDTO
assignUserPermissionDTO
);
void
deleteUserPermission
(
int
parseInt
);
}
license/src/main/java/iot/sixiang/license/service/UserService.java
View file @
e1a9b743
...
@@ -20,7 +20,7 @@ public interface UserService {
...
@@ -20,7 +20,7 @@ public interface UserService {
boolean
updateUser
(
User
user
);
boolean
updateUser
(
User
user
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
int
userId
);
User
getUserById
(
int
userId
);
User
getUserById
(
int
userId
);
...
...
license/src/main/java/iot/sixiang/license/service/impl/PermissionServiceImpl.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.mapper.PermissionMapper
;
import
iot.sixiang.license.service.PermissionService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 14:21
* Description
*/
@Service
public
class
PermissionServiceImpl
implements
PermissionService
{
@Resource
PermissionMapper
permissionMapper
;
@Override
public
List
<
Permission
>
getPermissionList
()
{
return
permissionMapper
.
selectList
(
null
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/SysOperLogServiceImpl.java
View file @
e1a9b743
...
@@ -45,11 +45,11 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
...
@@ -45,11 +45,11 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
}
}
@Override
@Override
public
PageInfoModel
<
SysOperLogVo
>
getOperLogList
(
int
pageNo
,
int
pageSize
)
{
public
PageInfoModel
<
SysOperLogVo
>
getOperLogList
(
int
pageNo
,
int
pageSize
,
String
startTime
,
String
endTime
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
List
<
SysOperLogVo
>
records
=
sysOperLogMapper
.
getOperLogList
();
List
<
SysOperLogVo
>
records
=
sysOperLogMapper
.
getOperLogList
(
startTime
,
endTime
);
List
<
SysOperLogVo
>
result
=
new
ArrayList
<>();
List
<
SysOperLogVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
records
.
size
()
>
0
)
{
if
(
begin
>=
0
&&
records
.
size
()
>
0
)
{
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserPermissionServiceImpl.java
0 → 100644
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.UserPermission
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.PermissionMapper
;
import
iot.sixiang.license.mapper.UserPermissionMapper
;
import
iot.sixiang.license.model.dto.AssignUserPermissionDTO
;
import
iot.sixiang.license.service.PermissionService
;
import
iot.sixiang.license.service.UserPermissionService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/1/31 14:21
* Description
*/
@Service
public
class
UserPermissionServiceImpl
implements
UserPermissionService
{
@Resource
UserPermissionMapper
userPermissionMapper
;
@Override
public
List
<
UserPermission
>
getPermissionById
(
int
userId
)
{
if
(
userId
<=
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
return
userPermissionMapper
.
getPermissionById
(
userId
);
}
@Override
public
boolean
saveBatch
(
AssignUserPermissionDTO
assignUserPermissionDTO
)
{
List
<
Integer
>
userPermissions
=
assignUserPermissionDTO
.
getPermissions
();
Integer
userId
=
assignUserPermissionDTO
.
getUserId
();
if
(
userPermissions
.
isEmpty
()
||
userId
<=
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
return
userPermissionMapper
.
saveBatch
(
userPermissions
,
userId
)
>
0
;
}
@Override
public
void
deleteUserPermission
(
int
parseInt
)
{
userPermissionMapper
.
deleteUserPermission
(
parseInt
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
e1a9b743
package
iot
.
sixiang
.
license
.
service
.
impl
;
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
cn.hutool.core.lang.Validator
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.consts.ResultCode
;
...
@@ -35,11 +36,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -35,11 +36,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
UserMapper
userMapper
;
UserMapper
userMapper
;
@Override
@Override
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
)
{
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
int
userId
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
);
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
,
userId
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
UserVo
>
result
=
new
ArrayList
<>();
List
<
UserVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
@@ -74,14 +75,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -74,14 +75,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
@Override
public
boolean
addUser
(
String
userName
,
String
company
,
String
password
)
{
public
boolean
addUser
(
String
userName
,
String
company
,
String
password
)
{
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
company
)
||
!
CommonUtil
.
regularMessage
(
userName
))
{
String
notify
;
if
(
Validator
.
isEmail
(
userName
))
{
notify
=
userName
;
}
else
{
throw
new
IotLicenseException
(
403
,
"请输入正确的邮箱账号"
);
}
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
company
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
User
res
=
userMapper
.
getUserByUserName
(
userName
);
User
res
=
userMapper
.
getUserByUserName
(
userName
);
if
(
res
!=
null
)
{
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
}
}
return
userMapper
.
addUser
(
userName
,
company
,
password
);
return
userMapper
.
addUser
(
userName
,
company
,
password
,
notify
);
}
}
@Override
@Override
...
...
license/src/main/java/iot/sixiang/license/util/CommonUtil.java
View file @
e1a9b743
...
@@ -11,7 +11,9 @@ import java.io.File;
...
@@ -11,7 +11,9 @@ import java.io.File;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.security.SecureRandom
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -21,6 +23,34 @@ import java.util.regex.Pattern;
...
@@ -21,6 +23,34 @@ import java.util.regex.Pattern;
@Slf4j
@Slf4j
public
class
CommonUtil
{
public
class
CommonUtil
{
/**
* 获取指定日期前或后几天
*
* @return
*/
public
static
String
getDayByNum
(
int
num
,
String
dateStr
)
throws
ParseException
{
//获取指定当前日期的前三天时间
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
date
=
format
.
parse
(
dateStr
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DATE
,
num
);
date
=
calendar
.
getTime
();
return
format
.
format
(
date
);
}
/**
* date 转 字符串
* @param date
* @param pattern
* @return
*/
public
static
String
dateToString
(
Date
date
,
String
pattern
)
{
SimpleDateFormat
ft
=
new
SimpleDateFormat
(
pattern
);
return
ft
.
format
(
date
);
}
/**
/**
* 验证密码-是否包含用户名字符(密码应与用户名无相关性,密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串)
* 验证密码-是否包含用户名字符(密码应与用户名无相关性,密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串)
*/
*/
...
...
license/src/main/resources/mapper/PermissionMapper.xml
0 → 100644
View file @
e1a9b743
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"iot.sixiang.license.mapper.PermissionMapper"
>
</mapper>
\ No newline at end of file
license/src/main/resources/mapper/PmsUseLogMapper.xml
View file @
e1a9b743
...
@@ -4,6 +4,12 @@
...
@@ -4,6 +4,12 @@
<select
id=
"getPmsUseLogList"
resultType=
"iot.sixiang.license.entity.PmsUseLog"
>
<select
id=
"getPmsUseLogList"
resultType=
"iot.sixiang.license.entity.PmsUseLog"
>
SELECT * FROM pms_use_log
SELECT * FROM pms_use_log
where 1=1
where 1=1
<if
test=
"startTime != null and startTime != ''"
>
AND create_time
>
#{startTime}
</if>
<if
test=
"endTime != null and endTime != ''"
>
AND create_time
<
#{endTime}
</if>
<if
test=
"null != sn and '' != sn"
>
<if
test=
"null != sn and '' != sn"
>
and sn like concat('%',#{sn},'%')
and sn like concat('%',#{sn},'%')
</if>
</if>
...
...
license/src/main/resources/mapper/SysOperLogMapper.xml
View file @
e1a9b743
...
@@ -6,6 +6,14 @@
...
@@ -6,6 +6,14 @@
</insert>
</insert>
<select
id=
"getOperLogList"
resultType=
"iot.sixiang.license.model.vo.SysOperLogVo"
>
<select
id=
"getOperLogList"
resultType=
"iot.sixiang.license.model.vo.SysOperLogVo"
>
select id, title, business_type, uri, status, error_msg, oper_time from sys_oper_log order by oper_time desc
select id, title, business_type, uri, status, error_msg, oper_time from sys_oper_log
where 1=1
<if
test=
"startTime != null and startTime != ''"
>
AND oper_time
>
#{startTime}
</if>
<if
test=
"endTime != null and endTime != ''"
>
AND oper_time
<
#{endTime}
</if>
order by oper_time desc
</select>
</select>
</mapper>
</mapper>
license/src/main/resources/mapper/UserMapper.xml
View file @
e1a9b743
...
@@ -25,6 +25,9 @@
...
@@ -25,6 +25,9 @@
LEFT JOIN apply ON user.user_id = apply.user_id
LEFT JOIN apply ON user.user_id = apply.user_id
LEFT JOIN device ON apply.app_id = device.app_id
LEFT JOIN device ON apply.app_id = device.app_id
where 1=1
where 1=1
<if
test=
"userId != null"
>
and (user.user_id = #{userId} or parent = #{userId})
</if>
<if
test=
"null != userName and '' != userName"
>
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
and user_name like concat('%',#{userName},'%')
</if>
</if>
...
@@ -35,11 +38,11 @@
...
@@ -35,11 +38,11 @@
</select>
</select>
<select
id=
"getUserByUserName"
resultType=
"iot.sixiang.license.entity.User"
>
<select
id=
"getUserByUserName"
resultType=
"iot.sixiang.license.entity.User"
>
select * from user where user_name = #{userName}
select * from user where user_name = #{userName}
limit 1
</select>
</select>
<select
id=
"getUserById"
resultType=
"iot.sixiang.license.entity.User"
>
<select
id=
"getUserById"
resultType=
"iot.sixiang.license.entity.User"
>
select * from user where user_id = #{userId}
select * from user where user_id = #{userId}
limit 1
</select>
</select>
</mapper>
</mapper>
license/src/main/resources/mapper/UserPermissionMapper.xml
0 → 100644
View file @
e1a9b743
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"iot.sixiang.license.mapper.UserPermissionMapper"
>
<insert
id=
"saveBatch"
>
insert into user_permission(permission, user, create_time) values
<foreach
collection=
"userPermissions"
separator=
","
item=
"permission"
>
(#{permission}, #{userId}, now())
</foreach>
</insert>
<delete
id=
"deleteUserPermission"
>
delete from user_permission where user = #{userId}
</delete>
<select
id=
"getPermissionById"
resultType=
"iot.sixiang.license.entity.UserPermission"
>
SELECT * FROM `user_permission` WHERE user = #{userId} and deleted = 0
</select>
</mapper>
\ No newline at end of file
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