UserDeviceController.java
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.glsx.smart.controller;
import java.util.List;
import com.alibaba.fastjson.JSON;
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;
import com.glsx.smart.service.SmartUserDeviceService;
import lombok.extern.slf4j.Slf4j;
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.RestController;
/**
* <p>Description: 用户设备业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-04-23
*/
@Slf4j
@RestController
@RequestMapping("/userDevice")
public class UserDeviceController {
@Autowired
private SmartUserDeviceService userDeviceService;
/**
* 获取用户设备
*
* @param userDevice 请求
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SmartUserDevice userDevice) {
log.info("$$$$ /userDevice/getList param: {}", JSON.toJSONString(userDevice));
if (userDevice.getUserId() == null) {
throw BusinessException.create(ResultEnum.PARAM_ERROR);
}
List<SmartUserDevice> userDeviceList = userDeviceService.getList(userDevice);
return R.ok().data(userDeviceList);
}
/**
* 保存用户设备
*
* @param userDevice 请求
* @return 结果
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody SmartUserDevice userDevice) {
log.info("$$$$ /userDevice/save param: {}", JSON.toJSONString(userDevice));
boolean success = userDeviceService.save(userDevice) > 0;
return R.ok().data(success);
}
/**
* 删除用户设备
*
* @param userDevice 请求
* @return 结果
*/
@RequestMapping(value = "/deleteDevice", method = {RequestMethod.POST})
public R deleteDevice(@RequestBody SmartUserDevice userDevice) {
log.info("$$$$ /userDevice/deleteDevice param: {}", JSON.toJSONString(userDevice));
if (userDevice.getId() == null && userDevice.getUserId() == null) {
throw BusinessException.create(ResultEnum.PARAM_ERROR);
}
boolean success = userDeviceService.deleteDevice(userDevice) > 0;
return R.ok().data(success);
}
}