Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
smartDevices-platform-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 4404ef17
authored
Mar 05, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]封装返回体
1 parent
ae4ea9d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
src/main/java/cn/com/glsx/modules/controller/DeviceController.java
src/main/java/cn/com/glsx/modules/model/param/ResponseBody.java
src/main/java/cn/com/glsx/modules/service/UserService.java
src/main/java/cn/com/glsx/modules/controller/DeviceController.java
View file @
4404ef1
package
cn
.
com
.
glsx
.
modules
.
controller
;
import
cn.com.glsx.modules.model.param.DeviceInfo
;
import
cn.com.glsx.modules.service.DeviceService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.util.List
;
/**
* @author zhouhaibao
...
...
@@ -9,8 +21,35 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping
(
"/device"
)
@Api
(
value
=
"设备管理"
,
tags
=
{
"设备管理"
})
public
class
DeviceController
{
@Autowired
private
DeviceService
deviceService
;
/**
* 获取用户下的设备列表
*
* @return
*/
@RequestMapping
(
value
=
"/{uid}/devices"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
@ApiOperation
(
value
=
"获取用户下的设备列表"
)
public
R
getAllDevicesByUser
(
@PathVariable
String
uid
){
List
<
DeviceInfo
>
list
=
deviceService
.
getAllDevicesByUser
(
uid
);
return
R
.
ok
(
JSONObject
.
toJSONString
(
list
));
}
/**
* 获取用户下的设备列表
*
* @return
*/
@RequestMapping
(
value
=
"/devices/{device_id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
@ApiOperation
(
value
=
"根据id获取设备"
)
public
R
getDevicesById
(
@PathVariable
String
device_id
){
DeviceInfo
deviceInfo
=
deviceService
.
getDevicesById
(
device_id
);
return
R
.
ok
(
JSONObject
.
toJSONString
(
deviceInfo
));
}
}
src/main/java/cn/com/glsx/modules/model/param/ResponseBody.java
View file @
4404ef1
...
...
@@ -16,4 +16,14 @@ public class ResponseBody {
* 返回的数据
*/
private
String
result
;
/**
* 返回code
*/
private
String
code
;
/**
* 返回message
*/
private
String
message
;
}
src/main/java/cn/com/glsx/modules/service/UserService.java
View file @
4404ef1
package
cn
.
com
.
glsx
.
modules
.
service
;
import
cn.com.glsx.modules.entity.TuyaUser
;
import
cn.com.glsx.modules.mapper.TuyaUserMapper
;
import
cn.com.glsx.modules.model.param.ResponseBody
;
import
cn.com.glsx.modules.model.param.UserBo
;
...
...
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