Commit 02ff516f0fc506e69d636c4a5ed72b62dfa38a01

Authored by YunaiV
1 parent 6a36fe65

1. 完成通知模块的迁移

2. 实现 excel 导出的基础功能
ruoyi-admin/src/main/resources/application.yml
... ... @@ -77,22 +77,6 @@ spring:
77 77 # #连接池最大阻塞等待时间(使用负值表示没有限制)
78 78 max-wait: -1ms
79 79  
80   -# MyBatis配置
81   -mybatis:
82   - # 搜索指定包别名
83   - typeAliasesPackage: com.ruoyi.**.domain
84   - # 配置mapper的扫描,找到所有的mapper.xml映射文件
85   - mapperLocations: classpath*:mapper/**/*Mapper.xml
86   - # 加载全局的配置文件
87   - configLocation: classpath:mybatis/mybatis-config.xml
88   -
89   -# PageHelper分页插件
90   -pagehelper:
91   - helperDialect: mysql
92   - reasonable: true
93   - supportMethodsArguments: true
94   - params: count=countSql
95   -
96 80 # Swagger配置
97 81 swagger:
98 82 # 是否开启swagger
... ...
ruoyi-framework/pom.xml deleted
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <parent>
6   - <artifactId>ruoyi</artifactId>
7   - <groupId>com.ruoyi</groupId>
8   - <version>3.3.0</version>
9   - </parent>
10   - <modelVersion>4.0.0</modelVersion>
11   -
12   - <artifactId>ruoyi-framework</artifactId>
13   -
14   - <description>
15   - framework框架核心
16   - </description>
17   -
18   - <dependencies>
19   -
20   -
21   - <!-- SpringBoot 拦截器 -->
22   - <dependency>
23   - <groupId>org.springframework.boot</groupId>
24   - <artifactId>spring-boot-starter-aop</artifactId>
25   - </dependency>
26   -
27   - <!-- 获取系统信息 -->
28   - <dependency>
29   - <groupId>com.github.oshi</groupId>
30   - <artifactId>oshi-core</artifactId>
31   - </dependency>
32   -
33   - </dependencies>
34   -
35   -</project>
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java
... ... @@ -58,31 +58,16 @@ public class Cpu {
58 58 return Arith.round(Arith.mul(sys / total, 100), 2);
59 59 }
60 60  
61   - public void setSys(double sys) {
62   - this.sys = sys;
63   - }
64   -
65 61 public double getUsed() {
66 62 return Arith.round(Arith.mul(used / total, 100), 2);
67 63 }
68 64  
69   - public void setUsed(double used) {
70   - this.used = used;
71   - }
72   -
73 65 public double getWait() {
74 66 return Arith.round(Arith.mul(wait / total, 100), 2);
75 67 }
76 68  
77   - public void setWait(double wait) {
78   - this.wait = wait;
79   - }
80   -
81 69 public double getFree() {
82 70 return Arith.round(Arith.mul(free / total, 100), 2);
83 71 }
84 72  
85   - public void setFree(double free) {
86   - this.free = free;
87   - }
88 73 }
... ...
ruoyi-ui/src/api/system/notice.js
... ... @@ -30,7 +30,7 @@ export function addNotice(data) {
30 30 export function updateNotice(data) {
31 31 return request({
32 32 url: '/system/notice/update',
33   - method: 'put',
  33 + method: 'post',
34 34 data: data
35 35 })
36 36 }
... ... @@ -39,6 +39,6 @@ export function updateNotice(data) {
39 39 export function delNotice(noticeId) {
40 40 return request({
41 41 url: '/system/notice/delete?id=' + noticeId,
42   - method: 'delete'
  42 + method: 'post'
43 43 })
44 44 }
... ...
ruoyi-ui/src/api/system/user.js
... ... @@ -49,7 +49,8 @@ export function exportUser(query) {
49 49 return request({
50 50 url: '/system/user/export',
51 51 method: 'get',
52   - params: query
  52 + params: query,
  53 + responseType: 'blob'
53 54 })
54 55 }
55 56  
... ...
ruoyi-ui/src/views/system/notice/index.vue
... ... @@ -49,7 +49,7 @@
49 49 </el-row>
50 50  
51 51 <el-table v-loading="loading" :data="noticeList">
52   - <el-table-column label="序号" align="center" prop="noticeId" width="100" />
  52 + <el-table-column label="序号" align="center" prop="id" width="100" />
53 53 <el-table-column
54 54 label="公告标题"
55 55 align="center"
... ... @@ -117,11 +117,11 @@
117 117 <el-form-item label="公告类型" prop="type">
118 118 <el-select v-model="form.type" placeholder="请选择">
119 119 <el-option
120   - v-for="dict in typeOptions"
121   - :key="dict.dictValue"
122   - :label="dict.dictLabel"
123   - :value="dict.dictValue"
124   - ></el-option>
  120 + v-for="dict in noticeTypeDictDatas"
  121 + :key="parseInt(dict.value)"
  122 + :label="dict.label"
  123 + :value="parseInt(dict.value)"
  124 + />
125 125 </el-select>
126 126 </el-form-item>
127 127 </el-col>
... ... @@ -131,9 +131,9 @@
131 131 <el-radio
132 132 v-for="dict in statusDictDatas"
133 133 :key="parseInt(dict.value)"
134   - :label="dict.label"
135   - :value="parseInt(dict.value)"
  134 + :label="parseInt(dict.value)"
136 135 >{{dict.label}}</el-radio>
  136 + </el-radio-group>
137 137 </el-form-item>
138 138 </el-col>
139 139 <el-col :span="24">
... ... @@ -177,10 +177,6 @@ export default {
177 177 title: "",
178 178 // 是否显示弹出层
179 179 open: false,
180   - // 类型数据字典
181   - statusOptions: [],
182   - // 状态数据字典
183   - typeOptions: [],
184 180 // 查询参数
185 181 queryParams: {
186 182 pageNo: 1,
... ... @@ -227,7 +223,7 @@ export default {
227 223 },
228 224 // 公告状态字典翻译
229 225 typeFormat(row, column) {
230   - return getDictDataLabel(DICT_TYPE.SYS_NOTICE_TYPE, row.status)
  226 + return getDictDataLabel(DICT_TYPE.SYS_NOTICE_TYPE, row.type)
231 227 },
232 228 // 取消按钮
233 229 cancel() {
... ... @@ -237,7 +233,7 @@ export default {
237 233 // 表单重置
238 234 reset() {
239 235 this.form = {
240   - noticeId: undefined,
  236 + id: undefined,
241 237 title: undefined,
242 238 type: undefined,
243 239 content: undefined,
... ... @@ -264,8 +260,8 @@ export default {
264 260 /** 修改按钮操作 */
265 261 handleUpdate(row) {
266 262 this.reset();
267   - const noticeId = row.noticeId || this.ids
268   - getNotice(noticeId).then(response => {
  263 + const id = row.id || this.ids
  264 + getNotice(id).then(response => {
269 265 this.form = response.data;
270 266 this.open = true;
271 267 this.title = "修改公告";
... ... @@ -275,7 +271,7 @@ export default {
275 271 submitForm: function() {
276 272 this.$refs["form"].validate(valid => {
277 273 if (valid) {
278   - if (this.form.noticeId !== undefined) {
  274 + if (this.form.id !== undefined) {
279 275 updateNotice(this.form).then(response => {
280 276 this.msgSuccess("修改成功");
281 277 this.open = false;
... ... @@ -293,13 +289,13 @@ export default {
293 289 },
294 290 /** 删除按钮操作 */
295 291 handleDelete(row) {
296   - const noticeIds = row.noticeId || this.ids
297   - this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", {
  292 + const ids = row.id || this.ids
  293 + this.$confirm('是否确认删除公告编号为"' + ids + '"的数据项?', "警告", {
298 294 confirmButtonText: "确定",
299 295 cancelButtonText: "取消",
300 296 type: "warning"
301 297 }).then(function() {
302   - return delNotice(noticeIds);
  298 + return delNotice(ids);
303 299 }).then(() => {
304 300 this.getList();
305 301 this.msgSuccess("删除成功");
... ...
ruoyi-ui/src/views/system/user/index.vue
... ... @@ -655,7 +655,15 @@ export default {
655 655 }).then(function() {
656 656 return exportUser(queryParams);
657 657 }).then(response => {
658   - this.download(response.msg);
  658 + // this.download(response.msg);
  659 + let blob = new Blob([response], {type: 'application/vnd.ms-excel'});
  660 + window.URL = window.URL || window.webkitURL;
  661 + let href = URL.createObjectURL(blob);
  662 + let downA = document.createElement("a");
  663 + downA.href = href;//
  664 + downA.download = '123321.xls';
  665 + downA.click();
  666 + window.URL.revokeObjectURL(href);
659 667 })
660 668 },
661 669 /** 导入按钮操作 */
... ...
src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java
... ... @@ -2,10 +2,10 @@ package cn.iocoder.dashboard.modules.system.controller.auth;
2 2  
3 3 import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
4 4 import cn.iocoder.dashboard.common.pojo.CommonResult;
5   -import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
6   -import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
7 5 import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthLoginReqVO;
8 6 import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthLoginRespVO;
  7 +import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
  8 +import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
9 9 import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert;
10 10 import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
11 11 import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;
... ... @@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.*;
22 22  
23 23 import javax.annotation.Resource;
24 24 import javax.validation.Valid;
25   -
26 25 import java.util.List;
27 26  
28 27 import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
... ...
src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeCreateReqVO.java
1 1 package cn.iocoder.dashboard.modules.system.controller.notice.vo;
2 2  
3   -import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
4 3 import io.swagger.annotations.ApiModel;
5 4 import lombok.Data;
6 5 import lombok.EqualsAndHashCode;
... ... @@ -8,5 +7,5 @@ import lombok.EqualsAndHashCode;
8 7 @ApiModel("通知公告创建 Request VO")
9 8 @Data
10 9 @EqualsAndHashCode(callSuper = true)
11   -public class SysNoticeCreateReqVO extends SysPostBaseVO {
  10 +public class SysNoticeCreateReqVO extends SysNoticeBaseVO {
12 11 }
... ...
src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeRespVO.java
1 1 package cn.iocoder.dashboard.modules.system.controller.notice.vo;
2 2  
3   -import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
4 3 import io.swagger.annotations.ApiModel;
5 4 import io.swagger.annotations.ApiModelProperty;
6 5 import lombok.Data;
... ... @@ -11,7 +10,7 @@ import java.util.Date;
11 10 @ApiModel("通知公告信息 Response VO")
12 11 @Data
13 12 @EqualsAndHashCode(callSuper = true)
14   -public class SysNoticeRespVO extends SysPostBaseVO {
  13 +public class SysNoticeRespVO extends SysNoticeBaseVO {
15 14  
16 15 @ApiModelProperty(value = "通知公告序号", required = true, example = "1024")
17 16 private Long id;
... ...
src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/vo/SysNoticeUpdateReqVO.java
1 1 package cn.iocoder.dashboard.modules.system.controller.notice.vo;
2 2  
3   -import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostBaseVO;
4 3 import io.swagger.annotations.ApiModel;
5 4 import io.swagger.annotations.ApiModelProperty;
6 5 import lombok.Data;
... ... @@ -11,7 +10,7 @@ import javax.validation.constraints.NotNull;
11 10 @ApiModel("岗位公告更新 Request VO")
12 11 @Data
13 12 @EqualsAndHashCode(callSuper = true)
14   -public class SysNoticeUpdateReqVO extends SysPostBaseVO {
  13 +public class SysNoticeUpdateReqVO extends SysNoticeBaseVO {
15 14  
16 15 @ApiModelProperty(value = "岗位公告编号", required = true, example = "1024")
17 16 @NotNull(message = "岗位公告编号不能为空")
... ...
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserController.java
... ... @@ -10,6 +10,7 @@ import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO;
10 10 import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
11 11 import cn.iocoder.dashboard.modules.system.service.user.SysUserService;
12 12 import cn.iocoder.dashboard.util.collection.CollectionUtils;
  13 +import com.alibaba.excel.EasyExcel;
13 14 import io.swagger.annotations.Api;
14 15 import io.swagger.annotations.ApiImplicitParam;
15 16 import io.swagger.annotations.ApiOperation;
... ... @@ -17,6 +18,8 @@ import org.springframework.validation.annotation.Validated;
17 18 import org.springframework.web.bind.annotation.*;
18 19  
19 20 import javax.annotation.Resource;
  21 +import javax.servlet.http.HttpServletResponse;
  22 +import java.io.IOException;
20 23 import java.util.*;
21 24  
22 25 import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
... ... @@ -116,6 +119,15 @@ public class SysUserController {
116 119 return success(true);
117 120 }
118 121  
  122 + @ApiOperation("导出用户")
  123 + @GetMapping("/export")
  124 + public void exportUsers(HttpServletResponse response) throws IOException {
  125 + String fileName = "测试文件.xls";
  126 + response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
  127 + response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  128 + EasyExcel.write(response.getOutputStream(), SysUserExcelVO.class).sheet().doWrite(new ArrayList<>());
  129 + }
  130 +
119 131 // @Log(title = "用户管理", businessType = BusinessType.EXPORT)
120 132 // @PreAuthorize("@ss.hasPermi('system:user:export')")
121 133 // @GetMapping("/export")
... ...
src/main/java/cn/iocoder/dashboard/modules/system/service/notice/impl/SysNoticeServiceImpl.java
... ... @@ -5,7 +5,6 @@ import cn.iocoder.dashboard.common.pojo.PageResult;
5 5 import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeCreateReqVO;
6 6 import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticePageReqVO;
7 7 import cn.iocoder.dashboard.modules.system.controller.notice.vo.SysNoticeUpdateReqVO;
8   -import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
9 8 import cn.iocoder.dashboard.modules.system.convert.notice.SysNoticeConvert;
10 9 import cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice.SysNoticeMapper;
11 10 import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO;
... ... @@ -40,6 +39,7 @@ public class SysNoticeServiceImpl implements SysNoticeService {
40 39 @Override
41 40 public Long createNotice(SysNoticeCreateReqVO reqVO) {
42 41 SysNoticeDO notice = SysNoticeConvert.INSTANCE.convert(reqVO);
  42 + noticeMapper.insert(notice);
43 43 return notice.getId();
44 44 }
45 45  
... ...