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
57f7cc77
Commit
57f7cc77
authored
Dec 08, 2022
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增平台绑定接口
parent
239c324e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
12 deletions
+87
-12
TerminalDeviceController.java
.../sixiang/license/controller/TerminalDeviceController.java
+7
-4
PlatFormBindDTO.java
...n/java/iot/sixiang/license/model/dto/PlatFormBindDTO.java
+21
-0
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+4
-0
TerminalDeviceService.java
...va/iot/sixiang/license/service/TerminalDeviceService.java
+3
-4
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+40
-0
TerminalDeviceServiceImpl.java
...xiang/license/service/impl/TerminalDeviceServiceImpl.java
+12
-4
No files found.
license/src/main/java/iot/sixiang/license/controller/TerminalDeviceController.java
View file @
57f7cc77
...
...
@@ -4,10 +4,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.dto.*
;
import
iot.sixiang.license.service.TerminalDeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -54,4 +51,10 @@ public class TerminalDeviceController {
public
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
return
terminalDeviceService
.
getBindStatus
(
terminalDevieUnBindDTO
);
}
@PostMapping
(
"/v2/bind"
)
@ApiOperation
(
value
=
"平台绑定设备sn接口"
,
notes
=
"平台绑定设备sn接口"
)
public
BaseResult
platFormBind
(
@RequestBody
PlatFormBindDTO
platFormBindDTO
)
{
return
terminalDeviceService
.
platFormBind
(
platFormBindDTO
);
}
}
license/src/main/java/iot/sixiang/license/model/dto/PlatFormBindDTO.java
0 → 100644
View file @
57f7cc77
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2022/12/8 10:34
* Description
*/
@Data
public
class
PlatFormBindDTO
{
@ApiModelProperty
(
"设备id"
)
private
Integer
deviceId
;
@ApiModelProperty
(
"设备编码"
)
private
String
sn
;
@ApiModelProperty
(
"绑定的SN"
)
private
String
snBind
;
}
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
57f7cc77
...
...
@@ -2,8 +2,10 @@ package iot.sixiang.license.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.PlatFormBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.vo.DeviceVo
;
...
...
@@ -24,4 +26,6 @@ public interface DeviceService extends IService<Device> {
Boolean
terminalDevieunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
);
}
license/src/main/java/iot/sixiang/license/service/TerminalDeviceService.java
View file @
57f7cc77
...
...
@@ -2,10 +2,7 @@ package iot.sixiang.license.service;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.dto.*
;
import
java.util.List
;
...
...
@@ -19,4 +16,6 @@ public interface TerminalDeviceService {
BaseResult
terminalDeviceunBind
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
);
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
57f7cc77
...
...
@@ -7,8 +7,10 @@ import iot.sixiang.license.device.DeviceManager;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.DeviceMapper
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.PlatFormBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.vo.DeviceVo
;
...
...
@@ -23,6 +25,7 @@ import java.util.ArrayList;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.BaseStream
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -137,4 +140,41 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
return
new
ResResult
(
405
,
"未绑定"
);
}
}
@Override
public
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
)
{
Integer
deviceId
=
platFormBindDTO
.
getDeviceId
();
String
sn
=
platFormBindDTO
.
getSn
();
String
snBind
=
platFormBindDTO
.
getSnBind
();
LambdaQueryWrapper
<
Device
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
Device:
:
getSnBind
,
snBind
).
last
(
"limit 1"
);
Device
device
=
deviceMapper
.
selectOne
(
queryWrapper
);
if
(
device
!=
null
)
{
if
(
deviceId
.
equals
(
device
.
getDeviceId
()))
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
failed
().
msg
(
"设备sn已被绑定"
);
}
}
LambdaQueryWrapper
<
Device
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
Device:
:
getDeviceId
,
deviceId
).
last
(
"limit 1"
);
Device
tempDevice
=
deviceMapper
.
selectOne
(
wrapper
);
if
(
tempDevice
!=
null
)
{
if
(!
StringUtils
.
isEmpty
(
tempDevice
.
getSnBind
()))
{
return
BaseResult
.
failed
().
msg
(
"设备已绑定sn"
);
}
}
else
{
return
BaseResult
.
failed
().
msg
(
"请输入正确的id"
);
}
tempDevice
.
setSn
(
sn
);
tempDevice
.
setSnBind
(
snBind
);
tempDevice
.
setStatus
(
1
);
tempDevice
.
setUpdateTime
(
new
Date
());
int
res
=
deviceMapper
.
updateById
(
tempDevice
);
if
(
res
>
0
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
failed
();
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/TerminalDeviceServiceImpl.java
View file @
57f7cc77
...
...
@@ -7,10 +7,7 @@ import iot.sixiang.license.jwt.JwtUtil;
import
iot.sixiang.license.jwt.LoginUser
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieBindDTO
;
import
iot.sixiang.license.model.dto.TerminalDevieUnBindDTO
;
import
iot.sixiang.license.model.dto.*
;
import
iot.sixiang.license.service.DeviceService
;
import
iot.sixiang.license.service.PmsUseService
;
import
iot.sixiang.license.service.TerminalDeviceService
;
...
...
@@ -132,4 +129,15 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
}
return
deviceService
.
getBindStatus
(
terminalDevieUnBindDTO
);
}
@Override
public
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
)
{
Integer
deviceId
=
platFormBindDTO
.
getDeviceId
();
String
sn
=
platFormBindDTO
.
getSn
();
String
snBind
=
platFormBindDTO
.
getSnBind
();
if
(
deviceId
==
null
||
deviceId
<=
0
||
StringUtils
.
isEmpty
(
sn
)
||
StringUtils
.
isEmpty
(
snBind
))
{
return
BaseResult
.
validate_failed
();
}
return
deviceService
.
platFormBind
(
platFormBindDTO
);
}
}
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