北京经济技术开发区经开区虚拟城市项目-【后端】-服务,Poi,企业,地块等定制接口
13693261870
2023-10-05 e60b6c9cdc11fd436a0bcae225d1789db04c9504
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.smartearth.poiexcel.controller;
 
import com.smartearth.poiexcel.entity.EntEntity;
import com.smartearth.poiexcel.entity.ResponseMsg;
import com.smartearth.poiexcel.service.EntService;
import com.smartearth.poiexcel.utils.StringHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * 企业控制器
 * @author WWW
 * @date 2023-10-05
 */
@Api(tags = "企业控制器")
@RestController
@RequestMapping("/ent")
public class EntController extends BaseController {
    @Resource
    EntService entService;
 
    @ApiOperation(value = "查询令牌")
    @GetMapping({"/selectToken"})
    public ResponseMsg<Object> selectToken() {
        try {
            String token = entService.selectToken();
 
            return success(StringHelper.isEmpty(token) ? 0 : 1, token);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
 
    @ApiOperation(value = "查询企业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "startDate", value = "开始日期", dataType = "String", paramType = "query", example = "2023-06-29"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "String", paramType = "query", example = "2023-06-30"),
            @ApiImplicitParam(name = "qylabel", value = "标签", dataType = "Integer", paramType = "query", example = "开业"),
            @ApiImplicitParam(name = "showCount", value = "显示记录数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "currentPage", value = "当前分页数", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping({"/selectEnts"})
    public ResponseMsg<Object> selectEnts(String token, String startDate, String endDate, String qylabel, Integer showCount, Integer currentPage) {
        try {
            if (StringHelper.isEmpty(token)) {
                token = entService.selectToken();
            }
            if (StringHelper.isEmpty(token)) {
                return fail("查询令牌失败");
            }
            if (null == showCount || showCount < 1) {
                showCount = 10;
            }
            if (null == currentPage || currentPage < 1) {
                currentPage = 1;
            }
 
            List<EntEntity> list = entService.selectEnts(token, startDate, endDate, qylabel, showCount, currentPage);
 
            return success(null == list || list.isEmpty() ? 0 : list.size(), list);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
 
    @ApiOperation(value = "插入企业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "startDate", value = "开始日期", dataType = "String", paramType = "query", example = "2023-06-29"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "String", paramType = "query", example = "2023-06-30"),
            @ApiImplicitParam(name = "qylabel", value = "标签", dataType = "Integer", paramType = "query", example = "开业"),
            @ApiImplicitParam(name = "showCount", value = "显示记录数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "currentPage", value = "当前分页数", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping({"/insertEnts"})
    public ResponseMsg<Object> insertEnts(String token, String startDate, String endDate, String qylabel, Integer showCount, Integer currentPage) {
        try {
            if (StringHelper.isEmpty(token)) {
                token = entService.selectToken();
            }
            if (StringHelper.isEmpty(token)) {
                return fail("查询令牌失败");
            }
            if (null == showCount || showCount < 1) {
                showCount = 10;
            }
            if (null == currentPage || currentPage < 1) {
                currentPage = 1;
            }
 
            List<EntEntity> list = entService.selectEnts(token, startDate, endDate, qylabel, showCount, currentPage);
            if (null == list || list.isEmpty()) {
                return fail("查询企业为空");
            }
 
            Integer rows = entService.insertEnts(list);
 
            return success(rows);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
}