脚本管理页面增加字段、执行结果根据失败关键字筛选
优化菜单点击方法、优化心跳处理
This commit is contained in:
+3
-3
@@ -29,10 +29,10 @@ public class SysMenuClickController extends BaseController
|
||||
* 查询菜单点击计数列表
|
||||
*/
|
||||
@RequiresPermissions("system:sysMenuClick:list")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysMenuClick sysMenuClick)
|
||||
@GetMapping("/getMenuListTopEight")
|
||||
public AjaxResult list()
|
||||
{
|
||||
List<SysMenuClick> list = sysMenuClickService.selectSysMenuClickList(sysMenuClick);
|
||||
List<SysMenuClick> list = sysMenuClickService.selectSysMenuClickList();
|
||||
return success(list);
|
||||
}
|
||||
/**
|
||||
|
||||
+3
@@ -29,4 +29,7 @@ public class EpsBusinessScript extends BaseEntity
|
||||
/** 脚本默认参数 */
|
||||
@Excel(name = "脚本默认参数")
|
||||
private String defaultParams;
|
||||
/** 结果失败判断关键字 */
|
||||
@Excel(name = "结果失败判断关键字")
|
||||
private String failedKeywords;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 菜单点击计数对象 sys_menu_click
|
||||
@@ -13,6 +13,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
* @author gyt
|
||||
* @date 2025-11-12
|
||||
*/
|
||||
@Data
|
||||
public class SysMenuClick extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -37,69 +38,4 @@ public class SysMenuClick extends BaseEntity
|
||||
@Excel(name = "最后点击时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date lastClickTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setPageRoute(String pageRoute)
|
||||
{
|
||||
this.pageRoute = pageRoute;
|
||||
}
|
||||
|
||||
public String getPageRoute()
|
||||
{
|
||||
return pageRoute;
|
||||
}
|
||||
|
||||
public void setPageName(String pageName)
|
||||
{
|
||||
this.pageName = pageName;
|
||||
}
|
||||
|
||||
public String getPageName()
|
||||
{
|
||||
return pageName;
|
||||
}
|
||||
|
||||
public void setClickCount(Long clickCount)
|
||||
{
|
||||
this.clickCount = clickCount;
|
||||
}
|
||||
|
||||
public Long getClickCount()
|
||||
{
|
||||
return clickCount;
|
||||
}
|
||||
|
||||
public void setLastClickTime(Date lastClickTime)
|
||||
{
|
||||
this.lastClickTime = lastClickTime;
|
||||
}
|
||||
|
||||
public Date getLastClickTime()
|
||||
{
|
||||
return lastClickTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("pageRoute", getPageRoute())
|
||||
.append("pageName", getPageName())
|
||||
.append("clickCount", getClickCount())
|
||||
.append("lastClickTime", getLastClickTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.SysMenuClick;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单点击计数Service接口
|
||||
*
|
||||
@@ -25,7 +26,7 @@ public interface ISysMenuClickService
|
||||
* @param sysMenuClick 菜单点击计数
|
||||
* @return 菜单点击计数集合
|
||||
*/
|
||||
public List<SysMenuClick> selectSysMenuClickList(SysMenuClick sysMenuClick);
|
||||
public List<SysMenuClick> selectSysMenuClickList();
|
||||
|
||||
/**
|
||||
* 新增菜单点击计数
|
||||
|
||||
+10
-2
@@ -1,11 +1,12 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import com.ruoyi.system.domain.SysMenu;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
import com.ruoyi.system.domain.vo.TreeSelect;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单 业务层
|
||||
*
|
||||
@@ -141,4 +142,11 @@ public interface ISysMenuService
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkMenuNameUnique(SysMenu menu);
|
||||
/**
|
||||
* 根据用户查询系统菜单列表--权限控制前
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> getMenuListByWelcome(Long userId);
|
||||
}
|
||||
|
||||
+35
-2
@@ -1,13 +1,19 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.domain.SysMenu;
|
||||
import com.ruoyi.system.domain.SysMenuClick;
|
||||
import com.ruoyi.system.mapper.SysMenuClickMapper;
|
||||
import com.ruoyi.system.service.ISysMenuClickService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单点击计数Service业务层处理
|
||||
@@ -20,6 +26,8 @@ public class SysMenuClickServiceImpl implements ISysMenuClickService
|
||||
{
|
||||
@Autowired
|
||||
private SysMenuClickMapper sysMenuClickMapper;
|
||||
@Autowired
|
||||
private ISysMenuService sysMenuService;
|
||||
|
||||
/**
|
||||
* 查询菜单点击计数
|
||||
@@ -40,9 +48,34 @@ public class SysMenuClickServiceImpl implements ISysMenuClickService
|
||||
* @return 菜单点击计数
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuClick> selectSysMenuClickList(SysMenuClick sysMenuClick)
|
||||
public List<SysMenuClick> selectSysMenuClickList()
|
||||
{
|
||||
return sysMenuClickMapper.selectSysMenuClickList(sysMenuClick);
|
||||
List<SysMenuClick> menuClickList = sysMenuClickMapper.selectSysMenuClickList(new SysMenuClick());
|
||||
// 获取当前用户有权限的菜单列表
|
||||
List<SysMenu> permittedMenus = getPermittedMenusForCurrentUser();
|
||||
Set<String> permittedMenuIds = permittedMenus.stream()
|
||||
.map(SysMenu::getMenuName)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 过滤有权限的菜单
|
||||
List<SysMenuClick> permittedPopularMenus = menuClickList.stream()
|
||||
.filter(menu -> permittedMenuIds.contains(menu.getPageName()))
|
||||
.limit(8) // 取前8个
|
||||
.collect(Collectors.toList());
|
||||
return permittedPopularMenus;
|
||||
}
|
||||
/**
|
||||
* 获取当前用户有权限的菜单
|
||||
*/
|
||||
private List<SysMenu> getPermittedMenusForCurrentUser() {
|
||||
// 使用Ruoyi的权限服务(推荐)
|
||||
if (SecurityUtils.getLoginUser() != null) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return sysMenuService.getMenuListByWelcome(userId);
|
||||
}
|
||||
|
||||
// 如果是匿名访问,返回空列表
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+28
-10
@@ -1,15 +1,5 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
@@ -24,6 +14,11 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单 业务层处理
|
||||
@@ -540,4 +535,27 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" },
|
||||
new String[] { "", "", "", "/", "/" });
|
||||
}
|
||||
/**
|
||||
* 根据用户查询系统菜单列表--欢迎页
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> getMenuListByWelcome(Long userId)
|
||||
{
|
||||
SysMenu menu = new SysMenu();
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (userId == 1L)
|
||||
{
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-9
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.EpsBusinessScriptMapper">
|
||||
|
||||
|
||||
<resultMap type="EpsBusinessScript" id="EpsBusinessScriptResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="scriptName" column="script_name" />
|
||||
<result property="scriptPath" column="script_path" />
|
||||
<result property="defaultParams" column="default_params" />
|
||||
<result property="failedKeywords" column="failed_keywords" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
@@ -16,18 +17,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEpsBusinessScriptVo">
|
||||
select id, script_name, script_path, default_params, create_time, update_time, create_by, update_by from eps_business_script
|
||||
select id, script_name, script_path, default_params, failed_keywords, create_time, update_time, create_by, update_by from eps_business_script
|
||||
</sql>
|
||||
|
||||
<select id="selectEpsBusinessScriptList" parameterType="EpsBusinessScript" resultMap="EpsBusinessScriptResult">
|
||||
<include refid="selectEpsBusinessScriptVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="scriptName != null and scriptName != ''"> and script_name like concat('%', #{scriptName}, '%')</if>
|
||||
<if test="scriptPath != null and scriptPath != ''"> and script_path = #{scriptPath}</if>
|
||||
<if test="defaultParams != null and defaultParams != ''"> and default_params = #{defaultParams}</if>
|
||||
<if test="failedKeywords != null and failedKeywords != ''"> and failed_keywords = #{failedKeywords}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectEpsBusinessScriptById" parameterType="Long" resultMap="EpsBusinessScriptResult">
|
||||
<include refid="selectEpsBusinessScriptVo"/>
|
||||
where id = #{id}
|
||||
@@ -39,20 +41,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="scriptName != null">script_name,</if>
|
||||
<if test="scriptPath != null">script_path,</if>
|
||||
<if test="defaultParams != null">default_params,</if>
|
||||
<if test="failedKeywords != null">failed_keywords,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="scriptName != null">#{scriptName},</if>
|
||||
<if test="scriptPath != null">#{scriptPath},</if>
|
||||
<if test="defaultParams != null">#{defaultParams},</if>
|
||||
<if test="failedKeywords != null">#{failedKeywords},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEpsBusinessScript" parameterType="EpsBusinessScript">
|
||||
@@ -61,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="scriptName != null">script_name = #{scriptName},</if>
|
||||
<if test="scriptPath != null">script_path = #{scriptPath},</if>
|
||||
default_params = #{defaultParams},
|
||||
failed_keywords = #{failedKeywords},
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
@@ -74,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEpsBusinessScriptByIds" parameterType="String">
|
||||
delete from eps_business_script where id in
|
||||
delete from eps_business_script where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
@@ -30,7 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="lastClickTime != null "> and last_click_time = #{lastClickTime}</if>
|
||||
</where>
|
||||
order by click_count desc
|
||||
limit 8
|
||||
</select>
|
||||
|
||||
<select id="selectSysMenuClickById" parameterType="Long" resultMap="SysMenuClickResult">
|
||||
|
||||
Reference in New Issue
Block a user