Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b1a30c57
authored
Apr 25, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' of 192.168.3.233:open-source/chejia-smart-service into dev
2 parents
02495403
4ea322a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
21 deletions
src/main/java/com/glsx/smart/controller/UserDeviceController.java
src/main/java/com/glsx/smart/service/impl/SmartUserDeviceServiceImpl.java
src/main/java/com/glsx/smart/controller/UserDeviceController.java
View file @
b1a30c5
...
...
@@ -4,7 +4,6 @@ import java.util.List;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.smart.dao.entity.SmartUserDevice
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.ResultEnum
;
...
...
@@ -14,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
...
...
@@ -38,13 +36,12 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/getList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getList
(
SmartUserDevice
req
)
{
public
List
<
SmartUserDevice
>
getList
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getList param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
req
.
getUserId
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
List
<
SmartUserDevice
>
userDeviceList
=
userDeviceService
.
getList
(
req
);
return
R
.
ok
().
data
(
userDeviceList
);
return
userDeviceService
.
getList
(
req
);
}
/**
...
...
@@ -54,13 +51,12 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/getByDeviceId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getByDeviceId
(
SmartUserDevice
req
)
{
public
SmartUserDevice
getByDeviceId
(
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/getByDeviceId param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
()))
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
SmartUserDevice
userDevice
=
userDeviceService
.
getByDeviceId
(
req
);
return
R
.
ok
().
data
(
userDevice
);
return
userDeviceService
.
getByDeviceId
(
req
);
}
/**
...
...
@@ -70,13 +66,12 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
R
save
(
@RequestBody
SmartUserDevice
req
)
{
public
boolean
save
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/save param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
boolean
success
=
userDeviceService
.
save
(
req
)
>
0
;
return
R
.
ok
().
data
(
success
);
return
userDeviceService
.
save
(
req
)
>
0
;
}
/**
...
...
@@ -86,13 +81,12 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/deleteDevice"
,
method
=
{
RequestMethod
.
POST
})
public
R
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
public
boolean
deleteDevice
(
@RequestBody
SmartUserDevice
req
)
{
log
.
info
(
"$$$$ /userDevice/deleteDevice param: {}"
,
JSON
.
toJSONString
(
req
));
if
(
StringUtils
.
isBlank
(
req
.
getDeviceId
())
||
req
.
getChannel
()
==
null
)
{
throw
BusinessException
.
create
(
ResultEnum
.
PARAM_ERROR
);
}
boolean
success
=
userDeviceService
.
deleteDevice
(
req
)
>
0
;
return
R
.
ok
().
data
(
success
);
return
userDeviceService
.
deleteDevice
(
req
)
>
0
;
}
/**
...
...
@@ -102,10 +96,9 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/getUserBindKey"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
R
getUserBindKey
(
@RequestParam
String
username
)
{
public
String
getUserBindKey
(
String
username
)
{
log
.
info
(
"$$$$ /userDevice/getUserBindKey param: {}"
,
username
);
String
userBindKey
=
userDeviceService
.
getUserBindKey
(
username
);
return
R
.
ok
().
data
(
userBindKey
);
return
userDeviceService
.
getUserBindKey
(
username
);
}
/**
...
...
@@ -115,9 +108,8 @@ public class UserDeviceController {
* @return 结果
*/
@RequestMapping
(
value
=
"/sendCommand"
,
method
=
{
RequestMethod
.
POST
})
public
R
sendCommand
(
JSONObject
req
)
{
public
String
sendCommand
(
@RequestBody
JSONObject
req
)
{
log
.
info
(
"$$$$ /userDevice/sendCommand param: {}"
,
req
.
toJSONString
());
String
result
=
userDeviceService
.
sendCommand
(
req
);
return
R
.
ok
().
data
(
result
);
return
userDeviceService
.
sendCommand
(
req
);
}
}
src/main/java/com/glsx/smart/service/impl/SmartUserDeviceServiceImpl.java
View file @
b1a30c5
...
...
@@ -121,6 +121,8 @@ public class SmartUserDeviceServiceImpl extends BaseService implements SmartUser
String
respJson
=
HttpUtils
.
post
(
url
,
req
.
toJSONString
());
log
.
info
(
"$$$$ sendCommand resp = {}"
,
respJson
);
JSONObject
respObj
=
JSON
.
parseObject
(
respJson
);
return
respObj
.
getString
(
"result"
);
String
result
=
"200"
.
equals
(
respObj
.
getString
(
"code"
))
?
respObj
.
getString
(
"result"
)
:
null
;
return
result
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment