1
zhang
3 天以前 bc56530307e0e92b94a1abb5d38368f04b92e990
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
package com.zy.acs.hex.controller;
 
import com.zy.acs.framework.common.R;
import com.zy.acs.hex.domain.SelectOption;
import com.zy.acs.hex.enums.DirectionType;
import com.zy.acs.hex.enums.ProtocolType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
 
@RestController
@Slf4j
@RequestMapping(value = "/deviceLog")
public class SelectTypeController {
 
 
    /**
     * 查询消息类型
     *
     * @return
     */
    @GetMapping(value = "/queryType")
    @ResponseBody
    public R queryType() {
        DirectionType[] values = DirectionType.values();
        List<SelectOption> messageTypes = new ArrayList<>();
        for (DirectionType value : values) {
            messageTypes.add(new SelectOption(value.getText(), value.name().toLowerCase()));
        }
        return R.ok(messageTypes);
    }
 
    /**
     * 查询标签类型
     *
     * @return
     */
    @GetMapping(value = "/queryEvent")
    @ResponseBody
    public R queryEvent(@RequestParam(required = false) DirectionType directionType) {
        List<SelectOption> messageTypes = new ArrayList<>();
        if (directionType == null) {
            ProtocolType[] values = ProtocolType.values();
            for (ProtocolType value : values) {
                messageTypes.add(new SelectOption(value.name(), value.getDirection().getText() + "-" + value.getDes() + value.name()));
            }
            return R.ok(messageTypes);
        }
        List<ProtocolType> protocolTypes = ProtocolType.listByDirectionType(directionType);
        for (ProtocolType value : protocolTypes) {
            messageTypes.add(new SelectOption(value.name(), value.getDirection().getText() + "-" + value.getDes() + value.name()));
        }
        return R.ok(messageTypes);
    }
}