ustcyc
2025-01-07 de5d55508afd27fb2b47e6d4d6fd9984525c222c
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.zhitan.web.controller.gatewaysetting;
 
import javax.servlet.http.HttpServletResponse;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.zhitan.common.annotation.Anonymous;
import com.zhitan.common.core.page.TableDataInfo;
import com.zhitan.common.utils.StringUtils;
import com.zhitan.common.utils.poi.ExcelUtil;
import com.zhitan.gatewaysetting.domain.GatewaySetting;
import com.zhitan.gatewaysetting.service.IGatewaySettingService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
 
import org.springframework.web.bind.annotation.*;
import com.zhitan.common.annotation.Log;
import com.zhitan.common.core.controller.BaseController;
import com.zhitan.common.core.domain.AjaxResult;
import com.zhitan.common.enums.BusinessType;
 
import java.util.List;
import java.util.UUID;
 
/**
 * 网关配置信息Controller
 *
 * @author ZhiTan
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/gatewaySetting")
public class GatewaySettingController extends BaseController
{
    @Resource
    private IGatewaySettingService gatewaySettingService;
 
    /**
     * 查询网关配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:setting:list')")
    @GetMapping("/list")
    public TableDataInfo list(GatewaySetting gatewaySetting,@RequestParam Long pageNum,@RequestParam Long pageSize)
    {
//        startPage();
        Page<GatewaySetting> list = gatewaySettingService.selectGatewaySettingPage(gatewaySetting,pageNum,pageSize);
        return getDataTable(list);
    }
 
    /**
     * 查询计量器具数量和点位数量
     * @param gatewaySetting
     * @return
     */
    @GetMapping("/ptNum")
    public AjaxResult ptNum(GatewaySetting gatewaySetting)
    {
        return success(gatewaySettingService.ptNum(gatewaySetting));
    }
 
 
    /**
     * 导出网关配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:setting:export')")
    @Log(title = "网关配置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GatewaySetting gatewaySetting)
    {
        List<GatewaySetting> list = gatewaySettingService.selectGatewaySettingList(gatewaySetting);
        ExcelUtil<GatewaySetting> util = new ExcelUtil<GatewaySetting>(GatewaySetting.class);
        util.exportExcel(response, list, "网关配置信息数据");
    }
 
    /**
     * 获取网关配置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:setting:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gatewaySettingService.selectGatewaySettingById(id));
    }
 
    /**
     * 新增网关配置信息
     */
    @PreAuthorize("@ss.hasPermi('system:setting:add')")
    @Log(title = "网关配置信息", businessType = BusinessType.INSERT)
        @PostMapping
    public AjaxResult add(@RequestBody GatewaySetting gatewaySetting)
    {
        int repeatCount =  gatewaySettingService.checkOne(gatewaySetting);
        if(repeatCount>0){
            return AjaxResult.error("网关编号重复");
        }
        gatewaySetting.setId(UUID.randomUUID().toString());
        return toAjax(gatewaySettingService.insertGatewaySetting(gatewaySetting));
    }
 
    /**
     * 修改网关配置信息
     */
    @PreAuthorize("@ss.hasPermi('system:setting:edit')")
    @Log(title = "网关配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GatewaySetting gatewaySetting)
    {
        if(ObjectUtils.isEmpty(gatewaySetting.getId())){
            return AjaxResult.error("无网关主键");
        }
        int repeatCount =  gatewaySettingService.checkOne(gatewaySetting);
        if(repeatCount>0){
            return AjaxResult.error("网关编号重复");
        }
        return toAjax(gatewaySettingService.updateGatewaySetting(gatewaySetting));
    }
 
    /**
     * 删除网关配置信息
     */
    @PreAuthorize("@ss.hasPermi('system:setting:remove')")
    @Log(title = "网关配置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gatewaySettingService.deleteGatewaySettingByIds(ids));
    }
 
    /**
     * 查询所有网关编码或名称
     * @param gatewaySetting
     * @return
     */
    @GetMapping("/baseList")
    public AjaxResult baseList(GatewaySetting gatewaySetting)
    {
        return success(gatewaySettingService.selectGatewaySettingList(gatewaySetting));
    }
}