jinpengyong
2021-12-24 5c427a35595e2deb2c1a025ff9a4c164d498e01d
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
package com.moral.api.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.servlet.http.HttpServletRequest;
 
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.service.ProfessionService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
 
@Slf4j
@Api(tags = {"行业贡献率模块"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/profession")
public class ProfessionController {
 
    @Autowired
    private ProfessionService professionService;
 
    @ApiOperation(value = "根据组织id获取所有设备行业列表", notes = "根据组织id获取所有设备行业列表")
    @GetMapping("getProfessionsByOrganizationId")
    public ResultMessage getProfessions(Integer organizationId) {
        if (ObjectUtils.isEmpty(organizationId)) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Set<Map<String, Object>> response = professionService.getProfessionsByOrganizationId(organizationId);
        return ResultMessage.ok(response);
    }
 
    @ApiOperation(value = "获取该组织该行业所有设备的因子", notes = "获取该组织该行业所有设备的因子")
    @GetMapping("getSensorByProfessions")
    public ResultMessage getProfessions(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (ObjectUtils.isEmpty(params.get("organizationId")) || ObjectUtils.isEmpty(params.get("professions"))) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Set<Map<String, Object>> response = professionService.getSensorByProfessionsAndOrganizationId(params);
        return ResultMessage.ok(response);
    }
}