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
cdff0268
Commit
cdff0268
authored
Dec 09, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into for-yx
parents
7f895196
14de6597
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
27 deletions
+48
-27
update.sql
license/doc/update.sql
+2
-0
AuthManager.java
...e/src/main/java/iot/sixiang/license/auth/AuthManager.java
+14
-4
TerminalDeviceController.java
.../sixiang/license/controller/TerminalDeviceController.java
+25
-21
DeviceVo.java
.../src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
+3
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+3
-1
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+1
-1
No files found.
license/doc/update.sql
View file @
cdff0268
...
...
@@ -15,6 +15,8 @@ CREATE TABLE `pms_use_log`
AUTO_INCREMENT
=
0
DEFAULT
CHARSET
=
utf8
COMMENT
=
'使用记录表'
;
ALTER
TABLE
`device`
MODIFY
sn
varchar
(
30
)
NULL
COMMENT
'授权SN'
;
ALTER
TABLE
`device`
ADD
COLUMN
`status`
int
(
1
)
NULL
DEFAULT
NULL
COMMENT
'状态 0:未使用,1:已使用,2:失效'
AFTER
`app_id`
;
...
...
license/src/main/java/iot/sixiang/license/auth/AuthManager.java
View file @
cdff0268
...
...
@@ -80,9 +80,14 @@ public class AuthManager {
log
.
info
(
"in black..."
);
return
false
;
}
Apply
apply
=
allApply
.
get
(
appId
);
String
theAppId
=
device
.
getAppId
();
if
(
theAppId
==
null
)
{
log
.
info
(
"no real valid appId..."
);
return
false
;
}
Apply
apply
=
allApply
.
get
(
theAppId
);
String
appKey
=
apply
.
getAppKey
();
String
input
=
"app_id="
+
a
ppId
+
"&sn="
+
sn
;
String
input
=
"app_id="
+
theA
ppId
+
"&sn="
+
sn
;
String
valSHA1
=
HmacUtil
.
encrypt
(
input
,
appKey
,
HmacUtil
.
HMAC_SHA1
).
toUpperCase
();
if
(
CommonUtil
.
toUpperCaseByEnglish
(
sign
).
equals
(
CommonUtil
.
toUpperCaseByEnglish
(
valSHA1
)))
{
return
true
;
...
...
@@ -112,9 +117,14 @@ public class AuthManager {
log
.
info
(
"in black..."
);
return
false
;
}
Apply
apply
=
allApply
.
get
(
appId
);
String
theAppId
=
device
.
getAppId
();
if
(
theAppId
==
null
)
{
log
.
info
(
"no real valid appId..."
);
return
false
;
}
Apply
apply
=
allApply
.
get
(
theAppId
);
String
appKey
=
apply
.
getAppKey
();
String
input
=
"app_id="
+
a
ppId
+
"&sn="
+
sn
+
"&sn_bind="
+
device
.
getSnBind
();
String
input
=
"app_id="
+
theA
ppId
+
"&sn="
+
sn
+
"&sn_bind="
+
device
.
getSnBind
();
String
valSHA1
=
HmacUtil
.
encrypt
(
input
,
appKey
,
HmacUtil
.
HMAC_SHA1
).
toUpperCase
();
if
(
CommonUtil
.
toUpperCaseByEnglish
(
sign
).
equals
(
CommonUtil
.
toUpperCaseByEnglish
(
valSHA1
)))
{
return
true
;
...
...
license/src/main/java/iot/sixiang/license/controller/TerminalDeviceController.java
View file @
cdff0268
...
...
@@ -4,7 +4,11 @@ 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.*
;
import
iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO
;
import
iot.sixiang.license.model.dto.PlatFormBindDTO
;
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.service.TerminalDeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -22,23 +26,23 @@ public class TerminalDeviceController {
@Autowired
TerminalDeviceService
terminalDeviceService
;
//
@GetMapping("/get_token")
//
@ApiOperation(value = "终端设备获取token", notes = "终端设备获取token")
//
public ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO) {
//
return terminalDeviceService.getToken(getTerminalDeviceTokenDTO);
//
}
@GetMapping
(
"/get_token"
)
@ApiOperation
(
value
=
"终端设备获取token"
,
notes
=
"终端设备获取token"
)
public
ResResult
getToken
(
GetTerminalDeviceTokenDTO
getTerminalDeviceTokenDTO
)
{
return
terminalDeviceService
.
getToken
(
getTerminalDeviceTokenDTO
);
}
//
@PostMapping("/report_error_msg")
//
@ApiOperation(value = "终端设备上报错误信息", notes = "终端设备上报错误信息")
//
public BaseResult reportErrorMsg(@RequestBody List<ReportErrorMsgDTO> reportErrorMsgDTO) {
//
return terminalDeviceService.reportErrorMsg(reportErrorMsgDTO);
//
}
@PostMapping
(
"/report_error_msg"
)
@ApiOperation
(
value
=
"终端设备上报错误信息"
,
notes
=
"终端设备上报错误信息"
)
public
BaseResult
reportErrorMsg
(
@RequestBody
List
<
ReportErrorMsgDTO
>
reportErrorMsgDTO
)
{
return
terminalDeviceService
.
reportErrorMsg
(
reportErrorMsgDTO
);
}
//
@PostMapping("/bind")
//
@ApiOperation(value = "终端设备绑定接口", notes = "终端设备绑定接口")
//
public BaseResult terminalDevieBind(@RequestBody TerminalDevieBindDTO terminalDevieBindDTO) {
//
return terminalDeviceService.terminalDeviceBind(terminalDevieBindDTO);
//
}
@PostMapping
(
"/bind"
)
@ApiOperation
(
value
=
"终端设备绑定接口"
,
notes
=
"终端设备绑定接口"
)
public
BaseResult
terminalDevieBind
(
@RequestBody
TerminalDevieBindDTO
terminalDevieBindDTO
)
{
return
terminalDeviceService
.
terminalDeviceBind
(
terminalDevieBindDTO
);
}
@PostMapping
(
"/unbind"
)
@ApiOperation
(
value
=
"终端设备解绑接口"
,
notes
=
"终端设备解绑接口"
)
...
...
@@ -46,11 +50,11 @@ public class TerminalDeviceController {
return
terminalDeviceService
.
terminalDeviceunBind
(
terminalDevieUnBindDTO
);
}
//
@GetMapping("/get_bind_status")
//
@ApiOperation(value = "获取终端设备绑定状态接口", notes = "获取终端设备绑定状态接口")
//
public ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
//
return terminalDeviceService.getBindStatus(terminalDevieUnBindDTO);
//
}
@GetMapping
(
"/get_bind_status"
)
@ApiOperation
(
value
=
"获取终端设备绑定状态接口"
,
notes
=
"获取终端设备绑定状态接口"
)
public
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
)
{
return
terminalDeviceService
.
getBindStatus
(
terminalDevieUnBindDTO
);
}
@PostMapping
(
"/v2/bind"
)
@ApiOperation
(
value
=
"平台绑定设备sn接口"
,
notes
=
"平台绑定设备sn接口"
)
...
...
license/src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
View file @
cdff0268
...
...
@@ -16,6 +16,9 @@ public class DeviceVo implements Serializable {
@ApiModelProperty
(
"设备Id"
)
private
int
deviceId
;
@ApiModelProperty
(
"应用Id"
)
private
String
appId
;
@ApiModelProperty
(
"应用名"
)
private
String
appName
;
...
...
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
cdff0268
...
...
@@ -119,7 +119,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
queryWrapper
.
eq
(
Device:
:
getSnBind
,
snBind
).
last
(
"limit 1"
);
Device
device
=
deviceMapper
.
selectOne
(
queryWrapper
);
if
(
device
!=
null
)
{
device
.
setSn
(
CommonUtil
.
genRandomNum
(
18
));
if
(
snBind
.
equals
(
device
.
getSn
()))
{
device
.
setSn
(
null
);
}
device
.
setSnBind
(
null
);
device
.
setStatus
(
0
);
device
.
setUpdateTime
(
new
Date
());
...
...
license/src/main/resources/mapper/DeviceMapper.xml
View file @
cdff0268
...
...
@@ -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.status,de.create_time,de.update_time,de.device_id IN (select
SELECT de.device_id,
de.app_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
...
...
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