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
7d1140be
Commit
7d1140be
authored
Sep 07, 2022
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加修改密码接口、完善操作日志接口
parent
0d1e7daa
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
186 additions
and
78 deletions
+186
-78
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+39
-34
SysOperLogController.java
.../iot/sixiang/license/controller/SysOperLogController.java
+5
-5
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+52
-19
SysOperLog.java
.../src/main/java/iot/sixiang/license/entity/SysOperLog.java
+1
-3
SysOperLogMapper.java
...ain/java/iot/sixiang/license/mapper/SysOperLogMapper.java
+2
-1
UserMapper.java
.../src/main/java/iot/sixiang/license/mapper/UserMapper.java
+2
-0
LoginVo.java
...e/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
+5
-0
SysOperLogVo.java
.../main/java/iot/sixiang/license/model/vo/SysOperLogVo.java
+37
-0
UserUpdatePwdVo.java
...in/java/iot/sixiang/license/model/vo/UserUpdatePwdVo.java
+18
-0
SysOperLogService.java
...n/java/iot/sixiang/license/service/SysOperLogService.java
+2
-1
UserService.java
...rc/main/java/iot/sixiang/license/service/UserService.java
+4
-1
SysOperLogServiceImpl.java
...t/sixiang/license/service/impl/SysOperLogServiceImpl.java
+5
-6
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+7
-5
SysOperLogMapper.xml
license/src/main/resources/mapper/SysOperLogMapper.xml
+2
-2
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+5
-1
No files found.
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
7d1140be
...
@@ -4,11 +4,13 @@ import io.swagger.annotations.Api;
...
@@ -4,11 +4,13 @@ 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.User
;
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
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.vo.LoginVo
;
import
iot.sixiang.license.model.vo.LoginVo
;
...
@@ -37,18 +39,15 @@ public class LoginController {
...
@@ -37,18 +39,15 @@ public class LoginController {
@Resource
@Resource
EmailUtils
emailUtils
;
EmailUtils
emailUtils
;
@Resource
UserMapper
userMapper
;
@Value
(
"${spring.mail.to}"
)
@Value
(
"${spring.mail.to}"
)
private
String
account
;
private
String
account
;
@Value
(
"${other.md5.salt}"
)
private
String
salt
;
//模拟数据库
private
static
final
String
USER_NAME
=
"root"
;
static
Map
<
String
,
LoginUser
>
userMap
=
new
HashMap
<>();
static
{
LoginUser
user1
=
new
LoginUser
(
"2147483647"
,
"root"
,
"123456"
);
userMap
.
put
(
"2147483647"
,
user1
);
}
/**
/**
* 模拟用户登录
* 模拟用户登录
*/
*/
...
@@ -64,33 +63,34 @@ public class LoginController {
...
@@ -64,33 +63,34 @@ public class LoginController {
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
code
))
{
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
code
))
{
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
}
}
for
(
LoginUser
dbUser
:
userMap
.
values
())
{
User
user
=
userMapper
.
getUserByUserName
(
USER_NAME
);
String
name
=
dbUser
.
getUserName
();
String
name
=
USER_NAME
;
String
psw
=
name
+
dbUser
.
getPassword
();
String
psw
=
user
.
getPassword
();
if
(
DigestUtils
.
md5DigestAsHex
(
name
.
getBytes
()).
equals
(
userName
)
&&
DigestUtils
.
md5DigestAsHex
(
psw
.
getBytes
()).
equals
(
password
))
{
LoginUser
dbUser
=
new
LoginUser
(
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
user
.
getPassword
());
// 登录错误次数
if
(
DigestUtils
.
md5DigestAsHex
((
salt
+
name
+
salt
).
getBytes
()).
equals
(
userName
)
&&
psw
.
equals
(
password
))
{
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
// 登录错误次数
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
Date
curDate
=
new
Date
();
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
if
(
errCnt
!=
null
&&
errCnt
>=
3
&&
countFreezeDate
!=
null
&&
curDate
.
before
(
countFreezeDate
))
{
Date
curDate
=
new
Date
();
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
if
(
errCnt
!=
null
&&
errCnt
>=
3
&&
countFreezeDate
!=
null
&&
curDate
.
before
(
countFreezeDate
))
{
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
}
else
{
Date
curCodeDate
=
new
Date
();
if
(
code
.
equals
(
UserUtils
.
getEmailCode
(
account
))
&&
curCodeDate
.
before
(
UserUtils
.
getEmailCodeExpTime
(
account
)))
{
String
token
=
JwtUtil
.
createToken
(
dbUser
);
LoginVo
loginVo
=
new
LoginVo
();
loginVo
.
setAuthorization
(
token
);
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
removeErrCnt
(
userName
);
UserUtils
.
removeCountFreezeDate
(
userName
);
UserUtils
.
removeEmailCode
(
account
);
UserUtils
.
removeEmailCodeExpTime
(
account
);
log
.
info
(
"登录成功!生成token!"
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
}
else
{
}
else
{
Date
curCodeDate
=
new
Date
();
return
ResResult
.
failed
().
setMsgValue
(
"验证码错误或已过期"
);
if
(
code
.
equals
(
UserUtils
.
getEmailCode
(
account
))
&&
curCodeDate
.
before
(
UserUtils
.
getEmailCodeExpTime
(
account
)))
{
String
token
=
JwtUtil
.
createToken
(
dbUser
);
LoginVo
loginVo
=
new
LoginVo
();
loginVo
.
setAuthorization
(
token
);
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
removeErrCnt
(
userName
);
UserUtils
.
removeCountFreezeDate
(
userName
);
UserUtils
.
removeEmailCode
(
account
);
UserUtils
.
removeEmailCodeExpTime
(
account
);
log
.
info
(
"登录成功!生成token!"
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
}
else
{
return
ResResult
.
failed
().
setMsgValue
(
"验证码错误或已过期"
);
}
}
}
}
}
}
}
...
@@ -119,6 +119,11 @@ public class LoginController {
...
@@ -119,6 +119,11 @@ public class LoginController {
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误"
);
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误"
);
}
}
//public static void main(String[] args) {
// System.out.println(DigestUtils.md5DigestAsHex("PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX123456PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX".getBytes()));
// System.out.println(DigestUtils.md5DigestAsHex("PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SXrootPI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX".getBytes()));
//}
@ApiOperation
(
value
=
"注销接口"
,
notes
=
"注销接口"
)
@ApiOperation
(
value
=
"注销接口"
,
notes
=
"注销接口"
)
@GetMapping
(
"logout"
)
@GetMapping
(
"logout"
)
@MyLog
(
title
=
"注销"
,
businessType
=
BusinessType
.
OTHER
)
@MyLog
(
title
=
"注销"
,
businessType
=
BusinessType
.
OTHER
)
...
...
license/src/main/java/iot/sixiang/license/controller/SysOperLogController.java
View file @
7d1140be
...
@@ -4,11 +4,11 @@ import io.swagger.annotations.Api;
...
@@ -4,11 +4,11 @@ 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.SysOperLog
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.log.MyLog
;
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.vo.SysOperLogVo
;
import
iot.sixiang.license.service.SysOperLogService
;
import
iot.sixiang.license.service.SysOperLogService
;
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
;
...
@@ -42,16 +42,16 @@ public class SysOperLogController {
...
@@ -42,16 +42,16 @@ public class SysOperLogController {
@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"
)
})
})
public
PageResult
<
SysOperLog
>
getOperLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
public
PageResult
<
SysOperLog
Vo
>
getOperLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
PageInfoModel
<
SysOperLog
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
);
PageInfoModel
<
SysOperLog
Vo
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
);
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
<
SysOperLog
>
result
=
records
.
getResult
();
List
<
SysOperLog
Vo
>
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 @
7d1140be
...
@@ -9,16 +9,21 @@ import io.swagger.annotations.Api;
...
@@ -9,16 +9,21 @@ 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.User
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
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.vo.UserUpdatePwdVo
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
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
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.DigestUtils
;
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.*
;
...
@@ -40,6 +45,8 @@ public class UserController {
...
@@ -40,6 +45,8 @@ public class UserController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@Value
(
"${other.md5.salt}"
)
private
String
salt
;
@InitBinder
@InitBinder
public
void
initBinder
(
WebDataBinder
binder
)
{
public
void
initBinder
(
WebDataBinder
binder
)
{
...
@@ -91,28 +98,54 @@ public class UserController {
...
@@ -91,28 +98,54 @@ public class UserController {
}
}
}
}
/**
///**
* 修改user
// * 修改user
*
// *
* @param jsonObject
// * @param jsonObject
* @return
// * @return
*/
// */
@ApiOperation
(
value
=
"用户修改接口"
,
notes
=
"修改用户"
)
//@ApiOperation(value = "用户修改接口", notes = "修改用户")
@PostMapping
(
"update"
)
//@PostMapping("update")
@MyLog
(
title
=
"修改用户"
,
optParam
=
"#{userId},#{password}"
,
businessType
=
BusinessType
.
UPDATE
)
//@MyLog(title = "修改用户", optParam = "#{userId},#{password}", businessType = BusinessType.UPDATE)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
//@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter
(
name
=
"userId"
,
value
=
"用户Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
// @DynamicParameter(name = "userId", value = "用户Id", required = true, dataTypeClass = Integer.class),
@DynamicParameter
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
// @DynamicParameter(name = "password", value = "密码", required = true, dataTypeClass = String.class)
}))
//}))
public
BaseResult
updateUser
(
@RequestBody
JSONObject
jsonObject
)
{
//public BaseResult updateUser(@RequestBody JSONObject jsonObject) {
int
userId
=
jsonObject
.
getInteger
(
"userId"
);
// int userId = jsonObject.getInteger("userId");
String
password
=
jsonObject
.
getString
(
"password"
);
// String password = jsonObject.getString("password");
boolean
res
=
userService
.
updateUser
(
userId
,
password
);
// boolean res = userService.updateUser(userId, password);
if
(
res
)
{
// if (res) {
return
BaseResult
.
success
();
// return BaseResult.success();
// } else {
// return BaseResult.failed();
// }
//}
@ApiOperation
(
value
=
"用户修改密码"
,
notes
=
"修改密码"
)
@PostMapping
(
"update_pwd"
)
@MyLog
(
title
=
"修改密码"
,
businessType
=
BusinessType
.
UPDATE
)
public
BaseResult
updatePwd
(
@RequestBody
UserUpdatePwdVo
userUpdatePwdVo
)
{
String
oldPassWord
=
userUpdatePwdVo
.
getOldPassWord
();
String
newPassWord
=
userUpdatePwdVo
.
getNewPassWord
();
String
userId
=
UserUtils
.
getLoginUserId
();
User
user
;
if
(!
StringUtils
.
isEmpty
(
userId
))
{
user
=
userService
.
getUserById
(
Integer
.
parseInt
(
userId
));
}
else
{
}
else
{
return
BaseResult
.
failed
();
return
BaseResult
.
failed
();
}
}
if
(
oldPassWord
.
equals
(
user
.
getPassword
()))
{
user
.
setPassword
(
newPassWord
);
boolean
b
=
userService
.
updateUser
(
user
);
if
(
b
)
{
return
BaseResult
.
success
().
setMsgValue
(
"密码修改成功"
);
}
else
{
return
BaseResult
.
failed
().
setMsgValue
(
"密码修改失败"
);
}
}
else
{
return
BaseResult
.
failed
().
setMsgValue
(
"原密码出错"
);
}
}
}
...
...
license/src/main/java/iot/sixiang/license/entity/SysOperLog.java
View file @
7d1140be
...
@@ -35,7 +35,7 @@ public class SysOperLog implements Serializable {
...
@@ -35,7 +35,7 @@ public class SysOperLog implements Serializable {
@ApiModelProperty
(
"参数"
)
@ApiModelProperty
(
"参数"
)
private
String
optParam
;
private
String
optParam
;
@ApiModelProperty
(
"业务类型(0其它 1
新增 2修改 3
删除)"
)
@ApiModelProperty
(
"业务类型(0其它 1
查找 2新增 3修改 4
删除)"
)
private
Integer
businessType
;
private
Integer
businessType
;
@ApiModelProperty
(
"路径名称"
)
@ApiModelProperty
(
"路径名称"
)
...
@@ -49,6 +49,4 @@ public class SysOperLog implements Serializable {
...
@@ -49,6 +49,4 @@ public class SysOperLog implements Serializable {
@ApiModelProperty
(
"操作时间"
)
@ApiModelProperty
(
"操作时间"
)
private
Date
operTime
;
private
Date
operTime
;
}
}
license/src/main/java/iot/sixiang/license/mapper/SysOperLogMapper.java
View file @
7d1140be
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.mapper;
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.model.vo.SysOperLogVo
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -18,5 +19,5 @@ public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
...
@@ -18,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
<
SysOperLog
>
getOperLogList
();
List
<
SysOperLog
Vo
>
getOperLogList
();
}
}
license/src/main/java/iot/sixiang/license/mapper/UserMapper.java
View file @
7d1140be
...
@@ -26,4 +26,6 @@ public interface UserMapper extends BaseMapper<User> {
...
@@ -26,4 +26,6 @@ public interface UserMapper extends BaseMapper<User> {
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
);
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
);
User
getUserByUserName
(
String
userName
);
User
getUserByUserName
(
String
userName
);
User
getUserById
(
int
userId
);
}
}
license/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
View file @
7d1140be
...
@@ -3,6 +3,8 @@ package iot.sixiang.license.model.vo;
...
@@ -3,6 +3,8 @@ package iot.sixiang.license.model.vo;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
/**
/**
* Created by m33 on 2022/6/14 18:51
* Created by m33 on 2022/6/14 18:51
*/
*/
...
@@ -11,4 +13,7 @@ public class LoginVo {
...
@@ -11,4 +13,7 @@ public class LoginVo {
@ApiModelProperty
(
"token"
)
@ApiModelProperty
(
"token"
)
private
String
authorization
;
private
String
authorization
;
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
}
}
license/src/main/java/iot/sixiang/license/model/vo/SysOperLogVo.java
0 → 100644
View file @
7d1140be
package
iot
.
sixiang
.
license
.
model
.
vo
;
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 2022/9/7 14:52
* Description
*/
@Data
public
class
SysOperLogVo
{
@ApiModelProperty
(
"主键Id"
)
private
Integer
id
;
@ApiModelProperty
(
"模块标题"
)
private
String
title
;
@ApiModelProperty
(
"业务类型(0其它 1查找 2新增 3修改 4删除)"
)
private
Integer
businessType
;
@ApiModelProperty
(
"路径名称"
)
private
String
uri
;
@ApiModelProperty
(
"操作状态(0正常 1异常)"
)
private
Integer
status
;
@ApiModelProperty
(
"错误消息"
)
private
String
errorMsg
;
@ApiModelProperty
(
"操作时间"
)
private
Date
operTime
;
}
license/src/main/java/iot/sixiang/license/model/vo/UserUpdatePwdVo.java
0 → 100644
View file @
7d1140be
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2022/9/7 15:06
* Description
*/
@Data
public
class
UserUpdatePwdVo
{
@ApiModelProperty
(
value
=
"旧密码"
)
private
String
oldPassWord
;
@ApiModelProperty
(
value
=
"新密码"
)
private
String
newPassWord
;
}
license/src/main/java/iot/sixiang/license/service/SysOperLogService.java
View file @
7d1140be
...
@@ -3,6 +3,7 @@ package iot.sixiang.license.service;
...
@@ -3,6 +3,7 @@ package iot.sixiang.license.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.SysOperLogVo
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -17,5 +18,5 @@ import java.util.Date;
...
@@ -17,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
<
SysOperLog
>
getOperLogList
(
int
pageNo
,
int
pageSize
);
PageInfoModel
<
SysOperLog
Vo
>
getOperLogList
(
int
pageNo
,
int
pageSize
);
}
}
license/src/main/java/iot/sixiang/license/service/UserService.java
View file @
7d1140be
package
iot
.
sixiang
.
license
.
service
;
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
...
@@ -17,7 +18,9 @@ public interface UserService{
...
@@ -17,7 +18,9 @@ public interface UserService{
boolean
addUser
(
String
userName
,
String
company
,
String
password
);
boolean
addUser
(
String
userName
,
String
company
,
String
password
);
boolean
updateUser
(
int
userId
,
String
password
);
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
);
User
getUserById
(
int
userId
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/SysOperLogServiceImpl.java
View file @
7d1140be
...
@@ -6,13 +6,13 @@ import iot.sixiang.license.entity.SysOperLog;
...
@@ -6,13 +6,13 @@ import iot.sixiang.license.entity.SysOperLog;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.SysOperLogMapper
;
import
iot.sixiang.license.mapper.SysOperLogMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.SysOperLogVo
;
import
iot.sixiang.license.service.SysOperLogService
;
import
iot.sixiang.license.service.SysOperLogService
;
import
iot.sixiang.license.xss.XssUtil
;
import
iot.sixiang.license.xss.XssUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -45,18 +45,17 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
...
@@ -45,18 +45,17 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
}
}
@Override
@Override
public
PageInfoModel
<
SysOperLog
>
getOperLogList
(
int
pageNo
,
int
pageSize
)
{
public
PageInfoModel
<
SysOperLog
Vo
>
getOperLogList
(
int
pageNo
,
int
pageSize
)
{
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
<
SysOperLog
>
records
=
sysOperLogMapper
.
getOperLogList
();
List
<
SysOperLogVo
>
records
=
sysOperLogMapper
.
getOperLogList
();
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
SysOperLog:
:
getOperTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
SysOperLogVo
>
result
=
new
ArrayList
<>();
List
<
SysOperLog
>
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
)
{
result
=
records
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
result
=
records
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
}
PageInfoModel
<
SysOperLog
>
objectPageInfoModel
=
new
PageInfoModel
<>();
PageInfoModel
<
SysOperLog
Vo
>
objectPageInfoModel
=
new
PageInfoModel
<>();
objectPageInfoModel
.
setTotal
(
records
.
size
());
objectPageInfoModel
.
setTotal
(
records
.
size
());
objectPageInfoModel
.
setResult
(
result
);
objectPageInfoModel
.
setResult
(
result
);
return
objectPageInfoModel
;
return
objectPageInfoModel
;
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
7d1140be
...
@@ -51,6 +51,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -51,6 +51,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
return
objectPageInfoModel
;
return
objectPageInfoModel
;
}
}
@Override
public
User
getUserById
(
int
userId
)
{
return
userMapper
.
getUserById
(
userId
);
}
@Override
@Override
public
boolean
deleteUser
(
int
userId
)
{
public
boolean
deleteUser
(
int
userId
)
{
if
(
userId
==
0
)
{
if
(
userId
==
0
)
{
...
@@ -72,10 +77,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -72,10 +77,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
}
@Override
@Override
public
boolean
updateUser
(
int
userId
,
String
password
)
{
public
boolean
updateUser
(
User
user
)
{
if
(
userId
==
0
||
StringUtils
.
isEmpty
(
password
))
{
return
userMapper
.
updateUser
(
user
.
getUserId
(),
user
.
getPassword
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
return
userMapper
.
updateUser
(
userId
,
password
);
}
}
}
}
license/src/main/resources/mapper/SysOperLogMapper.xml
View file @
7d1140be
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
insert into sys_oper_log(title, business_type, uri, status, opt_param, error_msg, oper_time) values (#{title},#{businessType},#{uri},#{status},#{optParam},#{errorMsg},#{operTime})
insert into sys_oper_log(title, business_type, uri, status, opt_param, error_msg, oper_time) values (#{title},#{businessType},#{uri},#{status},#{optParam},#{errorMsg},#{operTime})
</insert>
</insert>
<select
id=
"getOperLogList"
resultType=
"iot.sixiang.license.
entity.SysOperLog
"
>
<select
id=
"getOperLogList"
resultType=
"iot.sixiang.license.
model.vo.SysOperLogVo
"
>
select id, title, business_type, uri, status,
opt_param, error_msg, oper_time from sys_oper_log
select id, title, business_type, uri, status,
error_msg, oper_time from sys_oper_log order by oper_time desc
</select>
</select>
</mapper>
</mapper>
license/src/main/resources/mapper/UserMapper.xml
View file @
7d1140be
...
@@ -27,7 +27,11 @@
...
@@ -27,7 +27,11 @@
</select>
</select>
<select
id=
"getUserByUserName"
resultType=
"iot.sixiang.license.entity.User"
>
<select
id=
"getUserByUserName"
resultType=
"iot.sixiang.license.entity.User"
>
select user_id from user where user_name = #{userName}
select * from user where user_name = #{userName}
</select>
<select
id=
"getUserById"
resultType=
"iot.sixiang.license.entity.User"
>
select * from user where user_id = #{userId}
</select>
</select>
</mapper>
</mapper>
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