浏览代码

工单系统

jingzhongge 2 年之前
父节点
当前提交
391d3d8a3f

+ 93 - 0
webapidemo-api/src/main/java/com/example/controller/system/LogininforController.java

@@ -0,0 +1,93 @@
1
+package com.example.controller.system;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.example.controller.BaseController;
7
+import com.example.entity.database.system.Logininfor;
8
+import com.example.entity.input.PageInput;
9
+import com.example.model.AjaxResult;
10
+import com.example.service.system.ILogininforService;
11
+import com.example.util.annotation.Log;
12
+import com.example.util.enums.BusinessType;
13
+import com.example.util.helper.ExcelHelper;
14
+import com.example.util.helper.StringHelper;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.web.bind.annotation.*;
19
+
20
+import javax.servlet.http.HttpServletResponse;
21
+import java.util.Arrays;
22
+import java.util.List;
23
+
24
+@Api(value = "系统访问记录",tags = "系统访问记录")
25
+@RestController
26
+@RequestMapping("/system/logininfor")
27
+public class LogininforController extends BaseController {
28
+    @Autowired
29
+    private ILogininforService logininforService;
30
+
31
+    @ApiOperation("列表")
32
+    @Log(title = "查询系统访问记录列表",businessType = BusinessType.QUERY)
33
+    @GetMapping
34
+    public AjaxResult getList(Logininfor input, PageInput pageInput) {
35
+        LambdaQueryWrapper<Logininfor> qw = new LambdaQueryWrapper();
36
+        qw.eq(input.getInfoId() != null && input.getInfoId() > 0, Logininfor::getInfoId, input.getInfoId());
37
+        qw.like(!StringHelper.isEmpty(input.getUserName()), Logininfor::getUserName, input.getUserName());
38
+        qw.like(!StringHelper.isEmpty(input.getIpaddr()), Logininfor::getIpaddr, input.getIpaddr());
39
+        qw.like(!StringHelper.isEmpty(input.getLoginLocation()), Logininfor::getLoginLocation, input.getLoginLocation());
40
+        qw.like(!StringHelper.isEmpty(input.getBrowser()), Logininfor::getBrowser, input.getBrowser());
41
+        qw.like(!StringHelper.isEmpty(input.getOs()), Logininfor::getOs, input.getOs());
42
+        qw.like(!StringHelper.isEmpty(input.getStatus()), Logininfor::getStatus, input.getStatus());
43
+        qw.like(!StringHelper.isEmpty(input.getMsg()), Logininfor::getMsg, input.getMsg());
44
+        qw.eq(input.getLoginTime() != null , Logininfor::getLoginTime, input.getLoginTime());
45
+        qw.between(input.getBeginTime()!=null, Logininfor::getLoginTime,input.getBeginTime(),input.getEndTime());
46
+
47
+        Page<Logininfor> page = GetPage(pageInput);
48
+        if (page != null) {
49
+            IPage<Logininfor> iPage = logininforService.getListPage(page, qw);
50
+            return Success("成功", iPage.getRecords(), iPage.getTotal());
51
+        } else {
52
+            return Success("成功", logininforService.getList(qw));
53
+        }
54
+    }
55
+
56
+    @ApiOperation("详情")
57
+    @Log(title = "查询系统访问记录详情",businessType = BusinessType.QUERY)
58
+    @GetMapping("/{id}")
59
+    public AjaxResult getInfo(@PathVariable long id) {
60
+        return Success("成功", logininforService.getEntity(id));
61
+    }
62
+
63
+    @ApiOperation("删除")
64
+    @Log(title = "删除系统访问记录",businessType = BusinessType.DELETE)
65
+    @DeleteMapping("/{ids}")
66
+    public AjaxResult delete(@PathVariable Long[] ids)  {
67
+        boolean result = logininforService.delete(Arrays.asList(ids));
68
+        if (result) {
69
+            return Success("成功");
70
+        } else {
71
+            return Error("删除失败");
72
+        }
73
+    }
74
+
75
+    @ApiOperation("导出Excel")
76
+    @Log(title = "导出Excel",businessType = BusinessType.EXPORT)
77
+    @PostMapping("/export")
78
+    public void ExportExcel(HttpServletResponse response) {
79
+        List<Logininfor> list = logininforService.getList();
80
+        ExcelHelper<Logininfor> excel = new ExcelHelper<>(Logininfor.class);
81
+        excel.exportExcel(response, "xlsx", list);
82
+    }
83
+
84
+    @Log(title = "清空登录日志",businessType = BusinessType.CLEAN)
85
+    @DeleteMapping("/clean")
86
+    public AjaxResult clean()
87
+    {
88
+        logininforService.cleanLogininfor();
89
+        return Success("操作成功!");
90
+    }
91
+
92
+
93
+}

+ 176 - 0
webapidemo-api/src/main/java/com/example/controller/system/PostController.java

@@ -0,0 +1,176 @@
1
+package com.example.controller.system;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.example.controller.BaseController;
7
+import com.example.entity.database.system.Post;
8
+import com.example.entity.input.PageInput;
9
+import com.example.model.AjaxResult;
10
+import com.example.service.system.IPostService;
11
+import com.example.util.annotation.Log;
12
+import com.example.util.enums.BusinessType;
13
+import com.example.util.helper.ExcelHelper;
14
+import com.example.util.helper.StringHelper;
15
+import io.swagger.annotations.Api;
16
+import io.swagger.annotations.ApiOperation;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.web.bind.annotation.*;
19
+
20
+import javax.servlet.http.HttpServletResponse;
21
+import java.util.Date;
22
+import java.util.List;
23
+
24
+@Api(value = "岗位信息表", tags = "岗位信息表")
25
+@RestController
26
+@RequestMapping("/system/post")
27
+public class PostController extends BaseController {
28
+    @Autowired
29
+    private IPostService postService;
30
+
31
+    /**
32
+     * 查看岗位列表
33
+     * @param input
34
+     * @param pageInput
35
+     * @return
36
+     */
37
+    @ApiOperation("列表")
38
+    @Log(title = "查看岗位列表",businessType = BusinessType.QUERY)
39
+    @GetMapping()
40
+    public AjaxResult getList(Post input, PageInput pageInput) {
41
+        LambdaQueryWrapper<Post> qw = new LambdaQueryWrapper();
42
+        qw.eq(input.getPostId() != null && input.getPostId() > 0, Post::getPostId, input.getPostId());
43
+        qw.like(!StringHelper.isEmpty(input.getPostCode()), Post::getPostCode, input.getPostCode());
44
+        qw.like(!StringHelper.isEmpty(input.getPostName()), Post::getPostName, input.getPostName());
45
+        qw.eq(input.getPostSort() != null && input.getPostSort() > 0, Post::getPostSort, input.getPostSort());
46
+        qw.like(!StringHelper.isEmpty(input.getStatus()), Post::getStatus, input.getStatus());
47
+        qw.like(!StringHelper.isEmpty(input.getCreateBy()), Post::getCreateBy, input.getCreateBy());
48
+        qw.eq(input.getCreateTime() != null, Post::getCreateTime, input.getCreateTime());
49
+        qw.like(!StringHelper.isEmpty(input.getUpdateBy()), Post::getUpdateBy, input.getUpdateBy());
50
+        qw.eq(input.getUpdateTime() != null, Post::getUpdateTime, input.getUpdateTime());
51
+        qw.like(!StringHelper.isEmpty(input.getRemark()), Post::getRemark, input.getRemark());
52
+        Page<Post> page = GetPage(pageInput);
53
+        if (page != null) {
54
+            IPage<Post> iPage = postService.getListPage(page, qw);
55
+            return Success("成功", iPage.getRecords(), iPage.getTotal());
56
+        } else {
57
+            return Success("成功", postService.getList(qw));
58
+        }
59
+    }
60
+
61
+    /**
62
+     * 查看岗位详情
63
+     * @param id
64
+     * @return
65
+     */
66
+    @ApiOperation("详情")
67
+    @Log(title = "查看岗位详情",businessType = BusinessType.QUERY)
68
+    @GetMapping("/{id}")
69
+    public AjaxResult getInfo(@PathVariable Long id) {
70
+        LambdaQueryWrapper<Post> qw = new LambdaQueryWrapper<>();
71
+        qw.eq(Post::getPostId, id).eq(Post::getStatus, "0");
72
+        Post entity = postService.getEntity(qw);
73
+        if (entity == null) {
74
+            return Error("岗位不存在!");
75
+        }
76
+        return Success("成功", entity);
77
+    }
78
+
79
+    /**
80
+     * 新增岗位
81
+     * @param input
82
+     * @return
83
+     */
84
+    @ApiOperation("新增")
85
+    @Log(title = "新增岗位",businessType = BusinessType.INSERT)
86
+    @PostMapping
87
+    public AjaxResult add(@RequestBody Post input) {
88
+        LambdaQueryWrapper<Post> qw = new LambdaQueryWrapper<>();
89
+        qw.eq(StringHelper.isNotEmpty(input.getPostName()), Post::getPostName, input.getPostName());
90
+
91
+        LambdaQueryWrapper<Post> qw2 = new LambdaQueryWrapper<>();
92
+        qw2.eq(StringHelper.isNotEmpty(input.getPostCode()), Post::getPostCode, input.getPostCode());
93
+        Post entity = postService.getEntity(qw);
94
+        Post entity2 = postService.getEntity(qw2);
95
+        input.setCreateBy(CurrentUser().getUserName());
96
+        input.setCreateTime(new Date());
97
+        if (entity != null) {
98
+            return Error("新增岗位'" + input.getPostName() + "'失败,岗位名称已存在");
99
+        } else if (entity2 != null) {
100
+            return Error("新增岗位'" + input.getPostName() + "'失败,岗位编码已存在");
101
+        }
102
+        boolean result = postService.insert(input);
103
+        if (result) {
104
+            return Success("成功");
105
+        } else {
106
+            return Error("新增失败");
107
+        }
108
+    }
109
+
110
+    /**
111
+     * 编辑
112
+     * @param input
113
+     * @return
114
+     */
115
+    @ApiOperation("编辑")
116
+    @Log(title = "修改岗位信息",businessType = BusinessType.UPDATE)
117
+    @PutMapping
118
+    public AjaxResult edit(@RequestBody Post input) {
119
+        LambdaQueryWrapper<Post> qw = new LambdaQueryWrapper<>();
120
+        LambdaQueryWrapper<Post> qw2 = new LambdaQueryWrapper<>();
121
+
122
+        if (StringHelper.isNotEmpty(input.getPostName())) {
123
+            qw.eq(Post::getPostName, input.getPostName());
124
+            Post entity = postService.getEntity(qw);
125
+            if (entity != null && !entity.getPostId().equals(input.getPostId())) {
126
+                return Error("修改岗位'" + input.getPostName() + "'失败,岗位名称已存在");
127
+            }
128
+        }
129
+        if (StringHelper.isNotEmpty(input.getPostCode())) {
130
+            qw2.eq(Post::getPostCode, input.getPostCode());
131
+            Post entity2 = postService.getEntity(qw2);
132
+
133
+            if (entity2 != null && !entity2.getPostId().equals(input.getPostId())) {
134
+                return Error("修改岗位'" + input.getPostName() + "'失败,岗位编码已存在");
135
+            }
136
+        }
137
+        input.setUpdateBy(CurrentUser().getUserName());
138
+        input.setUpdateTime(new Date());
139
+
140
+        boolean result = postService.update(input);
141
+        if (result) {
142
+            return Success("成功");
143
+        } else {
144
+            return Error("修改失败");
145
+        }
146
+    }
147
+
148
+    /**
149
+     * 删除
150
+     * @param ids
151
+     * @return
152
+     */
153
+    @ApiOperation("删除")
154
+    @Log(title = "删除岗位",businessType = BusinessType.DELETE)
155
+    @DeleteMapping("/{ids}")
156
+    public AjaxResult delete(@PathVariable Long[] ids) {
157
+        LambdaQueryWrapper<Post> qw = new LambdaQueryWrapper<>();
158
+        qw.in(Post::getPostId, ids);
159
+        boolean delete = postService.delete(qw);
160
+        if (delete) {
161
+            return Success("成功");
162
+        } else {
163
+            return Error("删除失败");
164
+        }
165
+    }
166
+
167
+    @ApiOperation("导出Excel")
168
+    @Log(title = "导出Excel",businessType = BusinessType.EXPORT)
169
+    @PostMapping("/exportExcel")
170
+    public void ExportExcel(HttpServletResponse response) {
171
+        List<Post> list = postService.getList();
172
+        ExcelHelper<Post> excel = new ExcelHelper<>(Post.class);
173
+        excel.exportExcel(response, "xlsx", list);
174
+    }
175
+
176
+}