whyczh
2021-04-07 4992d0ea3fb6adaba4331fda37c43e8f0d00a458
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
package com.whyc.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.whyc.dto.Response;
import com.whyc.pojo.MotorState;
import com.whyc.service.MotorStateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
@RestController
@RequestMapping("motorState")
@Api(tags = "电机-状态")
@Slf4j
public class MotorStateController {
    @Resource
    private MotorStateService motorStateService;
 
    @PostMapping
    @ApiOperation("添加")
    public Response add(@RequestBody MotorState motorState){
        return motorStateService.add(motorState);
    }
    @PutMapping
    @ApiOperation("编辑")
    public Response update(@RequestBody MotorState motorState){
        return motorStateService.update(motorState);
    }
    @GetMapping
    @ApiOperation("查询by设备id")
    public Response getMontorState(@RequestParam int deviceId){
        return motorStateService.getById(deviceId);
    }
    /*@PutMapping("delete")
    public Response delete(@RequestParam Integer deviceId){
        return motorStateService.delete(deviceId);
    }*/
 
    @GetMapping("/all")
    @ApiOperation("查询所有")
    public Response<IPage<MotorState>> getAll(@RequestParam int pageNum,@RequestParam int pageSize){
        return motorStateService.getAll(pageNum,pageSize);
    }
 
    @GetMapping("ws")
    @ApiOperation(value="查询webSocket",protocols = "ws",notes = "接口:ws://localhost:8090/websocket,发送消息为deviceId")
    public Response doc(){
        return new Response().setMsg(1,"查看接口描述");
    }
 
}