懒羊羊
2023-10-17 5d91e0a52879bf16511817b3cd20496f07717ab1
提交 | 用户 | 时间
4779be 1 package cn.stylefeng.guns.modular.zsx.sys.kanbanConf.controller;
2
3 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
4 import cn.stylefeng.guns.modular.zsx.kb.utils.IPUtil;
5 import cn.stylefeng.guns.modular.zsx.sys.kanbanConf.entity.KanbanConf;
6 import cn.stylefeng.guns.modular.zsx.sys.kanbanConf.model.params.KanbanConfParam;
7 import cn.stylefeng.guns.modular.zsx.sys.kanbanConf.service.KanbanConfService;
8 import cn.stylefeng.roses.core.base.controller.BaseController;
9 import cn.stylefeng.roses.kernel.model.response.ResponseData;
10 import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
11 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.stereotype.Controller;
14 import org.springframework.web.bind.annotation.RequestMapping;
15 import org.springframework.web.bind.annotation.ResponseBody;
16
17 import javax.servlet.http.HttpServletRequest;
18
19
20 /**
21  * 看板配置控制器
22  *
23  * @author ruimin
24  * @Date 2023-10-08 15:23:17
25  */
26 @Controller
27 @RequestMapping("/kanbanConf")
28 public class KanbanConfController extends BaseController {
29
30     private String PREFIX = "/modular/sys/kanbanConf";
31
32     @Autowired
33     private KanbanConfService kanbanConfService;
34
35     /**
36      * 跳转到主页面
37      *
38      * @author ruimin
39      * @Date 2023-10-08
40      */
41     @RequestMapping("")
42     public String index() {
43         return PREFIX + "/kanbanConf.html";
44     }
45
46     /**
47      * 新增页面
48      *
49      * @author ruimin
50      * @Date 2023-10-08
51      */
52     @RequestMapping("/add")
53     public String add() {
54         return PREFIX + "/kanbanConf_add.html";
55     }
56
57     /**
58      * 编辑页面
59      *
60      * @author ruimin
61      * @Date 2023-10-08
62      */
63     @RequestMapping("/edit")
64     public String edit() {
65         return PREFIX + "/kanbanConf_edit.html";
66     }
67
68     /**
69      * 新增接口
70      *
71      * @author ruimin
72      * @Date 2023-10-08
73      */
74     @RequestMapping("/addItem")
75     @ResponseBody
76     @DataSource(name = "self")
77     public ResponseData addItem(KanbanConfParam kanbanConfParam) {
78         this.kanbanConfService.add(kanbanConfParam);
79         return ResponseData.success();
80     }
81
82     /**
83      * 编辑接口
84      *
85      * @author ruimin
86      * @Date 2023-10-08
87      */
88     @RequestMapping("/editItem")
89     @ResponseBody
90     @DataSource(name = "self")
91     public ResponseData editItem(KanbanConfParam kanbanConfParam) {
92         this.kanbanConfService.update(kanbanConfParam);
93         return ResponseData.success();
94     }
95
96     /**
97      * 删除接口
98      *
99      * @author ruimin
100      * @Date 2023-10-08
101      */
102     @RequestMapping("/delete")
103     @ResponseBody
104     @DataSource(name = "self")
105     public ResponseData delete(KanbanConfParam kanbanConfParam) {
106         this.kanbanConfService.delete(kanbanConfParam);
107         return ResponseData.success();
108     }
109
110     /**
111      * 查看详情接口
112      *
113      * @author ruimin
114      * @Date 2023-10-08
115      */
116     @RequestMapping("/detail")
117     @ResponseBody
118     @DataSource(name = "self")
119     public ResponseData detail(KanbanConfParam kanbanConfParam) {
120         KanbanConf detail = this.kanbanConfService.getById(kanbanConfParam.getId());
121         return ResponseData.success(detail);
122     }
123
124     /**
125      * 查询列表
126      *
127      * @author ruimin
128      * @Date 2023-10-08
129      */
130     @ResponseBody
131     @RequestMapping("/list")
132     @DataSource(name = "self")
133     public LayuiPageInfo list(KanbanConfParam kanbanConfParam) {
134         return this.kanbanConfService.findPageBySpec(kanbanConfParam);
135     }
136
137     @RequestMapping("/ipSetting")
138     @ResponseBody
139     @DataSource(name = "self")
140     public ResponseData ipSetting(KanbanConfParam kanbanConfParam, HttpServletRequest request) {
141         String realIp = IPUtil.getRealIp(request);
142         KanbanConf kanbanConf = new KanbanConf();
143         KanbanConf ipAddress = this.kanbanConfService.getOne(new QueryWrapper<KanbanConf>().eq("ip_address", realIp));
144         if(ipAddress == null){
145             kanbanConf.setLineCode(kanbanConfParam.getLineCode());
146             kanbanConf.setLocationCode(kanbanConfParam.getLocationCode());
147             kanbanConf.setIpAddress(realIp);
148             this.kanbanConfService.save(kanbanConf);
149         }else {
150             kanbanConf.setLineCode(kanbanConfParam.getLineCode());
151             kanbanConf.setLocationCode(kanbanConfParam.getLocationCode());
152             this.kanbanConfService.update(kanbanConf,new QueryWrapper<KanbanConf>().eq("ip_address", realIp));
153         }
154         return ResponseData.success();
155     }
156
157     @RequestMapping("/initIpConf")
158     @ResponseBody
159     @DataSource(name = "self")
160     public ResponseData initIpConf(HttpServletRequest request) {
161         String realIp = IPUtil.getRealIp(request);
162         KanbanConf ipAddress = this.kanbanConfService.getOne(new QueryWrapper<KanbanConf>().eq("ip_address", realIp));
163         return ResponseData.success(ipAddress);
164     }
165
166 }
167
168