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
ce877ab0
Commit
ce877ab0
authored
Jan 30, 2023
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改日志模块
parent
04dee544
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
116 additions
and
38 deletions
+116
-38
pom.xml
license/pom.xml
+7
-0
PmsUseLogController.java
...a/iot/sixiang/license/controller/PmsUseLogController.java
+14
-5
SysOperLogController.java
.../iot/sixiang/license/controller/SysOperLogController.java
+22
-8
GlobalExceptionHandler.java
...a/iot/sixiang/license/handler/GlobalExceptionHandler.java
+2
-2
PmsUseLogMapper.java
...main/java/iot/sixiang/license/mapper/PmsUseLogMapper.java
+1
-1
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
PmsUseService.java
.../main/java/iot/sixiang/license/service/PmsUseService.java
+1
-1
SysOperLogService.java
...n/java/iot/sixiang/license/service/SysOperLogService.java
+1
-1
PmsUseServiceImpl.java
...a/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
+2
-2
SysOperLogServiceImpl.java
...t/sixiang/license/service/impl/SysOperLogServiceImpl.java
+4
-4
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+7
-2
CommonUtil.java
...se/src/main/java/iot/sixiang/license/util/CommonUtil.java
+30
-1
PmsUseLogMapper.xml
license/src/main/resources/mapper/PmsUseLogMapper.xml
+6
-0
SysOperLogMapper.xml
license/src/main/resources/mapper/SysOperLogMapper.xml
+7
-0
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+10
-9
No files found.
license/pom.xml
View file @
ce877ab0
...
...
@@ -106,6 +106,13 @@
<artifactId>
log
</artifactId>
<version>
${acc.log.version}
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.7.22
</version>
</dependency>
</dependencies>
<repositories>
...
...
license/src/main/java/iot/sixiang/license/controller/PmsUseLogController.java
View file @
ce877ab0
...
...
@@ -5,21 +5,21 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.entity.PmsUseLog
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.PmsUseService
;
import
iot.sixiang.license.
service.SysOperLogService
;
import
iot.sixiang.license.
util.CommonUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -45,14 +45,23 @@ public class PmsUseLogController {
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
),
@ApiImplicitParam
(
name
=
"sn"
,
value
=
"设备编号"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态 1:成功,0:失败"
,
dataType
=
"int"
)
})
public
PageResult
<
PmsUseLog
>
getPmsUseLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
,
@RequestParam
(
value
=
"sn"
,
required
=
false
)
String
sn
,
@RequestParam
(
value
=
"status"
,
required
=
false
)
Integer
status
)
{
PageInfoModel
<
PmsUseLog
>
records
=
pmsUseService
.
getPmsUseLogList
(
pageNo
,
pageSize
,
sn
,
status
);
@RequestParam
(
value
=
"status"
,
required
=
false
)
Integer
status
)
throws
ParseException
{
if
(
StringUtils
.
isEmpty
(
endTime
))
{
endTime
=
CommonUtil
.
getDayByNum
(
1
,
CommonUtil
.
dateToString
(
new
Date
(),
"yyyy-MM-dd"
));
}
else
{
endTime
=
CommonUtil
.
getDayByNum
(
1
,
endTime
);
}
PageInfoModel
<
PmsUseLog
>
records
=
pmsUseService
.
getPmsUseLogList
(
pageNo
,
pageSize
,
sn
,
status
,
startTime
,
endTime
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
...
...
license/src/main/java/iot/sixiang/license/controller/SysOperLogController.java
View file @
ce877ab0
...
...
@@ -10,12 +10,16 @@ import iot.sixiang.license.log.MyLog;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -31,6 +35,7 @@ public class SysOperLogController {
/**
* 分页查询所有的oper_log
*
* @param pageNo
* @param pageSize
* @return
...
...
@@ -39,17 +44,26 @@ public class SysOperLogController {
@GetMapping
(
"operate/list"
)
@MyLog
(
title
=
"获取日志列表"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
)
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
)
})
public
PageResult
<
SysOperLog
>
getOperLogList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
PageInfoModel
<
SysOperLog
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
);
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
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
<
SysOperLog
>
records
=
sysOperLogService
.
getOperLogList
(
pageNo
,
pageSize
,
startTime
,
endTime
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
}
List
<
SysOperLog
>
result
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
...
...
license/src/main/java/iot/sixiang/license/handler/GlobalExceptionHandler.java
View file @
ce877ab0
...
...
@@ -17,7 +17,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
@ResponseBody
//为了返回数据
public
BaseResult
error
(
Exception
e
){
log
.
error
(
"出现自定义异常,{}"
+
e
.
getMessage
());
log
.
error
(
"出现自定义异常,{}"
,
e
.
getMessage
());
return
BaseResult
.
serverException
();
}
...
...
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
IotLicenseException
.
class
)
@ResponseBody
//为了返回数据
public
BaseResult
error
(
IotLicenseException
e
){
log
.
error
(
"出现自定义异常,{}"
+
e
.
getMsg
());
log
.
error
(
"出现自定义异常,{}"
,
e
.
getMsg
());
return
BaseResult
.
failed
().
msg
(
e
.
getMsg
()).
code
(
e
.
getCode
());
}
}
license/src/main/java/iot/sixiang/license/mapper/PmsUseLogMapper.java
View file @
ce877ab0
...
...
@@ -12,5 +12,5 @@ import java.util.List;
* Description
*/
public
interface
PmsUseLogMapper
extends
BaseMapper
<
PmsUseLog
>
{
List
<
PmsUseLog
>
getPmsUseLogList
(
String
sn
,
Integer
status
);
List
<
PmsUseLog
>
getPmsUseLogList
(
String
sn
,
Integer
status
,
String
startTime
,
String
endTime
);
}
license/src/main/java/iot/sixiang/license/mapper/SysOperLogMapper.java
View file @
ce877ab0
...
...
@@ -18,5 +18,5 @@ public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
boolean
addOperlog
(
String
title
,
Integer
businessType
,
String
uri
,
Integer
status
,
String
optParam
,
String
errorMsg
,
Date
operTime
);
List
<
SysOperLog
>
getOperLogList
();
List
<
SysOperLog
>
getOperLogList
(
String
startTime
,
String
endTime
);
}
license/src/main/java/iot/sixiang/license/mapper/UserMapper.java
View file @
ce877ab0
...
...
@@ -19,7 +19,7 @@ public interface UserMapper extends BaseMapper<User> {
boolean
deleteUser
(
int
user
);
boolean
addUser
(
String
userName
,
String
company
,
String
password
);
boolean
addUser
(
String
userName
,
String
company
,
String
password
,
String
notify
);
boolean
updateUser
(
int
userId
,
String
password
);
...
...
license/src/main/java/iot/sixiang/license/service/PmsUseService.java
View file @
ce877ab0
...
...
@@ -16,7 +16,7 @@ public interface PmsUseService {
void
success
(
int
useLogId
);
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
);
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
,
String
startTime
,
String
endTime
);
boolean
reportErrorMsg
(
ReportErrorMsgDTO
reportErrorMsgDTO
);
...
...
license/src/main/java/iot/sixiang/license/service/SysOperLogService.java
View file @
ce877ab0
...
...
@@ -17,5 +17,5 @@ import java.util.Date;
public
interface
SysOperLogService
extends
IService
<
SysOperLog
>
{
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
>
getOperLogList
(
int
pageNo
,
int
pageSize
,
String
startTime
,
String
endTime
);
}
license/src/main/java/iot/sixiang/license/service/impl/PmsUseServiceImpl.java
View file @
ce877ab0
...
...
@@ -49,11 +49,11 @@ public class PmsUseServiceImpl implements PmsUseService {
}
@Override
public
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
)
{
public
PageInfoModel
<
PmsUseLog
>
getPmsUseLogList
(
int
pageNo
,
int
pageSize
,
String
sn
,
Integer
status
,
String
startTime
,
String
endTime
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
PmsUseLog
>
pmsUseLogs
=
pmsUseLogMapper
.
getPmsUseLogList
(
sn
,
status
);
List
<
PmsUseLog
>
pmsUseLogs
=
pmsUseLogMapper
.
getPmsUseLogList
(
sn
,
status
,
startTime
,
endTime
);
List
<
PmsUseLog
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
pmsUseLogs
.
size
()
>
0
)
{
...
...
license/src/main/java/iot/sixiang/license/service/impl/SysOperLogServiceImpl.java
View file @
ce877ab0
...
...
@@ -37,11 +37,11 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
}
@Override
public
PageInfoModel
<
SysOperLog
>
getOperLogList
(
int
pageNo
,
int
pageSize
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
public
PageInfoModel
<
SysOperLog
>
getOperLogList
(
int
pageNo
,
int
pageSize
,
String
startTime
,
String
endTime
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
SysOperLog
>
records
=
sysOperLogMapper
.
getOperLogList
();
List
<
SysOperLog
>
records
=
sysOperLogMapper
.
getOperLogList
(
startTime
,
endTime
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
SysOperLog:
:
getOperTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
SysOperLog
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
ce877ab0
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
cn.hutool.core.lang.Validator
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.User
;
...
...
@@ -61,14 +62,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public
boolean
addUser
(
String
userName
,
String
company
,
String
password
)
{
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
company
)
||
!
CommonUtil
.
regularMessage
(
userName
))
{
String
notify
=
null
;
if
(
Validator
.
isEmail
(
userName
))
{
notify
=
userName
;
}
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
company
)
||
(
notify
==
null
&&
!
CommonUtil
.
regularMessage
(
userName
)))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
User
res
=
userMapper
.
getUserByUserName
(
userName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
}
return
userMapper
.
addUser
(
userName
,
company
,
password
);
return
userMapper
.
addUser
(
userName
,
company
,
password
,
notify
);
}
@Override
...
...
license/src/main/java/iot/sixiang/license/util/CommonUtil.java
View file @
ce877ab0
...
...
@@ -8,12 +8,41 @@ import java.io.File;
import
java.io.UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
@Slf4j
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
);
}
/**
* 随机生成指定长度的字符串
*
...
...
@@ -55,7 +84,7 @@ public class CommonUtil {
public
static
boolean
regularMessage
(
String
message
)
{
String
regex
=
"^[0-9a-zA-Z
_
]{1,}$"
;
String
regex
=
"^[0-9a-zA-Z]{1,}$"
;
return
message
.
matches
(
regex
);
}
...
...
license/src/main/resources/mapper/PmsUseLogMapper.xml
View file @
ce877ab0
...
...
@@ -10,6 +10,12 @@
<if
test=
"null != status"
>
and status = #{status}
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND create_time
>
#{startTime}
</if>
<if
test=
"endTime != null and endTime != ''"
>
AND create_time
<
#{endTime}
</if>
and deleted = 0
order by create_time desc
</select>
...
...
license/src/main/resources/mapper/SysOperLogMapper.xml
View file @
ce877ab0
...
...
@@ -7,5 +7,12 @@
<select
id=
"getOperLogList"
resultType=
"iot.sixiang.license.entity.SysOperLog"
>
select id, title, business_type, uri, status, opt_param, 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>
</select>
</mapper>
license/src/main/resources/mapper/UserMapper.xml
View file @
ce877ab0
...
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"iot.sixiang.license.mapper.UserMapper"
>
<insert
id=
"addUser"
parameterType=
"iot.sixiang.license.entity.User"
>
insert into user(user_name, company, password,
create_time, update_time) values (#{userName},#{company}, #{password
}, now(), now())
insert into user(user_name, company, password,
notify, create_time, update_time) values (#{userName},#{company}, #{password}, #{notify, jdbcType=VARCHAR
}, now(), now())
</insert>
<delete
id=
"deleteUser"
parameterType=
"iot.sixiang.license.entity.User"
>
...
...
@@ -17,7 +17,8 @@
<select
id=
"getUserList"
resultType=
"iot.sixiang.license.model.vo.UserVo"
>
SELECT user.user_id, user_name, password, company, user.create_time, user.update_time,
COUNT(device.`device_id`) totalDevice,
COUNT(if(device.device_id is NOT NULL, if (device.`status` = 0 or device.`status` is NULL, 1, NULL), NULL)) unUseDevice,
COUNT(if(device.device_id is NOT NULL, if (device.`status` = 0 or device.`status` is NULL, 1, NULL), NULL))
unUseDevice,
COUNT(if(device.device_id is NOT NULL and device.`status` = 1, 1, NULL)) inUseDevice,
COUNT(if(device.device_id is NOT NULL and device.`status` = 2, 1, NULL)) failedDevice
FROM USER
...
...
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