From 39a0e05f87494d6cc84001b0b6d8e534685aaed6 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 21 五月 2021 17:58:01 +0800
Subject: [PATCH] update 请求响应对象 与 分页对象 结构修改 适配接口文档配置
---
ruoyi-ui/src/store/modules/user.js | 12
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java | 10
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java | 10
ruoyi-ui/src/views/system/role/index.vue | 10
ruoyi-ui/src/components/ImageUpload/index.vue | 200 +++++-----
ruoyi-ui/src/views/system/user/index.vue | 14
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java | 61 ++-
ruoyi-ui/src/views/login.vue | 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java | 18
ruoyi-ui/src/views/system/user/profile/index.vue | 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java | 8
ruoyi-ui/src/components/FileUpload/index.vue | 358 ++++++++++----------
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java | 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java | 13
ruoyi-ui/src/views/system/user/profile/userAvatar.vue | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java | 10
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java | 249 ++++++--------
17 files changed, 496 insertions(+), 495 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
index 28be0fe..0988656 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
@@ -19,6 +19,8 @@
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
@@ -88,10 +90,10 @@
code = captcha.getCode();
}
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("uuid", uuid);
ajax.put("img", captcha.getImageBase64());
- return ajax;
+ return AjaxResult.success(ajax);
}
private String getCodeResult(String capStr) {
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
index c69cdf2..7418a2c 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -18,10 +18,12 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.Map;
/**
* 閫氱敤璇锋眰澶勭悊
- *
+ *
* @author ruoyi
*/
@RestController
@@ -34,7 +36,7 @@
/**
* 閫氱敤涓嬭浇璇锋眰
- *
+ *
* @param fileName 鏂囦欢鍚嶇О
* @param delete 鏄惁鍒犻櫎
*/
@@ -77,10 +79,10 @@
// 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("fileName", fileName);
ajax.put("url", url);
- return ajax;
+ return AjaxResult.success(ajax);
}
catch (Exception e)
{
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
index 719012b..c3fdf83 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
@@ -15,12 +15,14 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* 閮ㄩ棬淇℃伅
- *
+ *
* @author ruoyi
*/
@RestController
@@ -89,10 +91,10 @@
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index b2df955..b2b9efb 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -17,12 +17,14 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
* 鐧诲綍楠岃瘉
- *
+ *
* @author ruoyi
*/
@RestController
@@ -42,24 +44,24 @@
/**
* 鐧诲綍鏂规硶
- *
+ *
* @param loginBody 鐧诲綍淇℃伅
* @return 缁撴灉
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
// 鐢熸垚浠ょ墝
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
* 鑾峰彇鐢ㄦ埛淇℃伅
- *
+ *
* @return 鐢ㄦ埛淇℃伅
*/
@GetMapping("getInfo")
@@ -71,16 +73,16 @@
Set<String> roles = permissionService.getRolePermission(user);
// 鏉冮檺闆嗗悎
Set<String> permissions = permissionService.getMenuPermission(user);
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
* 鑾峰彇璺敱淇℃伅
- *
+ *
* @return 璺敱淇℃伅
*/
@GetMapping("getRouters")
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java
index 547368b..00f1464 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java
@@ -18,11 +18,13 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* 鑿滃崟淇℃伅
- *
+ *
* @author ruoyi
*/
@RestController
@@ -78,10 +80,10 @@
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
@@ -148,4 +150,4 @@
}
return toAjax(menuService.deleteMenuById(menuId));
}
-}
\ No newline at end of file
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
index 7c65a9b..31ca6dd 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
@@ -19,10 +19,12 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
/**
* 涓汉淇℃伅 涓氬姟澶勭悊
- *
+ *
* @author ruoyi
*/
@RestController
@@ -43,10 +45,11 @@
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
- AjaxResult ajax = AjaxResult.success(user);
+ Map<String,Object> ajax = new HashMap<>();
+ ajax.put("user", user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
@@ -121,12 +124,12 @@
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{
- AjaxResult ajax = AjaxResult.success();
+ Map<String,Object> ajax = new HashMap<>();
ajax.put("imgUrl", avatar);
// 鏇存柊缂撳瓨鐢ㄦ埛澶村儚
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
- return ajax;
+ return AjaxResult.success(ajax);
}
}
return AjaxResult.error("涓婁紶鍥剧墖寮傚父锛岃鑱旂郴绠$悊鍛�");
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
index 7e74399..079c15a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -23,12 +23,14 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
* 鐢ㄦ埛淇℃伅
- *
+ *
* @author ruoyi
*/
@RestController
@@ -94,17 +96,17 @@
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
- AjaxResult ajax = AjaxResult.success();
+ Map<String, Object> ajax = new HashMap<>();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (Validator.isNotNull(userId))
{
- ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
+ ajax.put("user", userService.selectUserById(userId));
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
}
- return ajax;
+ return AjaxResult.success(ajax);
}
/**
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
index a7d2297..7c388c5 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
@@ -1,161 +1,134 @@
package com.ruoyi.common.core.domain;
-import cn.hutool.core.lang.Validator;
import cn.hutool.http.HttpStatus;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
import lombok.Data;
-
-import java.util.HashMap;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
/**
* 鎿嶄綔娑堟伅鎻愰啋
- *
- * @author ruoyi
+ *
+ * @author Lion Li
*/
-public class AjaxResult<T> extends HashMap<String, Object>
-{
- private static final long serialVersionUID = 1L;
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ApiModel("璇锋眰鍝嶅簲瀵硅薄")
+public class AjaxResult<T> {
- /** 鐘舵�佺爜 */
- public static final String CODE_TAG = "code";
+ private static final long serialVersionUID = 1L;
- /** 杩斿洖鍐呭 */
- public static final String MSG_TAG = "msg";
+ /**
+ * 鐘舵�佺爜
+ */
+ @ApiModelProperty("娑堟伅鐘舵�佺爜")
+ private int code;
- /** 鏁版嵁瀵硅薄 */
- public static final String DATA_TAG = "data";
+ /**
+ * 杩斿洖鍐呭
+ */
+ @ApiModelProperty("娑堟伅鍐呭")
+ private String msg;
- public Integer getCode(){
- return (Integer) super.get(CODE_TAG);
- }
+ /**
+ * 鏁版嵁瀵硅薄
+ */
+ @ApiModelProperty("鏁版嵁瀵硅薄")
+ private T data;
- public String getMsg(){
- return (String) super.get(MSG_TAG);
- }
- public T getData(){
- return (T) super.get(DATA_TAG);
- }
+ /**
+ * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
+ *
+ * @param code 鐘舵�佺爜
+ * @param msg 杩斿洖鍐呭
+ */
+ public AjaxResult(int code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
- /**
- * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄锛屼娇鍏惰〃绀轰竴涓┖娑堟伅銆�
- */
- public AjaxResult()
- {
- }
+ /**
+ * 杩斿洖鎴愬姛娑堟伅
+ *
+ * @return 鎴愬姛娑堟伅
+ */
+ public static AjaxResult<Void> success() {
+ return AjaxResult.success("鎿嶄綔鎴愬姛");
+ }
- /**
- * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
- *
- * @param code 鐘舵�佺爜
- * @param msg 杩斿洖鍐呭
- */
- public AjaxResult(int code, String msg)
- {
- super.put(CODE_TAG, code);
- super.put(MSG_TAG, msg);
- }
+ /**
+ * 杩斿洖鎴愬姛鏁版嵁
+ *
+ * @return 鎴愬姛娑堟伅
+ */
+ public static <T> AjaxResult<T> success(T data) {
+ return AjaxResult.success("鎿嶄綔鎴愬姛", data);
+ }
- /**
- * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄
- *
- * @param code 鐘舵�佺爜
- * @param msg 杩斿洖鍐呭
- * @param data 鏁版嵁瀵硅薄
- */
- public AjaxResult(int code, String msg, T data)
- {
- super.put(CODE_TAG, code);
- super.put(MSG_TAG, msg);
- if (Validator.isNotNull(data))
- {
- super.put(DATA_TAG, data);
- }
- }
+ /**
+ * 杩斿洖鎴愬姛娑堟伅
+ *
+ * @param msg 杩斿洖鍐呭
+ * @return 鎴愬姛娑堟伅
+ */
+ public static AjaxResult<Void> success(String msg) {
+ return AjaxResult.success(msg, null);
+ }
- /**
- * 杩斿洖鎴愬姛娑堟伅
- *
- * @return 鎴愬姛娑堟伅
- */
- public static AjaxResult<Void> success()
- {
- return AjaxResult.success("鎿嶄綔鎴愬姛");
- }
+ /**
+ * 杩斿洖鎴愬姛娑堟伅
+ *
+ * @param msg 杩斿洖鍐呭
+ * @param data 鏁版嵁瀵硅薄
+ * @return 鎴愬姛娑堟伅
+ */
+ public static <T> AjaxResult<T> success(String msg, T data) {
+ return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data);
+ }
- /**
- * 杩斿洖鎴愬姛鏁版嵁
- *
- * @return 鎴愬姛娑堟伅
- */
- public static <T> AjaxResult<T> success(T data)
- {
- return AjaxResult.success("鎿嶄綔鎴愬姛", data);
- }
+ /**
+ * 杩斿洖閿欒娑堟伅
+ *
+ * @return
+ */
+ public static AjaxResult<Void> error() {
+ return AjaxResult.error("鎿嶄綔澶辫触");
+ }
- /**
- * 杩斿洖鎴愬姛娑堟伅
- *
- * @param msg 杩斿洖鍐呭
- * @return 鎴愬姛娑堟伅
- */
- public static AjaxResult<Void> success(String msg)
- {
- return AjaxResult.success(msg, null);
- }
+ /**
+ * 杩斿洖閿欒娑堟伅
+ *
+ * @param msg 杩斿洖鍐呭
+ * @return 璀﹀憡娑堟伅
+ */
+ public static AjaxResult<Void> error(String msg) {
+ return AjaxResult.error(msg, null);
+ }
- /**
- * 杩斿洖鎴愬姛娑堟伅
- *
- * @param msg 杩斿洖鍐呭
- * @param data 鏁版嵁瀵硅薄
- * @return 鎴愬姛娑堟伅
- */
- public static <T> AjaxResult<T> success(String msg, T data)
- {
- return new AjaxResult(HttpStatus.HTTP_OK, msg, data);
- }
+ /**
+ * 杩斿洖閿欒娑堟伅
+ *
+ * @param msg 杩斿洖鍐呭
+ * @param data 鏁版嵁瀵硅薄
+ * @return 璀﹀憡娑堟伅
+ */
+ public static <T> AjaxResult<T> error(String msg, T data) {
+ return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
+ }
- /**
- * 杩斿洖閿欒娑堟伅
- *
- * @return
- */
- public static AjaxResult<Void> error()
- {
- return AjaxResult.error("鎿嶄綔澶辫触");
- }
+ /**
+ * 杩斿洖閿欒娑堟伅
+ *
+ * @param code 鐘舵�佺爜
+ * @param msg 杩斿洖鍐呭
+ * @return 璀﹀憡娑堟伅
+ */
+ public static AjaxResult<Void> error(int code, String msg) {
+ return new AjaxResult<>(code, msg, null);
+ }
- /**
- * 杩斿洖閿欒娑堟伅
- *
- * @param msg 杩斿洖鍐呭
- * @return 璀﹀憡娑堟伅
- */
- public static AjaxResult<Void> error(String msg)
- {
- return AjaxResult.error(msg, null);
- }
-
- /**
- * 杩斿洖閿欒娑堟伅
- *
- * @param msg 杩斿洖鍐呭
- * @param data 鏁版嵁瀵硅薄
- * @return 璀﹀憡娑堟伅
- */
- public static <T> AjaxResult<T> error(String msg, T data)
- {
- return new AjaxResult(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
- }
-
- /**
- * 杩斿洖閿欒娑堟伅
- *
- * @param code 鐘舵�佺爜
- * @param msg 杩斿洖鍐呭
- * @return 璀﹀憡娑堟伅
- */
- public static AjaxResult<Void> error(int code, String msg)
- {
- return new AjaxResult(code, msg, null);
- }
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
index 4e71fc1..81c596b 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
@@ -1,5 +1,7 @@
package com.ruoyi.common.core.page;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@@ -9,39 +11,50 @@
/**
* 琛ㄦ牸鍒嗛〉鏁版嵁瀵硅薄
- *
- * @author ruoyi
+ *
+ * @author Lion Li
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
-public class TableDataInfo<T> implements Serializable
-{
- private static final long serialVersionUID = 1L;
+@ApiModel("鍒嗛〉鍝嶅簲瀵硅薄")
+public class TableDataInfo<T> implements Serializable {
+ private static final long serialVersionUID = 1L;
- /** 鎬昏褰曟暟 */
- private long total;
+ /**
+ * 鎬昏褰曟暟
+ */
+ @ApiModelProperty("鎬昏褰曟暟")
+ private long total;
- /** 鍒楄〃鏁版嵁 */
- private List<T> rows;
+ /**
+ * 鍒楄〃鏁版嵁
+ */
+ @ApiModelProperty("鍒楄〃鏁版嵁")
+ private List<T> rows;
- /** 娑堟伅鐘舵�佺爜 */
- private int code;
+ /**
+ * 娑堟伅鐘舵�佺爜
+ */
+ @ApiModelProperty("娑堟伅鐘舵�佺爜")
+ private int code;
- /** 娑堟伅鍐呭 */
- private String msg;
+ /**
+ * 娑堟伅鍐呭
+ */
+ @ApiModelProperty("娑堟伅鍐呭")
+ private String msg;
- /**
- * 鍒嗛〉
- *
- * @param list 鍒楄〃鏁版嵁
- * @param total 鎬昏褰曟暟
- */
- public TableDataInfo(List<T> list, long total)
- {
- this.rows = list;
- this.total = total;
- }
+ /**
+ * 鍒嗛〉
+ *
+ * @param list 鍒楄〃鏁版嵁
+ * @param total 鎬昏褰曟暟
+ */
+ public TableDataInfo(List<T> list, long total) {
+ this.rows = list;
+ this.total = total;
+ }
}
diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue
index d19a012..81e2b3a 100644
--- a/ruoyi-ui/src/components/FileUpload/index.vue
+++ b/ruoyi-ui/src/components/FileUpload/index.vue
@@ -1,179 +1,179 @@
-<template>
- <div class="upload-file">
- <el-upload
- :action="uploadFileUrl"
- :before-upload="handleBeforeUpload"
- :file-list="fileList"
- :limit="1"
- :on-error="handleUploadError"
- :on-exceed="handleExceed"
- :on-success="handleUploadSuccess"
- :show-file-list="false"
- :headers="headers"
- class="upload-file-uploader"
- ref="upload"
- >
- <!-- 涓婁紶鎸夐挳 -->
- <el-button size="mini" type="primary">閫夊彇鏂囦欢</el-button>
- <!-- 涓婁紶鎻愮ず -->
- <div class="el-upload__tip" slot="tip" v-if="showTip">
- 璇蜂笂浼�
- <template v-if="fileSize"> 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
- <template v-if="fileType"> 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
- 鐨勬枃浠�
- </div>
- </el-upload>
-
- <!-- 鏂囦欢鍒楄〃 -->
- <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
- <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
- <el-link :href="file.url" :underline="false" target="_blank">
- <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
- </el-link>
- <div class="ele-upload-list__item-content-action">
- <el-link :underline="false" @click="handleDelete(index)" type="danger">鍒犻櫎</el-link>
- </div>
- </li>
- </transition-group>
- </div>
-</template>
-
-<script>
-import { getToken } from "@/utils/auth";
-
-export default {
- props: {
- // 鍊�
- value: [String, Object, Array],
- // 澶у皬闄愬埗(MB)
- fileSize: {
- type: Number,
- default: 5,
- },
- // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg']
- fileType: {
- type: Array,
- default: () => ["doc", "xls", "ppt", "txt", "pdf"],
- },
- // 鏄惁鏄剧ず鎻愮ず
- isShowTip: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
- headers: {
- Authorization: "Bearer " + getToken(),
- },
- fileList: [],
- };
- },
- computed: {
- // 鏄惁鏄剧ず鎻愮ず
- showTip() {
- return this.isShowTip && (this.fileType || this.fileSize);
- },
- // 鍒楄〃
- list() {
- let temp = 1;
- if (this.value) {
- // 棣栧厛灏嗗�艰浆涓烘暟缁�
- const list = Array.isArray(this.value) ? this.value : [this.value];
- // 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁�
- return list.map((item) => {
- if (typeof item === "string") {
- item = { name: item, url: item };
- }
- item.uid = item.uid || new Date().getTime() + temp++;
- return item;
- });
- } else {
- this.fileList = [];
- return [];
- }
- },
- },
- methods: {
- // 涓婁紶鍓嶆牎妫�鏍煎紡鍜屽ぇ灏�
- handleBeforeUpload(file) {
- // 鏍℃鏂囦欢绫诲瀷
- if (this.fileType) {
- let fileExtension = "";
- if (file.name.lastIndexOf(".") > -1) {
- fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
- }
- const isTypeOk = this.fileType.some((type) => {
- if (file.type.indexOf(type) > -1) return true;
- if (fileExtension && fileExtension.indexOf(type) > -1) return true;
- return false;
- });
- if (!isTypeOk) {
- this.$message.error(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!`);
- return false;
- }
- }
- // 鏍℃鏂囦欢澶у皬
- if (this.fileSize) {
- const isLt = file.size / 1024 / 1024 < this.fileSize;
- if (!isLt) {
- this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSize} MB!`);
- return false;
- }
- }
- return true;
- },
- // 鏂囦欢涓暟瓒呭嚭
- handleExceed() {
- this.$message.error(`鍙厑璁镐笂浼犲崟涓枃浠禶);
- },
- // 涓婁紶澶辫触
- handleUploadError(err) {
- this.$message.error("涓婁紶澶辫触, 璇烽噸璇�");
- },
- // 涓婁紶鎴愬姛鍥炶皟
- handleUploadSuccess(res, file) {
- this.$message.success("涓婁紶鎴愬姛");
- this.$emit("input", res.url);
- },
- // 鍒犻櫎鏂囦欢
- handleDelete(index) {
- this.fileList.splice(index, 1);
- this.$emit("input", '');
- },
- // 鑾峰彇鏂囦欢鍚嶇О
- getFileName(name) {
- if (name.lastIndexOf("/") > -1) {
- return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
- } else {
- return "";
- }
- }
- },
- created() {
- this.fileList = this.list;
- },
-};
-</script>
-
-<style scoped lang="scss">
-.upload-file-uploader {
- margin-bottom: 5px;
-}
-.upload-file-list .el-upload-list__item {
- border: 1px solid #e4e7ed;
- line-height: 2;
- margin-bottom: 10px;
- position: relative;
-}
-.upload-file-list .ele-upload-list__item-content {
- display: flex;
- justify-content: space-between;
- align-items: center;
- color: inherit;
-}
-.ele-upload-list__item-content-action .el-link {
- margin-right: 10px;
-}
-</style>
\ No newline at end of file
+<template>
+ <div class="upload-file">
+ <el-upload
+ :action="uploadFileUrl"
+ :before-upload="handleBeforeUpload"
+ :file-list="fileList"
+ :limit="1"
+ :on-error="handleUploadError"
+ :on-exceed="handleExceed"
+ :on-success="handleUploadSuccess"
+ :show-file-list="false"
+ :headers="headers"
+ class="upload-file-uploader"
+ ref="upload"
+ >
+ <!-- 涓婁紶鎸夐挳 -->
+ <el-button size="mini" type="primary">閫夊彇鏂囦欢</el-button>
+ <!-- 涓婁紶鎻愮ず -->
+ <div class="el-upload__tip" slot="tip" v-if="showTip">
+ 璇蜂笂浼�
+ <template v-if="fileSize"> 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
+ <template v-if="fileType"> 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
+ 鐨勬枃浠�
+ </div>
+ </el-upload>
+
+ <!-- 鏂囦欢鍒楄〃 -->
+ <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
+ <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
+ <el-link :href="file.url" :underline="false" target="_blank">
+ <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
+ </el-link>
+ <div class="ele-upload-list__item-content-action">
+ <el-link :underline="false" @click="handleDelete(index)" type="danger">鍒犻櫎</el-link>
+ </div>
+ </li>
+ </transition-group>
+ </div>
+</template>
+
+<script>
+import { getToken } from "@/utils/auth";
+
+export default {
+ props: {
+ // 鍊�
+ value: [String, Object, Array],
+ // 澶у皬闄愬埗(MB)
+ fileSize: {
+ type: Number,
+ default: 5,
+ },
+ // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg']
+ fileType: {
+ type: Array,
+ default: () => ["doc", "xls", "ppt", "txt", "pdf"],
+ },
+ // 鏄惁鏄剧ず鎻愮ず
+ isShowTip: {
+ type: Boolean,
+ default: true
+ }
+ },
+ data() {
+ return {
+ uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+ headers: {
+ Authorization: "Bearer " + getToken(),
+ },
+ fileList: [],
+ };
+ },
+ computed: {
+ // 鏄惁鏄剧ず鎻愮ず
+ showTip() {
+ return this.isShowTip && (this.fileType || this.fileSize);
+ },
+ // 鍒楄〃
+ list() {
+ let temp = 1;
+ if (this.value) {
+ // 棣栧厛灏嗗�艰浆涓烘暟缁�
+ const list = Array.isArray(this.value) ? this.value : [this.value];
+ // 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁�
+ return list.map((item) => {
+ if (typeof item === "string") {
+ item = { name: item, url: item };
+ }
+ item.uid = item.uid || new Date().getTime() + temp++;
+ return item;
+ });
+ } else {
+ this.fileList = [];
+ return [];
+ }
+ },
+ },
+ methods: {
+ // 涓婁紶鍓嶆牎妫�鏍煎紡鍜屽ぇ灏�
+ handleBeforeUpload(file) {
+ // 鏍℃鏂囦欢绫诲瀷
+ if (this.fileType) {
+ let fileExtension = "";
+ if (file.name.lastIndexOf(".") > -1) {
+ fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
+ }
+ const isTypeOk = this.fileType.some((type) => {
+ if (file.type.indexOf(type) > -1) return true;
+ if (fileExtension && fileExtension.indexOf(type) > -1) return true;
+ return false;
+ });
+ if (!isTypeOk) {
+ this.$message.error(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!`);
+ return false;
+ }
+ }
+ // 鏍℃鏂囦欢澶у皬
+ if (this.fileSize) {
+ const isLt = file.size / 1024 / 1024 < this.fileSize;
+ if (!isLt) {
+ this.$message.error(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${this.fileSize} MB!`);
+ return false;
+ }
+ }
+ return true;
+ },
+ // 鏂囦欢涓暟瓒呭嚭
+ handleExceed() {
+ this.$message.error(`鍙厑璁镐笂浼犲崟涓枃浠禶);
+ },
+ // 涓婁紶澶辫触
+ handleUploadError(err) {
+ this.$message.error("涓婁紶澶辫触, 璇烽噸璇�");
+ },
+ // 涓婁紶鎴愬姛鍥炶皟
+ handleUploadSuccess(res, file) {
+ this.$message.success("涓婁紶鎴愬姛");
+ this.$emit("input", res.data.url);
+ },
+ // 鍒犻櫎鏂囦欢
+ handleDelete(index) {
+ this.fileList.splice(index, 1);
+ this.$emit("input", '');
+ },
+ // 鑾峰彇鏂囦欢鍚嶇О
+ getFileName(name) {
+ if (name.lastIndexOf("/") > -1) {
+ return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
+ } else {
+ return "";
+ }
+ }
+ },
+ created() {
+ this.fileList = this.list;
+ },
+};
+</script>
+
+<style scoped lang="scss">
+.upload-file-uploader {
+ margin-bottom: 5px;
+}
+.upload-file-list .el-upload-list__item {
+ border: 1px solid #e4e7ed;
+ line-height: 2;
+ margin-bottom: 10px;
+ position: relative;
+}
+.upload-file-list .ele-upload-list__item-content {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ color: inherit;
+}
+.ele-upload-list__item-content-action .el-link {
+ margin-right: 10px;
+}
+</style>
diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue
index ce540eb..17d30d8 100644
--- a/ruoyi-ui/src/components/ImageUpload/index.vue
+++ b/ruoyi-ui/src/components/ImageUpload/index.vue
@@ -1,100 +1,100 @@
-<template>
- <div class="component-upload-image">
- <el-upload
- :action="uploadImgUrl"
- list-type="picture-card"
- :on-success="handleUploadSuccess"
- :before-upload="handleBeforeUpload"
- :on-error="handleUploadError"
- name="file"
- :show-file-list="false"
- :headers="headers"
- style="display: inline-block; vertical-align: top"
- >
- <el-image v-if="!value" :src="value">
- <div slot="error" class="image-slot">
- <i class="el-icon-plus" />
- </div>
- </el-image>
- <div v-else class="image">
- <el-image :src="value" :style="`width:150px;height:150px;`" fit="fill"/>
- <div class="mask">
- <div class="actions">
- <span title="棰勮" @click.stop="dialogVisible = true">
- <i class="el-icon-zoom-in" />
- </span>
- <span title="绉婚櫎" @click.stop="removeImage">
- <i class="el-icon-delete" />
- </span>
- </div>
- </div>
- </div>
- </el-upload>
- <el-dialog :visible.sync="dialogVisible" title="棰勮" width="800" append-to-body>
- <img :src="value" style="display: block; max-width: 100%; margin: 0 auto;">
- </el-dialog>
- </div>
-</template>
-
-<script>
-import { getToken } from "@/utils/auth";
-
-export default {
- data() {
- return {
- dialogVisible: false,
- uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
- headers: {
- Authorization: "Bearer " + getToken(),
- },
- };
- },
- props: {
- value: {
- type: String,
- default: "",
- },
- },
- methods: {
- removeImage() {
- this.$emit("input", "");
- },
- handleUploadSuccess(res) {
- this.$emit("input", res.url);
- this.loading.close();
- },
- handleBeforeUpload() {
- this.loading = this.$loading({
- lock: true,
- text: "涓婁紶涓�",
- background: "rgba(0, 0, 0, 0.7)",
- });
- },
- handleUploadError() {
- this.$message({
- type: "error",
- message: "涓婁紶澶辫触",
- });
- this.loading.close();
- },
- },
- watch: {},
-};
-</script>
-
-<style scoped lang="scss">
-.image {
- position: relative;
- .mask {
- opacity: 0;
- position: absolute;
- top: 0;
- width: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- transition: all 0.3s;
- }
- &:hover .mask {
- opacity: 1;
- }
-}
-</style>
\ No newline at end of file
+<template>
+ <div class="component-upload-image">
+ <el-upload
+ :action="uploadImgUrl"
+ list-type="picture-card"
+ :on-success="handleUploadSuccess"
+ :before-upload="handleBeforeUpload"
+ :on-error="handleUploadError"
+ name="file"
+ :show-file-list="false"
+ :headers="headers"
+ style="display: inline-block; vertical-align: top"
+ >
+ <el-image v-if="!value" :src="value">
+ <div slot="error" class="image-slot">
+ <i class="el-icon-plus" />
+ </div>
+ </el-image>
+ <div v-else class="image">
+ <el-image :src="value" :style="`width:150px;height:150px;`" fit="fill"/>
+ <div class="mask">
+ <div class="actions">
+ <span title="棰勮" @click.stop="dialogVisible = true">
+ <i class="el-icon-zoom-in" />
+ </span>
+ <span title="绉婚櫎" @click.stop="removeImage">
+ <i class="el-icon-delete" />
+ </span>
+ </div>
+ </div>
+ </div>
+ </el-upload>
+ <el-dialog :visible.sync="dialogVisible" title="棰勮" width="800" append-to-body>
+ <img :src="value" style="display: block; max-width: 100%; margin: 0 auto;">
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { getToken } from "@/utils/auth";
+
+export default {
+ data() {
+ return {
+ dialogVisible: false,
+ uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+ headers: {
+ Authorization: "Bearer " + getToken(),
+ },
+ };
+ },
+ props: {
+ value: {
+ type: String,
+ default: "",
+ },
+ },
+ methods: {
+ removeImage() {
+ this.$emit("input", "");
+ },
+ handleUploadSuccess(res) {
+ this.$emit("input", res.data.url);
+ this.loading.close();
+ },
+ handleBeforeUpload() {
+ this.loading = this.$loading({
+ lock: true,
+ text: "涓婁紶涓�",
+ background: "rgba(0, 0, 0, 0.7)",
+ });
+ },
+ handleUploadError() {
+ this.$message({
+ type: "error",
+ message: "涓婁紶澶辫触",
+ });
+ this.loading.close();
+ },
+ },
+ watch: {},
+};
+</script>
+
+<style scoped lang="scss">
+.image {
+ position: relative;
+ .mask {
+ opacity: 0;
+ position: absolute;
+ top: 0;
+ width: 100%;
+ background-color: rgba(0, 0, 0, 0.5);
+ transition: all 0.3s;
+ }
+ &:hover .mask {
+ opacity: 1;
+ }
+}
+</style>
diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js
index 0e45157..c6624e3 100644
--- a/ruoyi-ui/src/store/modules/user.js
+++ b/ruoyi-ui/src/store/modules/user.js
@@ -37,8 +37,8 @@
const uuid = userInfo.uuid
return new Promise((resolve, reject) => {
login(username, password, code, uuid).then(res => {
- setToken(res.token)
- commit('SET_TOKEN', res.token)
+ setToken(res.data.token)
+ commit('SET_TOKEN', res.data.token)
resolve()
}).catch(error => {
reject(error)
@@ -50,11 +50,11 @@
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
- const user = res.user
+ const user = res.data.user
const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
- if (res.roles && res.roles.length > 0) { // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁�
- commit('SET_ROLES', res.roles)
- commit('SET_PERMISSIONS', res.permissions)
+ if (res.data.roles && res.data.roles.length > 0) { // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁�
+ commit('SET_ROLES', res.data.roles)
+ commit('SET_PERMISSIONS', res.data.permissions)
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}
diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue
index 147117f..d68f614 100644
--- a/ruoyi-ui/src/views/login.vue
+++ b/ruoyi-ui/src/views/login.vue
@@ -99,8 +99,8 @@
methods: {
getCode() {
getCodeImg().then(res => {
- this.codeUrl = "data:image/gif;base64," + res.img;
- this.loginForm.uuid = res.uuid;
+ this.codeUrl = "data:image/gif;base64," + res.data.img;
+ this.loginForm.uuid = res.data.uuid;
});
},
getCookie() {
diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue
index 3cb6df9..84ba981 100644
--- a/ruoyi-ui/src/views/system/role/index.vue
+++ b/ruoyi-ui/src/views/system/role/index.vue
@@ -390,14 +390,14 @@
/** 鏍规嵁瑙掕壊ID鏌ヨ鑿滃崟鏍戠粨鏋� */
getRoleMenuTreeselect(roleId) {
return roleMenuTreeselect(roleId).then(response => {
- this.menuOptions = response.menus;
+ this.menuOptions = response.data.menus;
return response;
});
},
/** 鏍规嵁瑙掕壊ID鏌ヨ閮ㄩ棬鏍戠粨鏋� */
getRoleDeptTreeselect(roleId) {
return roleDeptTreeselect(roleId).then(response => {
- this.deptOptions = response.depts;
+ this.deptOptions = response.data.depts;
return response;
});
},
@@ -513,7 +513,7 @@
this.open = true;
this.$nextTick(() => {
roleMenu.then(res => {
- let checkedKeys = res.checkedKeys
+ let checkedKeys = res.data.checkedKeys
checkedKeys.forEach((v) => {
this.$nextTick(()=>{
this.$refs.menu.setChecked(v, true ,false);
@@ -539,7 +539,7 @@
this.openDataScope = true;
this.$nextTick(() => {
roleDeptTreeselect.then(res => {
- this.$refs.dept.setCheckedKeys(res.checkedKeys);
+ this.$refs.dept.setCheckedKeys(res.data.checkedKeys);
});
});
this.title = "鍒嗛厤鏁版嵁鏉冮檺";
@@ -607,4 +607,4 @@
}
}
};
-</script>
\ No newline at end of file
+</script>
diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index 1a06eb3..ce1d621 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -562,8 +562,8 @@
this.reset();
this.getTreeselect();
getUser().then(response => {
- this.postOptions = response.posts;
- this.roleOptions = response.roles;
+ this.postOptions = response.data.posts;
+ this.roleOptions = response.data.roles;
this.open = true;
this.title = "娣诲姞鐢ㄦ埛";
this.form.password = this.initPassword;
@@ -575,11 +575,11 @@
this.getTreeselect();
const userId = row.userId || this.ids;
getUser(userId).then(response => {
- this.form = response.data;
- this.postOptions = response.posts;
- this.roleOptions = response.roles;
- this.form.postIds = response.postIds;
- this.form.roleIds = response.roleIds;
+ this.form = response.data.user;
+ this.postOptions = response.data.posts;
+ this.roleOptions = response.data.roles;
+ this.form.postIds = response.data.postIds;
+ this.form.roleIds = response.data.roleIds;
this.open = true;
this.title = "淇敼鐢ㄦ埛";
this.form.password = "";
diff --git a/ruoyi-ui/src/views/system/user/profile/index.vue b/ruoyi-ui/src/views/system/user/profile/index.vue
index 8993cab..7a3e295 100644
--- a/ruoyi-ui/src/views/system/user/profile/index.vue
+++ b/ruoyi-ui/src/views/system/user/profile/index.vue
@@ -81,9 +81,9 @@
methods: {
getUser() {
getUserProfile().then(response => {
- this.user = response.data;
- this.roleGroup = response.roleGroup;
- this.postGroup = response.postGroup;
+ this.user = response.data.user;
+ this.roleGroup = response.data.roleGroup;
+ this.postGroup = response.data.postGroup;
});
}
}
diff --git a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue
index 266183e..6ed6314 100644
--- a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue
+++ b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue
@@ -126,7 +126,7 @@
formData.append("avatarfile", data);
uploadAvatar(formData).then(response => {
this.open = false;
- this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
+ this.options.img = process.env.VUE_APP_BASE_API + response.data.imgUrl;
store.commit('SET_AVATAR', this.options.img);
this.msgSuccess("淇敼鎴愬姛");
this.visible = false;
--
Gitblit v1.9.3