lyh
5 天以前 fda571324684bc8d0945b3e2841305b1207fc3e9
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
package com.lxzn.nc.controller;
 
import com.lxzn.api.nc.DocRelativeControllerApi;
import com.lxzn.framework.domain.nc.DeviceInfo;
import com.lxzn.framework.model.response.CommonCode;
import com.lxzn.framework.model.response.QueryListResponseResult;
import com.lxzn.framework.model.response.ResponseResult;
import com.lxzn.nc.service.IDocRelativeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/doc/relative")
public class DocRelativeController implements DocRelativeControllerApi {
    @Autowired
    private IDocRelativeService relativeService;
    @Override
    @DeleteMapping("/delete/device/{docId}/{deviceId}")
    public ResponseResult deleteDocByDeviceId(@PathVariable("docId") String docId, @PathVariable("deviceId") String deviceId) {
        boolean b = relativeService.deleteDocByAttr(docId, 4, deviceId);
        if(b)
            return new ResponseResult(CommonCode.SUCCESS);
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/get/device/{docId}")
    public QueryListResponseResult<DeviceInfo> findDeviceByDocId(@PathVariable("docId") String docId) {
        List<DeviceInfo> list = relativeService.findDeviceByDocId(docId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
}