mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	发版 2.1.2
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "ruoyi-vue-plus",
 | 
			
		||||
  "version": "2.1.1",
 | 
			
		||||
  "version": "2.1.2",
 | 
			
		||||
  "description": "RuoYi-Vue-Plus后台管理系统",
 | 
			
		||||
  "author": "LionLi",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
 
 | 
			
		||||
@@ -135,7 +135,7 @@ export default {
 | 
			
		||||
    // 上传成功回调
 | 
			
		||||
    handleUploadSuccess(res, file) {
 | 
			
		||||
      this.$message.success("上传成功");
 | 
			
		||||
      this.$emit("input", res.url);
 | 
			
		||||
      this.$emit("input", res.data.url);
 | 
			
		||||
    },
 | 
			
		||||
    // 删除文件
 | 
			
		||||
    handleDelete(index) {
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ export default {
 | 
			
		||||
      this.$emit("input", "");
 | 
			
		||||
    },
 | 
			
		||||
    handleUploadSuccess(res) {
 | 
			
		||||
      this.$emit("input", res.url);
 | 
			
		||||
      this.$emit("input", res.data.url);
 | 
			
		||||
      this.loading.close();
 | 
			
		||||
    },
 | 
			
		||||
    handleBeforeUpload() {
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,8 @@ const user = {
 | 
			
		||||
      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 @@ const user = {
 | 
			
		||||
    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) { // 验证返回的roles是否是一个非空数组
 | 
			
		||||
            commit('SET_ROLES', res.roles)
 | 
			
		||||
            commit('SET_PERMISSIONS', res.permissions)
 | 
			
		||||
          if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
 | 
			
		||||
            commit('SET_ROLES', res.data.roles)
 | 
			
		||||
            commit('SET_PERMISSIONS', res.data.permissions)
 | 
			
		||||
          } else {
 | 
			
		||||
            commit('SET_ROLES', ['ROLE_DEFAULT'])
 | 
			
		||||
          }
 | 
			
		||||
 
 | 
			
		||||
@@ -80,6 +80,15 @@
 | 
			
		||||
            <span>更新日志</span>
 | 
			
		||||
          </div>
 | 
			
		||||
          <el-collapse accordion>
 | 
			
		||||
            <el-collapse-item title="v2.1.1 - 2021-5-21">
 | 
			
		||||
              <ol>
 | 
			
		||||
                <li>update springboot 升级 2.3.11</li>
 | 
			
		||||
                <li>update mybatis-plus 升级 3.4.3 分页Plus对象适配更新</li>
 | 
			
		||||
                <li>update 验证码生成更新为无符号整数计算</li>
 | 
			
		||||
                <li>update 请求响应对象 与 分页对象 结构修改 适配接口文档配置</li>
 | 
			
		||||
                <li>update swagger增加请求前缀</li>
 | 
			
		||||
              </ol>
 | 
			
		||||
            </el-collapse-item>
 | 
			
		||||
            <el-collapse-item title="v2.1.1 - 2021-5-19">
 | 
			
		||||
              <ol>
 | 
			
		||||
                <li>update 配置统一提取为 properties 配置类</li>
 | 
			
		||||
 
 | 
			
		||||
@@ -99,8 +99,8 @@ export default {
 | 
			
		||||
  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() {
 | 
			
		||||
 
 | 
			
		||||
@@ -390,14 +390,14 @@ export default {
 | 
			
		||||
    /** 根据角色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 @@ export default {
 | 
			
		||||
        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 @@ export default {
 | 
			
		||||
        this.openDataScope = true;
 | 
			
		||||
        this.$nextTick(() => {
 | 
			
		||||
          roleDeptTreeselect.then(res => {
 | 
			
		||||
            this.$refs.dept.setCheckedKeys(res.checkedKeys);
 | 
			
		||||
            this.$refs.dept.setCheckedKeys(res.data.checkedKeys);
 | 
			
		||||
          });
 | 
			
		||||
        });
 | 
			
		||||
        this.title = "分配数据权限";
 | 
			
		||||
 
 | 
			
		||||
@@ -562,8 +562,8 @@ export default {
 | 
			
		||||
      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 @@ export default {
 | 
			
		||||
      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 = "";
 | 
			
		||||
 
 | 
			
		||||
@@ -81,9 +81,9 @@ export default {
 | 
			
		||||
  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;
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -126,7 +126,7 @@ export default {
 | 
			
		||||
        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;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,8 @@
 | 
			
		||||
    <description>RuoYi-Vue-Plus后台管理系统</description>
 | 
			
		||||
 | 
			
		||||
    <properties>
 | 
			
		||||
        <ruoyi-vue-plus.version>2.1.1</ruoyi-vue-plus.version>
 | 
			
		||||
        <spring-boot.version>2.3.10.RELEASE</spring-boot.version>
 | 
			
		||||
        <ruoyi-vue-plus.version>2.1.2</ruoyi-vue-plus.version>
 | 
			
		||||
        <spring-boot.version>2.3.11.RELEASE</spring-boot.version>
 | 
			
		||||
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
			
		||||
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 | 
			
		||||
        <java.version>1.8</java.version>
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
        <poi.version>4.1.2</poi.version>
 | 
			
		||||
        <velocity.version>1.7</velocity.version>
 | 
			
		||||
        <jwt.version>0.9.1</jwt.version>
 | 
			
		||||
        <mybatis-plus.version>3.4.2</mybatis-plus.version>
 | 
			
		||||
        <mybatis-plus.version>3.4.3</mybatis-plus.version>
 | 
			
		||||
        <hutool.version>5.5.8</hutool.version>
 | 
			
		||||
        <feign.version>2.2.6.RELEASE</feign.version>
 | 
			
		||||
        <feign-okhttp.version>11.0</feign-okhttp.version>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,46 +1,44 @@
 | 
			
		||||
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>
 | 
			
		||||
{
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel("请求响应对象")
 | 
			
		||||
public class AjaxResult<T> {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    /** 状态码 */
 | 
			
		||||
    public static final String CODE_TAG = "code";
 | 
			
		||||
 | 
			
		||||
    /** 返回内容 */
 | 
			
		||||
    public static final String MSG_TAG = "msg";
 | 
			
		||||
 | 
			
		||||
    /** 数据对象 */
 | 
			
		||||
    public static final String DATA_TAG = "data";
 | 
			
		||||
 | 
			
		||||
    public Integer getCode(){
 | 
			
		||||
        return (Integer) super.get(CODE_TAG);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getMsg(){
 | 
			
		||||
        return (String) super.get(MSG_TAG);
 | 
			
		||||
    }
 | 
			
		||||
    public T getData(){
 | 
			
		||||
        return (T) super.get(DATA_TAG);
 | 
			
		||||
    }
 | 
			
		||||
	/**
 | 
			
		||||
	 * 状态码
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("消息状态码")
 | 
			
		||||
	private int code;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
     * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
 | 
			
		||||
	 * 返回内容
 | 
			
		||||
	 */
 | 
			
		||||
    public AjaxResult()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
	@ApiModelProperty("消息内容")
 | 
			
		||||
	private String msg;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 数据对象
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("数据对象")
 | 
			
		||||
	private T data;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 初始化一个新创建的 AjaxResult 对象
 | 
			
		||||
@@ -48,27 +46,9 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param code 状态码
 | 
			
		||||
	 * @param msg  返回内容
 | 
			
		||||
	 */
 | 
			
		||||
    public AjaxResult(int code, String msg)
 | 
			
		||||
    {
 | 
			
		||||
        super.put(CODE_TAG, code);
 | 
			
		||||
        super.put(MSG_TAG, msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 初始化一个新创建的 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);
 | 
			
		||||
        }
 | 
			
		||||
	public AjaxResult(int code, String msg) {
 | 
			
		||||
		this.code = code;
 | 
			
		||||
		this.msg = msg;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -76,8 +56,7 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return 成功消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static AjaxResult<Void> success()
 | 
			
		||||
    {
 | 
			
		||||
	public static AjaxResult<Void> success() {
 | 
			
		||||
		return AjaxResult.success("操作成功");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -86,8 +65,7 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return 成功消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static <T> AjaxResult<T> success(T data)
 | 
			
		||||
    {
 | 
			
		||||
	public static <T> AjaxResult<T> success(T data) {
 | 
			
		||||
		return AjaxResult.success("操作成功", data);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -97,8 +75,7 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param msg 返回内容
 | 
			
		||||
	 * @return 成功消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static AjaxResult<Void> success(String msg)
 | 
			
		||||
    {
 | 
			
		||||
	public static AjaxResult<Void> success(String msg) {
 | 
			
		||||
		return AjaxResult.success(msg, null);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -109,9 +86,8 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param data 数据对象
 | 
			
		||||
	 * @return 成功消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static <T> AjaxResult<T> success(String msg, T data)
 | 
			
		||||
    {
 | 
			
		||||
        return new AjaxResult(HttpStatus.HTTP_OK, msg, data);
 | 
			
		||||
	public static <T> AjaxResult<T> success(String msg, T data) {
 | 
			
		||||
		return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -119,8 +95,7 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
    public static AjaxResult<Void> error()
 | 
			
		||||
    {
 | 
			
		||||
	public static AjaxResult<Void> error() {
 | 
			
		||||
		return AjaxResult.error("操作失败");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -130,8 +105,7 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param msg 返回内容
 | 
			
		||||
	 * @return 警告消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static AjaxResult<Void> error(String msg)
 | 
			
		||||
    {
 | 
			
		||||
	public static AjaxResult<Void> error(String msg) {
 | 
			
		||||
		return AjaxResult.error(msg, null);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -142,9 +116,8 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param data 数据对象
 | 
			
		||||
	 * @return 警告消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static <T> AjaxResult<T> error(String msg, T data)
 | 
			
		||||
    {
 | 
			
		||||
        return new AjaxResult(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
 | 
			
		||||
	public static <T> AjaxResult<T> error(String msg, T data) {
 | 
			
		||||
		return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -154,8 +127,8 @@ public class AjaxResult<T> extends HashMap<String, Object>
 | 
			
		||||
	 * @param msg  返回内容
 | 
			
		||||
	 * @return 警告消息
 | 
			
		||||
	 */
 | 
			
		||||
    public static AjaxResult<Void> error(int code, String msg)
 | 
			
		||||
    {
 | 
			
		||||
        return new AjaxResult(code, msg, null);
 | 
			
		||||
	public static AjaxResult<Void> error(int code, String msg) {
 | 
			
		||||
		return new AjaxResult<>(code, msg, null);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -124,13 +124,25 @@ public class PagePlus<T,K> implements IPage<T> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    public boolean isSearchCount() {
 | 
			
		||||
        return this.total >= 0L && this.isSearchCount;
 | 
			
		||||
	public long getPages() {
 | 
			
		||||
		// 解决 github issues/3208
 | 
			
		||||
		return IPage.super.getPages();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public PagePlus<T, K> setSearchCount(boolean isSearchCount) {
 | 
			
		||||
        this.isSearchCount = isSearchCount;
 | 
			
		||||
        return this;
 | 
			
		||||
	public static <T,K> PagePlus<T,K> of(long current, long size) {
 | 
			
		||||
		return of(current, size, 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static <T,K> PagePlus<T,K> of(long current, long size, long total) {
 | 
			
		||||
		return of(current, size, total, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static <T,K> PagePlus<T,K> of(long current, long size, boolean searchCount) {
 | 
			
		||||
		return of(current, size, 0, searchCount);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static <T,K> PagePlus<T,K> of(long current, long size, long total, boolean searchCount) {
 | 
			
		||||
		return new PagePlus<>(current, size, total, searchCount);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
@@ -10,26 +12,38 @@ import java.util.List;
 | 
			
		||||
/**
 | 
			
		||||
 * 表格分页数据对象
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
public class TableDataInfo<T> implements Serializable
 | 
			
		||||
{
 | 
			
		||||
@ApiModel("分页响应对象")
 | 
			
		||||
public class TableDataInfo<T> implements Serializable {
 | 
			
		||||
	private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    /** 总记录数 */
 | 
			
		||||
	/**
 | 
			
		||||
	 * 总记录数
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("总记录数")
 | 
			
		||||
	private long total;
 | 
			
		||||
 | 
			
		||||
    /** 列表数据 */
 | 
			
		||||
	/**
 | 
			
		||||
	 * 列表数据
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("列表数据")
 | 
			
		||||
	private List<T> rows;
 | 
			
		||||
 | 
			
		||||
    /** 消息状态码 */
 | 
			
		||||
	/**
 | 
			
		||||
	 * 消息状态码
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("消息状态码")
 | 
			
		||||
	private int code;
 | 
			
		||||
 | 
			
		||||
    /** 消息内容 */
 | 
			
		||||
	/**
 | 
			
		||||
	 * 消息内容
 | 
			
		||||
	 */
 | 
			
		||||
	@ApiModelProperty("消息内容")
 | 
			
		||||
	private String msg;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -38,8 +52,7 @@ public class TableDataInfo<T> implements Serializable
 | 
			
		||||
	 * @param list  列表数据
 | 
			
		||||
	 * @param total 总记录数
 | 
			
		||||
	 */
 | 
			
		||||
    public TableDataInfo(List<T> list, long total)
 | 
			
		||||
    {
 | 
			
		||||
	public TableDataInfo(List<T> list, long total) {
 | 
			
		||||
		this.rows = list;
 | 
			
		||||
		this.total = total;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,85 @@
 | 
			
		||||
package com.ruoyi.framework.captcha;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.captcha.generator.CodeGenerator;
 | 
			
		||||
import cn.hutool.core.math.Calculator;
 | 
			
		||||
import cn.hutool.core.util.CharUtil;
 | 
			
		||||
import cn.hutool.core.util.RandomUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 无符号计算生成器
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
public class UnsignedMathGenerator implements CodeGenerator {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -5514819971774091076L;
 | 
			
		||||
 | 
			
		||||
	private static final String operators = "+-*";
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 参与计算数字最大长度
 | 
			
		||||
	 */
 | 
			
		||||
	private final int numberLength;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 构造
 | 
			
		||||
	 */
 | 
			
		||||
	public UnsignedMathGenerator() {
 | 
			
		||||
		this(2);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 构造
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param numberLength 参与计算最大数字位数
 | 
			
		||||
	 */
 | 
			
		||||
	public UnsignedMathGenerator(int numberLength) {
 | 
			
		||||
		this.numberLength = numberLength;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String generate() {
 | 
			
		||||
		final int limit = getLimit();
 | 
			
		||||
		int min = RandomUtil.randomInt(limit);
 | 
			
		||||
		int max = RandomUtil.randomInt(min, limit);
 | 
			
		||||
		String number1 = Integer.toString(max);
 | 
			
		||||
		String number2 = Integer.toString(min);
 | 
			
		||||
		number1 = StrUtil.padAfter(number1, this.numberLength, CharUtil.SPACE);
 | 
			
		||||
		number2 = StrUtil.padAfter(number2, this.numberLength, CharUtil.SPACE);
 | 
			
		||||
 | 
			
		||||
		return number1 + RandomUtil.randomChar(operators) + number2 + '=';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean verify(String code, String userInputCode) {
 | 
			
		||||
		int result;
 | 
			
		||||
		try {
 | 
			
		||||
			result = Integer.parseInt(userInputCode);
 | 
			
		||||
		} catch (NumberFormatException e) {
 | 
			
		||||
			// 用户输入非数字
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		final int calculateResult = (int) Calculator.conversion(code);
 | 
			
		||||
		return result == calculateResult;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取验证码长度
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return 验证码长度
 | 
			
		||||
	 */
 | 
			
		||||
	public int getLength() {
 | 
			
		||||
		return this.numberLength * 2 + 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据长度获取参与计算数字最大值
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return 最大值
 | 
			
		||||
	 */
 | 
			
		||||
	private int getLimit() {
 | 
			
		||||
		return Integer.parseInt("1" + StrUtil.repeat('0', this.numberLength));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -51,7 +51,8 @@ public class SwaggerConfig {
 | 
			
		||||
			.build()
 | 
			
		||||
			/* 设置安全模式,swagger可以设置访问token */
 | 
			
		||||
			.securitySchemes(securitySchemes())
 | 
			
		||||
			.securityContexts(securityContexts());
 | 
			
		||||
			.securityContexts(securityContexts())
 | 
			
		||||
			.pathMapping(swaggerProperties.getPathMapping());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,10 @@ public class SwaggerProperties {
 | 
			
		||||
     * 验证码类型
 | 
			
		||||
     */
 | 
			
		||||
    private Boolean enabled;
 | 
			
		||||
	/**
 | 
			
		||||
	 * 设置请求的统一前缀
 | 
			
		||||
	 */
 | 
			
		||||
	private String pathMapping;
 | 
			
		||||
    /**
 | 
			
		||||
     * 验证码类别
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ import cn.hutool.captcha.CircleCaptcha;
 | 
			
		||||
import cn.hutool.captcha.LineCaptcha;
 | 
			
		||||
import cn.hutool.captcha.ShearCaptcha;
 | 
			
		||||
import cn.hutool.captcha.generator.CodeGenerator;
 | 
			
		||||
import cn.hutool.captcha.generator.MathGenerator;
 | 
			
		||||
import cn.hutool.captcha.generator.RandomGenerator;
 | 
			
		||||
import cn.hutool.core.convert.Convert;
 | 
			
		||||
import cn.hutool.core.util.IdUtil;
 | 
			
		||||
@@ -13,12 +12,15 @@ import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.ruoyi.common.constant.Constants;
 | 
			
		||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
			
		||||
import com.ruoyi.common.core.redis.RedisCache;
 | 
			
		||||
import com.ruoyi.framework.captcha.UnsignedMathGenerator;
 | 
			
		||||
import com.ruoyi.framework.config.properties.CaptchaProperties;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -59,7 +61,7 @@ public class CaptchaController {
 | 
			
		||||
		AbstractCaptcha captcha;
 | 
			
		||||
		switch (captchaProperties.getType()) {
 | 
			
		||||
			case "math":
 | 
			
		||||
				codeGenerator = new MathGenerator(captchaProperties.getNumberLength());
 | 
			
		||||
				codeGenerator = new UnsignedMathGenerator(captchaProperties.getNumberLength());
 | 
			
		||||
				break;
 | 
			
		||||
			case "char":
 | 
			
		||||
				codeGenerator = new RandomGenerator(captchaProperties.getCharLength());
 | 
			
		||||
@@ -88,10 +90,10 @@ public class CaptchaController {
 | 
			
		||||
			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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,8 @@ import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 通用请求处理
 | 
			
		||||
@@ -77,10 +79,10 @@ public class CommonController
 | 
			
		||||
            // 上传并返回新文件名称
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 部门信息
 | 
			
		||||
@@ -89,10 +91,10 @@ public class SysDeptController extends BaseController
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -49,12 +51,12 @@ public class SysLoginController
 | 
			
		||||
    @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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -71,11 +73,11 @@ public class SysLoginController
 | 
			
		||||
        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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 菜单信息
 | 
			
		||||
@@ -78,10 +80,10 @@ public class SysMenuController extends BaseController
 | 
			
		||||
    {
 | 
			
		||||
        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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.*;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 个人信息 业务处理
 | 
			
		||||
@@ -43,10 +45,11 @@ public class SysProfileController extends BaseController
 | 
			
		||||
    {
 | 
			
		||||
        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 @@ public class SysProfileController extends BaseController
 | 
			
		||||
            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("上传图片异常,请联系管理员");
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,9 @@ import org.springframework.validation.annotation.Validated;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -94,17 +96,17 @@ public class SysUserController extends BaseController
 | 
			
		||||
    @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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -187,6 +187,8 @@ mybatis-plus:
 | 
			
		||||
swagger:
 | 
			
		||||
  # 是否开启swagger
 | 
			
		||||
  enabled: true
 | 
			
		||||
  # 请求前缀
 | 
			
		||||
  pathMapping: /dev-api
 | 
			
		||||
  # 标题
 | 
			
		||||
  title: '标题:RuoYi-Vue-Plus后台管理系统_接口文档'
 | 
			
		||||
  # 描述
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user