RuoYi
2025-03-05 3dcee7057dee0a67204dbf528cd4211a925b6142
优化代码
21 files modified
204 ■■■■■ changed files
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/text/Convert.java 6 ●●●●● patch | view | raw | blame | history
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/TableDataInfo.java 2 ●●● patch | view | raw | blame | history
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java 12 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java 22 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/domain.java.vm 4 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm 10 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm 12 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/v3/index-tree.vue.vm 10 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/v3/index.vue.vm 12 ●●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java 2 ●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java 2 ●●● patch | view | raw | blame | history
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml 1 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/assets/styles/index.scss 4 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/assets/styles/ruoyi.scss 15 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/components/Pagination/index.vue 1 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/layout/components/Navbar.vue 4 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/store/modules/permission.js 27 ●●●● patch | view | raw | blame | history
ruoyi-ui/src/utils/ruoyi.js 46 ●●●●● patch | view | raw | blame | history
ruoyi-ui/src/views/index.vue 8 ●●●●● patch | view | raw | blame | history
ruoyi-ui/src/views/system/logininfor/index.vue 2 ●●● patch | view | raw | blame | history
ruoyi-ui/src/views/system/operlog/index.vue 2 ●●● patch | view | raw | blame | history
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/text/Convert.java
@@ -540,9 +540,9 @@
    /**
     * 转换为boolean<br>
     * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
     * String支持的值为:true、false、yes、ok、no、1、0、是、否, 如果给定的值为空,或者转换失败,返回默认值<br>
     * 转换失败不会报错
     *
     *
     * @param value 被转换的值
     * @param defaultValue 转换错误时的默认值
     * @return 结果
@@ -569,10 +569,12 @@
            case "yes":
            case "ok":
            case "1":
            case "是":
                return true;
            case "false":
            case "no":
            case "0":
            case "否":
                return false;
            default:
                return defaultValue;
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/TableDataInfo.java
@@ -37,7 +37,7 @@
     * @param list 列表数据
     * @param total 总记录数
     */
    public TableDataInfo(List<?> list, int total)
    public TableDataInfo(List<?> list, long total)
    {
        this.rows = list;
        this.total = total;
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
@@ -36,11 +36,11 @@
    protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
    private final static long expireTime = CacheConstants.EXPIRATION;
    private final static long TOKEN_EXPIRE_TIME = CacheConstants.EXPIRATION;
    private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
    private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
    private final static Long TOKEN_REFRESH_THRESHOLD_MINUTES = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
    /**
     * 创建令牌
@@ -65,7 +65,7 @@
        // 接口返回信息
        Map<String, Object> rspMap = new HashMap<String, Object>();
        rspMap.put("access_token", JwtUtils.createToken(claimsMap));
        rspMap.put("expires_in", expireTime);
        rspMap.put("expires_in", TOKEN_EXPIRE_TIME);
        return rspMap;
    }
@@ -147,7 +147,7 @@
    {
        long expireTime = loginUser.getExpireTime();
        long currentTime = System.currentTimeMillis();
        if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
        if (expireTime - currentTime <= TOKEN_REFRESH_THRESHOLD_MINUTES)
        {
            refreshToken(loginUser);
        }
@@ -161,10 +161,10 @@
    public void refreshToken(LoginUser loginUser)
    {
        loginUser.setLoginTime(System.currentTimeMillis());
        loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
        loginUser.setExpireTime(loginUser.getLoginTime() + TOKEN_EXPIRE_TIME * MILLIS_MINUTE);
        // 根据uuid将loginUser缓存
        String userKey = getTokenKey(loginUser.getToken());
        redisService.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
        redisService.setCacheObject(userKey, loginUser, TOKEN_EXPIRE_TIME, TimeUnit.MINUTES);
    }
    private String getTokenKey(String token)
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java
@@ -129,9 +129,9 @@
        int row = genTableMapper.updateGenTable(genTable);
        if (row > 0)
        {
            for (GenTableColumn cenTableColumn : genTable.getColumns())
            for (GenTableColumn genTableColumn : genTable.getColumns())
            {
                genTableColumnMapper.updateGenTableColumn(cenTableColumn);
                genTableColumnMapper.updateGenTableColumn(genTableColumn);
            }
        }
    }
@@ -414,16 +414,16 @@
            {
                throw new ServiceException("树名称字段不能为空");
            }
            else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
        }
        else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
        {
            if (StringUtils.isEmpty(genTable.getSubTableName()))
            {
                if (StringUtils.isEmpty(genTable.getSubTableName()))
                {
                    throw new ServiceException("关联子表的表名不能为空");
                }
                else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
                {
                    throw new ServiceException("子表关联的外键名不能为空");
                }
                throw new ServiceException("关联子表的表名不能为空");
            }
            else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
            {
                throw new ServiceException("子表关联的外键名不能为空");
            }
        }
    }
ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/domain.java.vm
@@ -71,9 +71,9 @@
    {
        return $column.javaField;
    }
#end
#end
#end
#end
#if($table.sub)
    public List<${subClassName}> get${subClassName}List()
    {
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm
@@ -75,7 +75,7 @@
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['${moduleName}:${businessName}:add']"
          v-hasPermi="['${permissionPrefix}:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -144,21 +144,21 @@
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['${moduleName}:${businessName}:edit']"
            v-hasPermi="['${permissionPrefix}:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-plus"
            @click="handleAdd(scope.row)"
            v-hasPermi="['${moduleName}:${businessName}:add']"
            v-hasPermi="['${permissionPrefix}:add']"
          >新增</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['${moduleName}:${businessName}:remove']"
            v-hasPermi="['${permissionPrefix}:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
@@ -453,7 +453,7 @@
      this.reset();
      this.getTreeselect();
      if (row != null) {
        this.form.${treeParentCode} = row.${treeCode};
        this.form.${treeParentCode} = row.${treeParentCode};
      }
      get${BusinessName}(row.${pkColumn.javaField}).then(response => {
        this.form = response.data;
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm
@@ -75,7 +75,7 @@
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['${moduleName}:${businessName}:add']"
          v-hasPermi="['${permissionPrefix}:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -86,7 +86,7 @@
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['${moduleName}:${businessName}:edit']"
          v-hasPermi="['${permissionPrefix}:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -97,7 +97,7 @@
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['${moduleName}:${businessName}:remove']"
          v-hasPermi="['${permissionPrefix}:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -107,7 +107,7 @@
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['${moduleName}:${businessName}:export']"
          v-hasPermi="['${permissionPrefix}:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@@ -158,14 +158,14 @@
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['${moduleName}:${businessName}:edit']"
            v-hasPermi="['${permissionPrefix}:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['${moduleName}:${businessName}:remove']"
            v-hasPermi="['${permissionPrefix}:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/v3/index-tree.vue.vm
@@ -73,7 +73,7 @@
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['${moduleName}:${businessName}:add']"
          v-hasPermi="['${permissionPrefix}:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -136,9 +136,9 @@
#end
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
          <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${permissionPrefix}:edit']">修改</el-button>
          <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${permissionPrefix}:add']">新增</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${permissionPrefix}:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -420,7 +420,7 @@
  reset();
  await getTreeselect();
  if (row != null) {
    form.value.${treeParentCode} = row.${treeCode};
    form.value.${treeParentCode} = row.${treeParentCode};
  }
  get${BusinessName}(row.${pkColumn.javaField}).then(response => {
    form.value = response.data;
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/v3/index.vue.vm
@@ -73,7 +73,7 @@
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['${moduleName}:${businessName}:add']"
          v-hasPermi="['${permissionPrefix}:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -83,7 +83,7 @@
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['${moduleName}:${businessName}:edit']"
          v-hasPermi="['${permissionPrefix}:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -93,7 +93,7 @@
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['${moduleName}:${businessName}:remove']"
          v-hasPermi="['${permissionPrefix}:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
@@ -102,7 +102,7 @@
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['${moduleName}:${businessName}:export']"
          v-hasPermi="['${permissionPrefix}:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
@@ -148,8 +148,8 @@
#end
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${permissionPrefix}:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${permissionPrefix}:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
@@ -365,7 +365,7 @@
    /**
     * 获取路由名称,如没有配置路由名称则取路由地址
     * 
     * @param routerName 路由名称
     * @param name 路由名称
     * @param path 路由地址
     * @return 路由名称(驼峰格式)
     */
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java
@@ -73,7 +73,7 @@
                // 多角色设置permissions属性,以便数据权限匹配权限
                for (SysRole role : roles)
                {
                    if (StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL))
                    if (StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && !role.isAdmin())
                    {
                        Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
                        role.setPermissions(rolePerms);
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -146,7 +146,6 @@
         insert into sys_user(
             <if test="userId != null and userId != 0">user_id,</if>
             <if test="deptId != null and deptId != 0">dept_id,</if>
             <if test="userName != null and userName != ''">user_name,</if>
             <if test="nickName != null and nickName != ''">nick_name,</if>
             <if test="email != null and email != ''">email,</if>
             <if test="avatar != null and avatar != ''">avatar,</if>
ruoyi-ui/src/assets/styles/index.scss
@@ -129,10 +129,6 @@
  position: relative;
}
.pagination-container {
  margin-top: 30px;
}
.text-center {
  text-align: center
}
ruoyi-ui/src/assets/styles/ruoyi.scss
@@ -117,11 +117,9 @@
/** 表格布局 **/
.pagination-container {
  position: relative;
  height: 32px;
  margin-bottom: 10px;
  margin-top: 15px;
  padding: 10px 20px !important;
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}
/* tree border */
@@ -130,11 +128,6 @@
  border: 1px solid #e5e6e7;
  background: #FFFFFF none;
  border-radius: 4px;
}
.pagination-container .el-pagination {
  right: 0;
  position: absolute;
}
@media (max-width: 768px) {
@@ -201,8 +194,6 @@
}
.card-box {
  padding-right: 15px;
  padding-left: 15px;
  margin-bottom: 10px;
}
ruoyi-ui/src/components/Pagination/index.vue
@@ -106,7 +106,6 @@
<style scoped>
.pagination-container {
  background: #fff;
  padding: 32px 16px;
}
.pagination-container.hidden {
  display: none;
ruoyi-ui/src/layout/components/Navbar.vue
@@ -2,8 +2,8 @@
  <div class="navbar">
    <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
    <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
    <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>
    <breadcrumb v-if="!topNav" id="breadcrumb-container" class="breadcrumb-container" />
    <top-nav v-if="topNav" id="topmenu-container" class="topmenu-container" />
    <div class="right-menu">
      <template v-if="device!=='mobile'">
ruoyi-ui/src/store/modules/permission.js
@@ -82,28 +82,13 @@
function filterChildren(childrenMap, lastRouter = false) {
  var children = []
  childrenMap.forEach((el, index) => {
    if (el.children && el.children.length) {
      if (el.component === 'ParentView' && !lastRouter) {
        el.children.forEach(c => {
          c.path = el.path + '/' + c.path
          if (c.children && c.children.length) {
            children = children.concat(filterChildren(c.children, c))
            return
          }
          children.push(c)
        })
        return
      }
  childrenMap.forEach(el => {
    el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
    if (el.children && el.children.length && el.component === 'ParentView') {
      children = children.concat(filterChildren(el.children, el))
    } else {
      children.push(el)
    }
    if (lastRouter) {
      el.path = lastRouter.path + '/' + el.path
      if (el.children && el.children.length) {
        children = children.concat(filterChildren(el.children, el))
        return
      }
    }
    children = children.concat(el)
  })
  return children
}
ruoyi-ui/src/utils/ruoyi.js
@@ -1,5 +1,3 @@
/**
 * 通用js方法封装处理
 * Copyright (c) 2019 ruoyi
@@ -165,37 +163,19 @@
  };
  var childrenListMap = {};
  var nodeIds = {};
  var tree = [];
  for (let d of data) {
    let parentId = d[config.parentId];
    if (childrenListMap[parentId] == null) {
      childrenListMap[parentId] = [];
    }
    nodeIds[d[config.id]] = d;
    childrenListMap[parentId].push(d);
    let id = d[config.id];
    childrenListMap[id] = d;
  }
  for (let d of data) {
    let parentId = d[config.parentId];
    if (nodeIds[parentId] == null) {
    let parentId = d[config.parentId]
    let parentObj = childrenListMap[parentId]
    if (!parentObj) {
      tree.push(d);
    }
  }
  for (let t of tree) {
    adaptToChildrenList(t);
  }
  function adaptToChildrenList(o) {
    if (childrenListMap[o[config.id]] !== null) {
      o[config.childrenList] = childrenListMap[o[config.id]];
    }
    if (o[config.childrenList]) {
      for (let c of o[config.childrenList]) {
        adaptToChildrenList(c);
      }
    } else {
      parentObj[config.childrenList].push(d)
    }
  }
  return tree;
@@ -227,6 +207,18 @@
  return result
}
// 返回项目路径
export function getNormalPath(p) {
  if (p.length === 0 || !p || p == 'undefined') {
    return p
  };
  let res = p.replace('//', '/')
  if (res[res.length - 1] === '/') {
    return res.slice(0, res.length - 1)
  }
  return res
}
// 验证是否为blob格式
export function blobValidate(data) {
  return data.type !== 'application/json'
ruoyi-ui/src/views/index.vue
@@ -1,14 +1,6 @@
<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :sm="24" :lg="24">
        <blockquote class="text-warning" style="font-size: 14px">
          阿里云服务器折扣区<el-link href="http://aly.ruoyi.vip" type="primary" target="_blank">☛☛点我进入☚☚</el-link> &nbsp;&nbsp;&nbsp; 腾讯云服务器秒杀区<el-link href="http://txy.ruoyi.vip" type="primary" target="_blank">☛☛点我进入☚☚</el-link>
        </blockquote>
        <hr />
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>若依后台管理框架</h2>
        <p>
ruoyi-ui/src/views/system/logininfor/index.vue
@@ -153,7 +153,7 @@
      // 日期范围
      dateRange: [],
      // 默认排序
      defaultSort: {prop: 'accessTime', order: 'descending'},
      defaultSort: { prop: "accessTime", order: "descending" },
      // 查询参数
      queryParams: {
        pageNum: 1,
ruoyi-ui/src/views/system/operlog/index.vue
@@ -231,7 +231,7 @@
      // 日期范围
      dateRange: [],
      // 默认排序
      defaultSort: {prop: 'operTime', order: 'descending'},
      defaultSort: { prop: "operTime", order: "descending" },
      // 表单参数
      form: {},
      // 查询参数