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
49684035
Commit
49684035
authored
Nov 24, 2022
by
马33
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善设备列表和用户列表相关接口
parent
3648d524
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
89 additions
and
47 deletions
+89
-47
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+43
-36
DeviceMapper.java
...rc/main/java/iot/sixiang/license/mapper/DeviceMapper.java
+1
-1
DeviceVo.java
.../src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
+3
-0
ResourceVo.java
...rc/main/java/iot/sixiang/license/model/vo/ResourceVo.java
+3
-0
UserVo.java
...se/src/main/java/iot/sixiang/license/model/vo/UserVo.java
+12
-2
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+9
-1
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+1
-1
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+2
-2
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+4
-1
ResourceMapper.xml
license/src/main/resources/mapper/ResourceMapper.xml
+2
-1
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+9
-2
No files found.
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
View file @
49684035
...
...
@@ -24,7 +24,7 @@ import java.util.List;
/**
* <p>
*
前端控制器
* 前端控制器
* </p>
*
* @author m33
...
...
@@ -45,20 +45,21 @@ public class DeviceController {
/**
* 添加device
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"添加设备接口"
,
notes
=
"用于添加设备"
)
@PostMapping
(
"add"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"appId"
,
value
=
"应用Id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"count"
,
value
=
"需要创建的设备数量"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"appId"
,
value
=
"应用Id"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"count"
,
value
=
"需要创建的设备数量"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
}))
@MyLog
(
title
=
"添加设备"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
public
BaseResult
addDevice
(
@RequestBody
JSONObject
jsonObject
)
{
String
appId
=
jsonObject
.
getString
(
"appId"
);
int
count
=
jsonObject
.
getIntValue
(
"count"
);
boolean
res
=
deviceService
.
addDevice
(
appId
,
count
);
int
count
=
jsonObject
.
getIntValue
(
"count"
);
boolean
res
=
deviceService
.
addDevice
(
appId
,
count
);
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
...
...
@@ -68,6 +69,7 @@ public class DeviceController {
/**
* 可按条件分页查询所有的设备
*
* @param pageNo
* @param pageSize
* @param appName
...
...
@@ -76,26 +78,28 @@ public class DeviceController {
*/
@ApiOperation
(
value
=
"获取设备列表接口"
,
notes
=
"用于获取设备列表"
)
@GetMapping
(
"list"
)
@MyLog
(
title
=
"获取设备列表"
,
optParam
=
"#{pageNo},#{pageSize},#{appName},#{userName}"
,
businessType
=
BusinessType
.
SELECT
)
@MyLog
(
title
=
"获取设备列表"
,
optParam
=
"#{pageNo},#{pageSize},#{appName},#{userName}
,#{status}
"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"appName"
,
value
=
"应用名"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
)
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"appName"
,
value
=
"应用名"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态"
,
dataType
=
"int"
)
})
public
PageResult
<
DeviceVo
>
getDeviceList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
);
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
,
@RequestParam
(
value
=
"status"
,
required
=
false
)
int
status
)
{
PageInfoModel
<
DeviceVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
appName
,
userName
,
status
);
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
<
DeviceVo
>
pageResult
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
}
@ApiOperation
(
value
=
"获取设备详细信息接口"
,
notes
=
"用于获取设备详细信息列表"
)
...
...
@@ -108,9 +112,9 @@ public class DeviceController {
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
)
})
public
PageResult
<
DeviceDetailVo
>
getDeviceDetailList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
PageInfoModel
<
DeviceDetailVo
>
records
=
deviceManager
.
getDeviceDetailList
(
pageNo
,
pageSize
,
appName
,
userName
);
int
total
=
records
.
getTotal
();
...
...
@@ -125,13 +129,14 @@ public class DeviceController {
/**
* 添加device_black
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"添加设备黑名单接口"
,
notes
=
"用于添加设备黑名单"
)
@PostMapping
(
"device_black/add"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
}))
@MyLog
(
title
=
"添加设备黑名单"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
public
BaseResult
addDeviceBlack
(
@RequestBody
JSONObject
jsonObject
)
{
...
...
@@ -146,13 +151,14 @@ public class DeviceController {
/**
* 删除device_black
*
* @param jsonObject
* @return
*/
@ApiOperation
(
value
=
"设备黑名单删除接口"
,
notes
=
"删除设备黑名单"
)
@PostMapping
(
"device_black/delete"
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"deviceId"
,
value
=
"设备Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
)
}))
@MyLog
(
title
=
"删除设备黑名单"
,
optParam
=
"#{deviceId}"
,
businessType
=
BusinessType
.
DELETE
)
public
BaseResult
deleteDeviceBlack
(
@RequestBody
JSONObject
jsonObject
)
{
...
...
@@ -167,6 +173,7 @@ public class DeviceController {
/**
* 分页查询所有黑名单设备
*
* @param pageNo
* @param pageSize
* @return
...
...
@@ -175,19 +182,19 @@ public class DeviceController {
@GetMapping
(
"device_black/list"
)
@MyLog
(
title
=
"获取设备黑名单列表"
,
optParam
=
"#{pageNo},#{pageSize}"
,
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"
)
})
public
PageResult
<
DeviceBlack
>
getDeviceBlackList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
){
PageInfoModel
<
DeviceBlack
>
records
=
deviceBlackService
.
getDeviceBlackList
(
pageNo
,
pageSize
);
public
PageResult
<
DeviceBlack
>
getDeviceBlackList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
)
{
PageInfoModel
<
DeviceBlack
>
records
=
deviceBlackService
.
getDeviceBlackList
(
pageNo
,
pageSize
);
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
<
DeviceBlack
>
pageResult
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
}
}
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
View file @
49684035
...
...
@@ -13,7 +13,7 @@ import java.util.List;
* @since 2022-06-08
*/
public
interface
DeviceMapper
extends
BaseMapper
<
Device
>
{
List
<
DeviceVo
>
getDeviceList
(
String
appName
,
String
userName
);
List
<
DeviceVo
>
getDeviceList
(
String
appName
,
String
userName
,
int
status
);
boolean
addDevice
(
String
sn
,
String
appId
);
}
license/src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
View file @
49684035
...
...
@@ -28,6 +28,9 @@ public class DeviceVo implements Serializable {
@ApiModelProperty
(
"绑定的设备编号"
)
private
String
snBind
;
@ApiModelProperty
(
"状态 0:未使用,1:已使用,2:失效"
)
private
String
status
;
@ApiModelProperty
(
"设备状态 0:正常 1:禁用"
)
private
int
blackFlag
;
...
...
license/src/main/java/iot/sixiang/license/model/vo/ResourceVo.java
View file @
49684035
...
...
@@ -28,6 +28,9 @@ public class ResourceVo {
@ApiModelProperty
(
"设备编号"
)
private
String
sn
;
@ApiModelProperty
(
"设备状态"
)
private
String
status
;
@ApiModelProperty
(
"应用id"
)
private
String
appId
;
}
\ No newline at end of file
license/src/main/java/iot/sixiang/license/model/vo/UserVo.java
View file @
49684035
...
...
@@ -10,6 +10,16 @@ import lombok.Data;
@Data
public
class
UserVo
extends
User
{
@ApiModelProperty
(
"设备数量"
)
public
int
deviceCount
;
@ApiModelProperty
(
"总设备"
)
public
int
totalDevice
;
@ApiModelProperty
(
"已使用设备"
)
public
int
inUseDevice
;
@ApiModelProperty
(
"未使用设备"
)
public
int
unUseDevice
;
@ApiModelProperty
(
"失效设备"
)
public
int
failedDevice
;
}
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
49684035
...
...
@@ -79,6 +79,10 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
4
);
//第五个单元格
cell
.
setCellValue
(
"sn"
);
cell
.
setCellStyle
(
styleRow
);
cell
=
row
.
createCell
((
short
)
5
);
//第六个单元格
cell
.
setCellValue
(
"状态"
);
cell
.
setCellStyle
(
styleRow
);
//第五步插入数据
List
<
ResourceVo
>
resourceList
=
resourceService
.
getResource
(
userId
);
for
(
int
i
=
0
;
i
<
resourceList
.
size
();
i
++)
{
...
...
@@ -106,9 +110,13 @@ public class ResourceManager {
cell
=
row
.
createCell
((
short
)
4
);
// 第五个单元格
cell
.
setCellValue
(
resourceVo
.
getSn
());
cell
.
setCellStyle
(
style
);
cell
=
row
.
createCell
((
short
)
5
);
// 第六个单元格
cell
.
setCellValue
(
resourceVo
.
getStatus
());
cell
.
setCellStyle
(
style
);
}
//在填完所有值以后,对每一列设置自适应宽度
for
(
int
n
=
0
;
n
<
5
;
n
++)
{
for
(
int
n
=
0
;
n
<
6
;
n
++)
{
sheet
.
autoSizeColumn
(
n
);
}
wb
.
write
(
os
);
...
...
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
49684035
...
...
@@ -12,7 +12,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
* @since 2022-06-08
*/
public
interface
DeviceService
extends
IService
<
Device
>
{
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
);
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
,
int
status
);
boolean
addDevice
(
String
appId
,
int
count
);
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
49684035
...
...
@@ -32,11 +32,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private
DeviceMapper
deviceMapper
;
@Override
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
)
{
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
,
int
status
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
DeviceVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
appName
,
userName
);
List
<
DeviceVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
appName
,
userName
,
status
);
deviceTypes
=
deviceTypes
.
stream
().
sorted
(
Comparator
.
comparing
(
DeviceVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
DeviceVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
...
license/src/main/resources/mapper/DeviceMapper.xml
View file @
49684035
...
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"iot.sixiang.license.mapper.DeviceMapper"
>
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceVo"
>
SELECT de.device_id,app_name,user_name,sn,sn_bind,de.create_time,de.update_time,de.device_id IN (select
SELECT de.device_id,app_name,user_name,sn,sn_bind,de.
status,de.
create_time,de.update_time,de.device_id IN (select
device_id from device_black) AS blackFlag FROM device AS de
JOIN apply AS app ON de.app_id = app.app_id
JOIN USER AS us ON us.user_id = app.user_id
...
...
@@ -14,6 +14,9 @@
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
</if>
<if
test=
"null != status"
>
and status = #{status}
</if>
</select>
<insert
id=
"addDevice"
parameterType=
"iot.sixiang.license.entity.Device"
>
...
...
license/src/main/resources/mapper/ResourceMapper.xml
View file @
49684035
...
...
@@ -3,7 +3,8 @@
<mapper
namespace=
"iot.sixiang.license.mapper.ResourceMapper"
>
<select
id=
"getResource"
resultType=
"iot.sixiang.license.model.vo.ResourceVo"
>
SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn, b.app_id
SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn, b.app_id,
(CASE c.`status` WHEN 1 THEN '已使用' WHEN 2 THEN '失效' ELSE '未使用' END) `status`
FROM USER a, apply b, device c WHERE a.user_id = b.user_id
AND b.app_id = c.app_id AND a.user_id = #{userId}
</select>
...
...
license/src/main/resources/mapper/UserMapper.xml
View file @
49684035
...
...
@@ -15,8 +15,15 @@
</update>
<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`) deviceCount FROM USER LEFT JOIN apply ON user.user_id = apply.user_id LEFT JOIN device ON apply.app_id = device.app_id
where 1=1
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 and device.`status` = 1, 1, NULL)) inUseDevice,
COUNT(if(device.device_id is NOT NULL and device.`status` = 2, 1, NULL)) failedDevice
FROM USER
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=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
</if>
...
...
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