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
99aa7bce
Commit
99aa7bce
authored
Feb 02, 2023
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
b6b9cabd
45537ae0
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
245 additions
and
17 deletions
+245
-17
ReportController.java
...java/iot/sixiang/license/controller/ReportController.java
+16
-2
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+11
-5
ReportMapper.java
...rc/main/java/iot/sixiang/license/mapper/ReportMapper.java
+4
-0
UserMapper.java
.../src/main/java/iot/sixiang/license/mapper/UserMapper.java
+4
-1
ReportDTO.java
...rc/main/java/iot/sixiang/license/model/dto/ReportDTO.java
+32
-0
ReportVO.java
.../src/main/java/iot/sixiang/license/model/vo/ReportVO.java
+16
-0
UserChildIdVO.java
...main/java/iot/sixiang/license/model/vo/UserChildIdVO.java
+21
-0
ReportService.java
.../main/java/iot/sixiang/license/service/ReportService.java
+4
-3
UserService.java
...rc/main/java/iot/sixiang/license/service/UserService.java
+6
-1
ReportServiceImpl.java
...a/iot/sixiang/license/service/impl/ReportServiceImpl.java
+42
-0
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+8
-3
TreeUtil.java
license/src/main/java/iot/sixiang/license/util/TreeUtil.java
+36
-0
ReportMapper.xml
license/src/main/resources/mapper/ReportMapper.xml
+36
-0
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+9
-2
No files found.
license/src/main/java/iot/sixiang/license/controller/ReportController.java
View file @
99aa7bce
...
...
@@ -5,7 +5,11 @@ import io.swagger.annotations.ApiOperation;
import
iot.sixiang.license.entity.ReportType
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.service.ReportTypeService
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -26,17 +30,27 @@ public class ReportController {
@Resource
ReportTypeService
reportTypeService
;
@Resource
ReportService
reportService
;
/**
* 查询所有报警类型
*
* @return
*/
@ApiOperation
(
value
=
"获取报警类型
列表接口"
,
notes
=
"用于获取报警类型列表
"
)
@ApiOperation
(
value
=
"获取报警类型
接口"
,
notes
=
"用于获取报警类型
"
)
@GetMapping
(
"report_type/list"
)
@MyLog
(
title
=
"获取报警类型
列表
"
,
businessType
=
BusinessType
.
SELECT
)
@MyLog
(
title
=
"获取报警类型"
,
businessType
=
BusinessType
.
SELECT
)
public
ResResult
getReportTypeList
()
{
List
<
ReportType
>
reportTypes
=
reportTypeService
.
getReportTypeList
();
return
ResResult
.
success
().
goRecord
(
reportTypes
);
}
@ApiOperation
(
value
=
"获取报警列表接口"
,
notes
=
"用于获取报警列表"
)
@GetMapping
(
"list"
)
@MyLog
(
title
=
"获取报警列表"
,
optParam
=
"#{reportDTO.pageNo},#{reportDTO.pageSize},#{reportDTO.type},#{reportDTO.sn},#{reportDTO.startTime},#{reportDTO.endTime}"
,
businessType
=
BusinessType
.
SELECT
)
public
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
)
{
return
reportService
.
getReportList
(
reportDTO
);
}
}
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
99aa7bce
...
...
@@ -32,6 +32,7 @@ import iot.sixiang.license.service.UserPermissionService;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.TreeUtil
;
import
iot.sixiang.license.xss.XssUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -41,6 +42,7 @@ import org.springframework.web.bind.WebDataBinder;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -267,13 +269,17 @@ public class UserController {
userName
=
XssUtil
.
checkXSS
(
userName
);
company
=
XssUtil
.
checkXSS
(
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
;
if
(
StringUtils
.
isEmpty
(
userId
))
{
throw
new
IotLicenseException
(
403
,
"请重新登录"
);
}
List
<
Integer
>
userIds
=
new
ArrayList
<>();
List
<
Integer
>
userChildIds
=
TreeUtil
.
getUserChildIds
(
Integer
.
parseInt
(
userId
),
userIds
);
userChildIds
.
add
(
Integer
.
parseInt
(
userId
));
PageInfoModel
<
UserVo
>
records
=
userService
.
getUserList
(
pageNo
,
pageSize
,
userName
,
company
,
userChildIds
);
int
total
=
records
.
getTotal
();
if
(
total
<=
0
)
{
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
0
,
0
,
null
);
}
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
...
...
license/src/main/java/iot/sixiang/license/mapper/ReportMapper.java
View file @
99aa7bce
...
...
@@ -2,6 +2,9 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
java.util.List
;
/**
* Created by m33
...
...
@@ -9,4 +12,5 @@ import iot.sixiang.license.entity.Report;
* Description
*/
public
interface
ReportMapper
extends
BaseMapper
<
Report
>
{
List
<
ReportVO
>
getReportList
(
Integer
type
,
String
sn
,
String
startTime
,
String
endTime
,
List
<
Integer
>
userChildIds
);
}
license/src/main/java/iot/sixiang/license/mapper/UserMapper.java
View file @
99aa7bce
...
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.model.vo.UserChildIdVO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
java.util.List
;
...
...
@@ -23,9 +24,11 @@ public interface UserMapper extends BaseMapper<User> {
boolean
updateUser
(
int
userId
,
String
password
);
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
,
int
userId
);
List
<
UserVo
>
getUserList
(
String
userName
,
String
company
,
List
<
Integer
>
userIds
);
User
getUserByUserName
(
String
userName
);
User
getUserById
(
int
userId
);
List
<
UserChildIdVO
>
getChildUser
(
int
userId
);
}
license/src/main/java/iot/sixiang/license/model/dto/ReportDTO.java
0 → 100644
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2023/2/1 13:57
* Description
*/
@Data
public
class
ReportDTO
{
@ApiModelProperty
(
"当前页"
)
private
Integer
pageNo
;
@ApiModelProperty
(
"每页条数"
)
private
Integer
pageSize
;
@ApiModelProperty
(
"报警事件类型"
)
private
Integer
type
;
@ApiModelProperty
(
"设备编码"
)
private
String
sn
;
@ApiModelProperty
(
"开始时间"
)
private
String
startTime
;
@ApiModelProperty
(
"结束时间"
)
private
String
endTime
;
}
license/src/main/java/iot/sixiang/license/model/vo/ReportVO.java
0 → 100644
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
iot.sixiang.license.entity.Report
;
import
lombok.Data
;
/**
* Created by m33
* Date 2023/2/1 14:06
* Description
*/
@Data
public
class
ReportVO
extends
Report
{
@ApiModelProperty
(
"报警事件"
)
private
String
reportTypeStr
;
}
license/src/main/java/iot/sixiang/license/model/vo/UserChildIdVO.java
0 → 100644
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2023/2/1 14:52
* Description
*/
@Data
public
class
UserChildIdVO
{
@ApiModelProperty
(
"用户Id"
)
private
Integer
userId
;
@ApiModelProperty
(
"父Id"
)
private
Integer
parent
;
@ApiModelProperty
(
"账号级别"
)
private
Integer
level
;
}
license/src/main/java/iot/sixiang/license/service/ReportService.java
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.
entity.ReportType
;
import
java.util.List
;
import
iot.sixiang.license.
model.PageResult
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.vo.ReportVO
;
/**
* Created by M=54G
...
...
@@ -11,4 +11,5 @@ import java.util.List;
*/
public
interface
ReportService
{
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
);
}
license/src/main/java/iot/sixiang/license/service/UserService.java
View file @
99aa7bce
...
...
@@ -4,8 +4,11 @@ import iot.sixiang.license.entity.User;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.UserChildIdVO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
java.util.List
;
/**
* <p>
* 服务类
...
...
@@ -22,11 +25,13 @@ public interface UserService {
boolean
updateUser
(
User
user
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
int
userId
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
List
<
Integer
>
userIds
);
User
getUserById
(
int
userId
);
User
getUserByName
(
String
root
);
BaseResult
updateNotify
(
UpdateNotifyDTO
updateNotifyDTO
);
List
<
UserChildIdVO
>
getChildUser
(
int
userId
);
}
license/src/main/java/iot/sixiang/license/service/impl/ReportServiceImpl.java
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.mapper.ReportMapper
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.util.TreeUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* Created by m33
...
...
@@ -16,4 +26,36 @@ public class ReportServiceImpl implements ReportService {
@Resource
ReportMapper
reportMapper
;
@Override
public
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
)
{
int
pageNo
=
reportDTO
.
getPageNo
();
int
pageSize
=
reportDTO
.
getPageSize
();
Integer
type
=
reportDTO
.
getType
();
String
sn
=
reportDTO
.
getSn
();
String
startTime
=
reportDTO
.
getStartTime
();
String
endTime
=
reportDTO
.
getEndTime
();
String
userId
=
UserUtils
.
getLoginUserId
();
if
(
StringUtils
.
isEmpty
(
userId
))
{
throw
new
IotLicenseException
(
403
,
"请重新登录"
);
}
List
<
Integer
>
userIds
=
new
ArrayList
<>();
List
<
Integer
>
userChildIds
=
TreeUtil
.
getUserChildIds
(
Integer
.
parseInt
(
userId
),
userIds
);
userChildIds
.
add
(
Integer
.
parseInt
(
userId
));
List
<
ReportVO
>
reportList
=
reportMapper
.
getReportList
(
type
,
sn
,
startTime
,
endTime
,
userChildIds
);
int
total
=
reportList
.
size
();
List
<
ReportVO
>
result
;
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
total
>
0
)
{
result
=
reportList
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
else
{
return
new
PageResult
<>(
200
,
"查找成功"
,
pageNo
,
0
,
0
,
null
);
}
// pages为总页数
int
pages
=
total
/
pageSize
;
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
}
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
99aa7bce
...
...
@@ -12,9 +12,9 @@ import iot.sixiang.license.mapper.UserMapper;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.UserChildIdVO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -40,11 +40,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
UserMapper
userMapper
;
@Override
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
int
userId
)
{
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
,
List
<
Integer
>
userIds
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
,
userId
);
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
,
userId
s
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
UserVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
...
@@ -124,4 +124,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
}
@Override
public
List
<
UserChildIdVO
>
getChildUser
(
int
userId
)
{
return
userMapper
.
getChildUser
(
userId
);
}
}
license/src/main/java/iot/sixiang/license/util/TreeUtil.java
0 → 100644
View file @
99aa7bce
package
iot
.
sixiang
.
license
.
util
;
import
iot.sixiang.license.model.vo.UserChildIdVO
;
import
iot.sixiang.license.service.UserService
;
import
java.util.List
;
/**
* Created by m33
* Date 2023/2/1 14:49
* Description
*/
public
class
TreeUtil
{
/**
* 获取所有子账号userId
*
* @param userId
* @param res
* @return
*/
public
static
List
<
Integer
>
getUserChildIds
(
int
userId
,
List
<
Integer
>
res
)
{
UserService
userService
=
SpringUtil
.
getBean
(
UserService
.
class
);
List
<
UserChildIdVO
>
userChildIdVOS
=
userService
.
getChildUser
(
userId
);
if
(
userChildIdVOS
.
isEmpty
())
{
return
res
;
}
for
(
UserChildIdVO
userChildIdVO
:
userChildIdVOS
)
{
if
(
userChildIdVO
.
getLevel
()
<
3
)
{
getUserChildIds
(
userChildIdVO
.
getUserId
(),
res
);
}
res
.
add
(
userChildIdVO
.
getUserId
());
}
return
res
;
}
}
license/src/main/resources/mapper/ReportMapper.xml
0 → 100644
View file @
99aa7bce
<?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.ReportMapper"
>
<select
id=
"getReportList"
resultType=
"iot.sixiang.license.model.vo.ReportVO"
>
SELECT
report.*,
report_type.description
FROM
`report`
LEFT JOIN `user` ON user.user_name = report.user_name
LEFT JOIN report_type ON report.type = report_type.id
where 1=1
<if
test=
"userChildIds != null"
>
AND user.user_id IN
<foreach
collection=
"userChildIds"
open=
"("
separator=
","
close=
")"
item=
"userId"
>
#{userId}
</foreach>
</if>
<if
test=
"null != type"
>
AND report.type = #{type}
</if>
<if
test=
"null != sn and '' != sn"
>
AND report.sn like concat('%',#{sn},'%')
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND report.create_time
>
#{startTime}
</if>
<if
test=
"endTime != null and endTime != ''"
>
AND report.create_time
<
#{endTime}
</if>
AND report.deleted = 0
AND report_type.deleted = 0
ORDER BY report.create_time DESC
</select>
</mapper>
license/src/main/resources/mapper/UserMapper.xml
View file @
99aa7bce
...
...
@@ -25,8 +25,11 @@
LEFT JOIN apply ON user.user_id = apply.user_id
LEFT JOIN device ON apply.app_id = device.app_id
where 1=1
<if
test=
"userId != null"
>
and (user.user_id = #{userId} or parent = #{userId})
<if
test=
"userIds != null"
>
and user.user_id in
<foreach
collection=
"userIds"
open=
"("
separator=
","
close=
")"
item=
"userId"
>
#{userId}
</foreach>
</if>
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
...
...
@@ -45,4 +48,8 @@
select * from user where user_id = #{userId} limit 1
</select>
<select
id=
"getChildUser"
resultType=
"iot.sixiang.license.model.vo.UserChildIdVO"
>
select user_id, parent, `level` from `user` where parent = #{userId}
</select>
</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