mirror of https://gitee.com/stylefeng/guns
Merge branch 'master' of https://git.stylefeng.cn/guns-technology/guns-standalone-beetl into group1-dict
commit
04a76c1409
24
pom.xml
24
pom.xml
|
@ -25,17 +25,18 @@
|
|||
<java.version>1.8</java.version>
|
||||
<mysql-connector-java.version>8.0.21</mysql-connector-java.version>
|
||||
<docker.img.version>latest</docker.img.version>
|
||||
<oshi.version>3.9.1</oshi.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.ibeetl/beetl -->
|
||||
<dependency>
|
||||
<groupId>com.ibeetl</groupId>
|
||||
<artifactId>beetl</artifactId>
|
||||
<version>3.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>auth-spring-boot-starter</artifactId>
|
||||
|
@ -101,6 +102,12 @@
|
|||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>timer-spring-boot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
|
@ -123,7 +130,22 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!--硬件信息获取-->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
package cn.stylefeng.guns.config.web;
|
||||
|
||||
import com.alibaba.druid.filter.stat.StatFilter;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator;
|
||||
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.aop.support.JdkRegexpMethodPointcut;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Druid配置
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/11 10:23
|
||||
*/
|
||||
@Configuration
|
||||
public class DruidConfiguration {
|
||||
|
||||
/**
|
||||
* druidServlet注册
|
||||
*/
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServletRegistration() {
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
|
||||
registration.addUrlMappings("/druid/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
/**
|
||||
* druid监控 配置URI拦截策略
|
||||
*/
|
||||
@Bean
|
||||
public FilterRegistrationBean druidStatFilter() {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
|
||||
//添加过滤规则.
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
//添加不需要忽略的格式信息.
|
||||
filterRegistrationBean.addInitParameter(
|
||||
"exclusions", "/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*");
|
||||
//用于session监控页面的用户名显示 需要登录后主动将username注入到session里
|
||||
filterRegistrationBean.addInitParameter("principalSessionName", "username");
|
||||
filterRegistrationBean.addInitParameter("profileEnable", "true");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* druid数据库连接池监控
|
||||
*/
|
||||
@Bean
|
||||
public DruidStatInterceptor druidStatInterceptor() {
|
||||
return new DruidStatInterceptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* druid慢sql监控
|
||||
*/
|
||||
@Bean
|
||||
public StatFilter druidSlowSQL(){
|
||||
StatFilter statFilter = new StatFilter();
|
||||
statFilter.setLogSlowSql(true);
|
||||
statFilter.setMergeSql(true);
|
||||
statFilter.setSlowSqlMillis(1000);
|
||||
return statFilter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public JdkRegexpMethodPointcut druidStatPointcut() {
|
||||
JdkRegexpMethodPointcut druidStatPointcut = new JdkRegexpMethodPointcut();
|
||||
String patterns = "cn.stylefeng.guns.modular.*.service.*";
|
||||
//可以set多个
|
||||
druidStatPointcut.setPatterns(patterns);
|
||||
return druidStatPointcut;
|
||||
}
|
||||
|
||||
/**
|
||||
* druid数据库连接池监控
|
||||
*/
|
||||
@Bean
|
||||
public BeanTypeAutoProxyCreator beanTypeAutoProxyCreator() {
|
||||
BeanTypeAutoProxyCreator beanTypeAutoProxyCreator = new BeanTypeAutoProxyCreator();
|
||||
beanTypeAutoProxyCreator.setTargetBeanType(DruidDataSource.class);
|
||||
beanTypeAutoProxyCreator.setInterceptorNames("druidStatInterceptor");
|
||||
return beanTypeAutoProxyCreator;
|
||||
}
|
||||
|
||||
/**
|
||||
* druid 为druidStatPointcut添加拦截
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Advisor druidStatAdvisor() {
|
||||
return new DefaultPointcutAdvisor(druidStatPointcut(), druidStatInterceptor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除监控页面广告
|
||||
*
|
||||
* @author chenli
|
||||
* @Date 2021/1/4 20:57
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Bean
|
||||
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
|
||||
// 获取web监控页面的参数
|
||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||
// 提取common.js的配置路径
|
||||
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
|
||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||
final String filePath = "support/http/resources/js/common.js";
|
||||
Filter filter = new Filter() {
|
||||
@Override
|
||||
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
chain.doFilter(request, response);
|
||||
String text = Utils.readFromResource(filePath);
|
||||
// 正则替换banner, 除去底部的广告信息
|
||||
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
|
||||
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
||||
text = text.replaceAll("<div.*?container\"></div>", "");
|
||||
text = text.replaceAll("<footer.*?footer\"></footer>", "");
|
||||
response.getWriter().write(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
};
|
||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||
registrationBean.setFilter(filter);
|
||||
registrationBean.addUrlPatterns(commonJsPattern);
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package cn.stylefeng.guns.core.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* ip工具类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2018/9/27 上午10:47
|
||||
*/
|
||||
public class IpInfoUtils {
|
||||
|
||||
/**
|
||||
* 获取客户端IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
if (ip.equals("127.0.0.1")) {
|
||||
//根据网卡取本机配置的IP
|
||||
InetAddress inet = null;
|
||||
try {
|
||||
inet = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ip = inet.getHostAddress();
|
||||
}
|
||||
}
|
||||
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
if (ip != null && ip.length() > 15) {
|
||||
if (ip.indexOf(",") > 0) {
|
||||
ip = ip.substring(0, ip.indexOf(","));
|
||||
}
|
||||
}
|
||||
|
||||
if ("0:0:0:0:0:0:0:1".equals(ip)) {
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端主机名称
|
||||
*/
|
||||
public static String getHostName() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.guns.modular.log;
|
||||
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 操作业务日志管理控制器界面渲染
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @author TSQ
|
||||
* @date 2021/1/5 14:44
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
@ApiResource(name = "操作日志管理相关的界面渲染", path = "/view/log")
|
||||
public class LogViewController {
|
||||
|
||||
private String PREFIX = "/modular/system/log";
|
||||
|
||||
/**
|
||||
* 操作日志管理列表
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @author TSQ
|
||||
* @date 2021/1/5 15:18
|
||||
*/
|
||||
@GetResource(name="操作日志管理列表", path ="", requiredPermission = false, requiredLogin = false)
|
||||
public String indexView(){
|
||||
return PREFIX + "/log.html";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.guns.modular.log;
|
||||
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 登陆日志管理控制器界面渲染
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @author TSQ
|
||||
* @date 2021/1/5 14:42
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
@ApiResource(name = "登陆日志管理相关的界面渲染", path = "loginLog")
|
||||
public class LoginLogViewController {
|
||||
|
||||
private String PREFIX = "/modular/system/log";
|
||||
|
||||
/**
|
||||
* 登陆日志管理列表
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @author TSQ
|
||||
* @date 2021/1/5 15:17
|
||||
*/
|
||||
@GetResource(name="登陆日志管理列表" , path = "", requiredPermission = false ,requiredLogin = false)
|
||||
public String indexView(){
|
||||
return PREFIX + "/login_log.html";
|
||||
}
|
||||
|
||||
}
|
|
@ -60,4 +60,26 @@ public class RoleViewController {
|
|||
return "/modular/auth/role/role_edit_data_scope.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配接口界面
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 11:43
|
||||
*/
|
||||
@GetResource(name = "分配接口界面", path = "/view/role/assignApi")
|
||||
public String roleAssignApi() {
|
||||
return "/modular/auth/role/role_assign_api.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配菜单和按钮界面
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 11:45
|
||||
*/
|
||||
@GetResource(name = "分配菜单界面", path = "/view/role/assignMenuAndButtons")
|
||||
public String roleAssignMenuButton() {
|
||||
return "/modular/auth/role/role_assign_menu_button.html";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package cn.stylefeng.guns.modular.system.controller;
|
||||
|
||||
import cn.stylefeng.guns.modular.system.warpper.SystemHardwareWarpper;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
/**
|
||||
* 项目监控
|
||||
*
|
||||
* @author chenli
|
||||
* @Date 2020/12/30 16:40
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
@ApiResource(name = "项目监控")
|
||||
public class MonitorController {
|
||||
|
||||
private String PREFIX = "/modular/frame";
|
||||
|
||||
@Value("${server.port}")
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 系统硬件信息页面
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2018/12/24 22:43
|
||||
*/
|
||||
@GetResource(name = "服务器监控", path = "/monitor/systemInfo", requiredPermission = false)
|
||||
public String systemInfo(Model model) {
|
||||
SystemHardwareWarpper systemHardwareWarpper = new SystemHardwareWarpper();
|
||||
systemHardwareWarpper.copyTo();
|
||||
model.addAttribute("server",systemHardwareWarpper);
|
||||
return PREFIX+"/systemInfo.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* durid sql监控页面
|
||||
*
|
||||
* @author chenli
|
||||
* @Date 2021/1/4 16:32
|
||||
*/
|
||||
@GetResource(name = "SQL监控", path = "/monitor/druid", requiredPermission = false,requiredLogin = false)
|
||||
public String duridInfo(Model model){
|
||||
model.addAttribute("port",port);
|
||||
return PREFIX+"/druid.html";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package cn.stylefeng.guns.modular.system.model;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Setter
|
||||
public class CpuInfo {
|
||||
|
||||
/**
|
||||
* 核心数
|
||||
*/
|
||||
private int cpuNum;
|
||||
|
||||
/**
|
||||
* CPU总的使用率
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* CPU系统使用率
|
||||
*/
|
||||
private double sys;
|
||||
|
||||
/**
|
||||
* CPU用户使用率
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* CPU当前等待率
|
||||
*/
|
||||
private double wait;
|
||||
|
||||
/**
|
||||
* CPU当前空闲率
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public int getCpuNum() {
|
||||
return cpuNum;
|
||||
}
|
||||
|
||||
public double getTotal() {
|
||||
return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue();
|
||||
}
|
||||
|
||||
public double getSys() {
|
||||
return NumberUtil.round(NumberUtil.mul(sys / total, 100), 2).doubleValue();
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return NumberUtil.round(NumberUtil.mul(used / total, 100), 2).doubleValue();
|
||||
}
|
||||
|
||||
public double getWait() {
|
||||
return NumberUtil.round(NumberUtil.mul(wait / total, 100), 2).doubleValue();
|
||||
}
|
||||
|
||||
public double getFree() {
|
||||
return NumberUtil.round(NumberUtil.mul(free / total, 100), 2).doubleValue();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package cn.stylefeng.guns.modular.system.model;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* JVM相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Setter
|
||||
public class JvmInfo {
|
||||
/**
|
||||
* 当前JVM占用的内存总数(M)
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* JVM最大可用内存总数(M)
|
||||
*/
|
||||
private double max;
|
||||
|
||||
/**
|
||||
* JVM空闲内存(M)
|
||||
*/
|
||||
private double free;
|
||||
|
||||
/**
|
||||
* JDK版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* JDK路径
|
||||
*/
|
||||
private String home;
|
||||
|
||||
public double getTotal() {
|
||||
return NumberUtil.div(total, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return NumberUtil.div(max, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getFree() {
|
||||
return NumberUtil.div(free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return NumberUtil.div(total - free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getHome() {
|
||||
return home;
|
||||
}
|
||||
|
||||
public double getUsage() {
|
||||
return NumberUtil.mul(NumberUtil.div(total - free, total, 4), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JDK名称
|
||||
*/
|
||||
public String getName() {
|
||||
return ManagementFactory.getRuntimeMXBean().getVmName();
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK启动时间
|
||||
*/
|
||||
public String getStartTime() {
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
Date date = new Date(time);
|
||||
return DateUtil.formatDateTime(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK运行时间
|
||||
*/
|
||||
public String getRunTime() {
|
||||
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
Date date = new Date(time);
|
||||
|
||||
//运行多少分钟
|
||||
long runMS = DateUtil.between(date, new Date(), DateUnit.MS);
|
||||
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
|
||||
long day = runMS / nd;
|
||||
long hour = runMS % nd / nh;
|
||||
long min = runMS % nd % nh / nm;
|
||||
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package cn.stylefeng.guns.modular.system.model;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Setter
|
||||
public class MemInfo {
|
||||
/**
|
||||
* 内存总量
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* 已用内存
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* 剩余内存
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public double getTotal() {
|
||||
return NumberUtil.div(total, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getUsed() {
|
||||
return NumberUtil.div(used, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
|
||||
public double getFree() {
|
||||
return NumberUtil.div(free, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getUsage() {
|
||||
return NumberUtil.mul(NumberUtil.div(used, total, 4), 100);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package cn.stylefeng.guns.modular.system.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 系统文件相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Data
|
||||
public class SysFileInfo {
|
||||
|
||||
/**
|
||||
* 盘符路径
|
||||
*/
|
||||
private String dirName;
|
||||
|
||||
/**
|
||||
* 盘符类型
|
||||
*/
|
||||
private String sysTypeName;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 总大小
|
||||
*/
|
||||
private String total;
|
||||
|
||||
/**
|
||||
* 剩余大小
|
||||
*/
|
||||
private String free;
|
||||
|
||||
/**
|
||||
* 已经使用量
|
||||
*/
|
||||
private String used;
|
||||
|
||||
/**
|
||||
* 资源的使用率
|
||||
*/
|
||||
private double usage;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.stylefeng.guns.modular.system.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 系统相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Data
|
||||
public class SysInfo {
|
||||
|
||||
/**
|
||||
* 服务器名称
|
||||
*/
|
||||
private String computerName;
|
||||
|
||||
/**
|
||||
* 服务器Ip
|
||||
*/
|
||||
private String computerIp;
|
||||
|
||||
/**
|
||||
* 项目路径
|
||||
*/
|
||||
private String userDir;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 系统架构
|
||||
*/
|
||||
private String osArch;
|
||||
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
package cn.stylefeng.guns.modular.system.warpper;
|
||||
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.stylefeng.guns.core.util.IpInfoUtils;
|
||||
import cn.stylefeng.guns.modular.system.model.*;
|
||||
import lombok.Data;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.CentralProcessor.TickType;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.software.os.FileSystem;
|
||||
import oshi.software.os.OSFileStore;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.Util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @Date 2019-07-13 13:42
|
||||
*/
|
||||
@Data
|
||||
public class SystemHardwareWarpper {
|
||||
|
||||
private static final int OSHI_WAIT_SECOND = 1000;
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*/
|
||||
private CpuInfo cpu = new CpuInfo();
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*/
|
||||
private MemInfo mem = new MemInfo();
|
||||
|
||||
/**
|
||||
* JVM相关信息
|
||||
*/
|
||||
private JvmInfo jvm = new JvmInfo();
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*/
|
||||
private SysInfo sys = new SysInfo();
|
||||
|
||||
/**
|
||||
* 磁盘相关信息
|
||||
*/
|
||||
private List<SysFileInfo> sysFiles = new LinkedList<>();
|
||||
|
||||
public void copyTo() {
|
||||
SystemInfo si = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
|
||||
setCpuInfo(hal.getProcessor());
|
||||
|
||||
setMemInfo(hal.getMemory());
|
||||
|
||||
setSysInfo();
|
||||
|
||||
setJvmInfo();
|
||||
|
||||
setSysFiles(si.getOperatingSystem());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置CPU信息
|
||||
*/
|
||||
private void setCpuInfo(CentralProcessor processor) {
|
||||
// CPU信息
|
||||
long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
Util.sleep(OSHI_WAIT_SECOND);
|
||||
long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()];
|
||||
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];
|
||||
long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()];
|
||||
long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()];
|
||||
long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()];
|
||||
long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()];
|
||||
long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()];
|
||||
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
|
||||
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
|
||||
cpu.setCpuNum(processor.getLogicalProcessorCount());
|
||||
cpu.setTotal(totalCpu);
|
||||
cpu.setSys(cSys);
|
||||
cpu.setUsed(user);
|
||||
cpu.setWait(iowait);
|
||||
cpu.setFree(idle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置内存信息
|
||||
*/
|
||||
private void setMemInfo(GlobalMemory memory) {
|
||||
mem.setTotal(memory.getTotal());
|
||||
mem.setUsed(memory.getTotal() - memory.getAvailable());
|
||||
mem.setFree(memory.getAvailable());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置服务器信息
|
||||
*/
|
||||
private void setSysInfo() {
|
||||
Properties props = System.getProperties();
|
||||
sys.setComputerName(IpInfoUtils.getHostName());
|
||||
sys.setComputerIp(NetUtil.getLocalhostStr());
|
||||
sys.setOsName(props.getProperty("os.name"));
|
||||
sys.setOsArch(props.getProperty("os.arch"));
|
||||
sys.setUserDir(props.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Java虚拟机
|
||||
*/
|
||||
private void setJvmInfo() {
|
||||
Properties props = System.getProperties();
|
||||
jvm.setTotal(Runtime.getRuntime().totalMemory());
|
||||
jvm.setMax(Runtime.getRuntime().maxMemory());
|
||||
jvm.setFree(Runtime.getRuntime().freeMemory());
|
||||
jvm.setVersion(props.getProperty("java.version"));
|
||||
jvm.setHome(props.getProperty("java.home"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置磁盘信息
|
||||
*/
|
||||
private void setSysFiles(OperatingSystem os) {
|
||||
FileSystem fileSystem = os.getFileSystem();
|
||||
OSFileStore[] fsArray = fileSystem.getFileStores();
|
||||
for (OSFileStore fs : fsArray) {
|
||||
long free = fs.getUsableSpace();
|
||||
long total = fs.getTotalSpace();
|
||||
long used = total - free;
|
||||
SysFileInfo sysFile = new SysFileInfo();
|
||||
sysFile.setDirName(fs.getMount());
|
||||
sysFile.setSysTypeName(fs.getType());
|
||||
sysFile.setTypeName(fs.getName());
|
||||
sysFile.setTotal(convertFileSize(total));
|
||||
sysFile.setFree(convertFileSize(free));
|
||||
sysFile.setUsed(convertFileSize(used));
|
||||
|
||||
if (total == 0) {
|
||||
sysFile.setUsage(0);
|
||||
} else {
|
||||
sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
|
||||
}
|
||||
|
||||
sysFiles.add(sysFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节转换
|
||||
*
|
||||
* @param size 字节大小
|
||||
* @return 转换后值
|
||||
*/
|
||||
public String convertFileSize(long size) {
|
||||
long kb = 1024;
|
||||
long mb = kb * 1024;
|
||||
long gb = mb * 1024;
|
||||
if (size >= gb) {
|
||||
return String.format("%.1f GB", (float) size / gb);
|
||||
} else if (size >= mb) {
|
||||
float f = (float) size / mb;
|
||||
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
|
||||
} else if (size >= kb) {
|
||||
float f = (float) size / kb;
|
||||
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
|
||||
} else {
|
||||
return String.format("%d B", size);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package cn.stylefeng.guns.modular.timer;
|
||||
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 定时控制器
|
||||
*
|
||||
* @author youyongkun
|
||||
* @date 2021/1/6 3:56 下午
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
@ApiResource(name = "定时管理相关的界面渲染", path = "/sysTimers")
|
||||
public class TimersViewController {
|
||||
|
||||
private String PREFIX = "/modular/system/timers";
|
||||
|
||||
/**
|
||||
* 定时管理-首页-视图
|
||||
*
|
||||
* @author youyongkun
|
||||
* @date 2021/1/6 4:28 下午
|
||||
*/
|
||||
@GetResource(name = "定时管理-首页-视图", path = "", requiredPermission = false, requiredLogin = false)
|
||||
public String indexView() {
|
||||
return PREFIX + "/timers.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时管理-添加-视图
|
||||
*
|
||||
* @author youyongkun
|
||||
* @date 2021/1/6 4:28 下午
|
||||
*/
|
||||
@GetResource(name = "定时管理-添加-视图", path = "/addView", requiredPermission = false, requiredLogin = false)
|
||||
public String addView() {
|
||||
return PREFIX + "/timers_add.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时管理-修改-视图
|
||||
*
|
||||
* @author youyongkun
|
||||
* @date 2021/1/6 4:28 下午
|
||||
*/
|
||||
@GetResource(name = "定时管理-修改-视图", path = "editView", requiredPermission = false, requiredLogin = false)
|
||||
public String editView() {
|
||||
return PREFIX + "/timers_edit.html";
|
||||
}
|
||||
}
|
|
@ -8,4 +8,4 @@ spring:
|
|||
|
||||
# 连接池大小根据实际情况调整
|
||||
max-active: 100
|
||||
max-pool-prepared-statement-per-connection-size: 100
|
||||
max-pool-prepared-statement-per-connection-size: 100
|
||||
|
|
|
@ -8,4 +8,4 @@ spring:
|
|||
|
||||
# 连接池大小根据实际情况调整
|
||||
max-active: 100
|
||||
max-pool-prepared-statement-per-connection-size: 100
|
||||
max-pool-prepared-statement-per-connection-size: 100
|
||||
|
|
|
@ -20,7 +20,8 @@ spring:
|
|||
locale: zh_CN
|
||||
serialization:
|
||||
indent_output: false
|
||||
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
scanner:
|
||||
open: true
|
||||
sys-log:
|
||||
|
|
|
@ -76,9 +76,9 @@ layui.use(['table', 'HttpRequest', 'func'], function () {
|
|||
*/
|
||||
Resource.openDetailDlg = function (data) {
|
||||
func.open({
|
||||
height: 500,
|
||||
height: 600,
|
||||
title: '资源详情',
|
||||
content: Feng.ctxPath + '/view/resource/detail?resourceId=' + data.resourceId,
|
||||
content: Feng.ctxPath + '/view/resource/detail?resourceCode=' + data.resourceCode,
|
||||
tableId: Resource.tableId
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* 详情对话框
|
||||
*/
|
||||
var ResourceInfoDlg = {
|
||||
data: {
|
||||
resourceParentId: "",
|
||||
resourceParentName: ""
|
||||
}
|
||||
};
|
||||
|
||||
layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'iconPicker'], function () {
|
||||
var $ = layui.jquery;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var form = layui.form;
|
||||
|
||||
//获取菜单信息
|
||||
var request = new HttpRequest(Feng.ctxPath + "/resource/getDetail?resourceCode=" + Feng.getUrlParam("resourceCode"), 'get');
|
||||
var resourceInfoResult = request.start();
|
||||
form.val('resourceForm', resourceInfoResult.data);
|
||||
});
|
|
@ -131,21 +131,32 @@ layui.use(['layer', 'form', 'table', 'admin', 'HttpRequest', 'func'], function (
|
|||
};
|
||||
|
||||
/**
|
||||
* 分配菜单
|
||||
* 分配菜单和按钮
|
||||
*
|
||||
* @param data 点击按钮时候的行数据
|
||||
*/
|
||||
Role.roleAssign = function (data) {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: '权限配置',
|
||||
area: ['300px', '450px'], //宽高
|
||||
fix: false,
|
||||
maxmin: true,
|
||||
content: Feng.ctxPath + '/role/role_assign/' + data.roleId,
|
||||
end: function () {
|
||||
table.reload(Role.tableId);
|
||||
}
|
||||
Role.assignMenu = function (data) {
|
||||
func.open({
|
||||
height: 650,
|
||||
width: 750,
|
||||
title: '分配菜单',
|
||||
content: Feng.ctxPath + "/view/role/assignMenuAndButtons?roleId=" + data.roleId,
|
||||
tableId: Role.tableId
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 分配接口
|
||||
*
|
||||
* @param data 点击按钮时候的行数据
|
||||
*/
|
||||
Role.assignApi = function (data) {
|
||||
func.open({
|
||||
height: 650,
|
||||
width: 550,
|
||||
title: '分配接口',
|
||||
content: Feng.ctxPath + "/view/role/assignApi?roleId=" + data.roleId,
|
||||
tableId: Role.tableId
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -187,8 +198,10 @@ layui.use(['layer', 'form', 'table', 'admin', 'HttpRequest', 'func'], function (
|
|||
Role.onEditDataScope(data);
|
||||
} else if (layEvent === 'delete') {
|
||||
Role.onDeleteRole(data);
|
||||
} else if (layEvent === 'roleAssign') {
|
||||
Role.roleAssign(data);
|
||||
} else if (layEvent === 'assignMenu') {
|
||||
Role.assignMenu(data);
|
||||
} else if (layEvent === 'assignApi') {
|
||||
Role.assignApi(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
layui.use(['layer', 'table', 'ax', 'laydate'], function () {
|
||||
layui.use(['HttpRequest', 'treeTable', 'laydate', 'func' ,'form'], function () {
|
||||
var $ = layui.$;
|
||||
var $ax = layui.ax;
|
||||
var layer = layui.layer;
|
||||
var table = layui.table;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var func = layui.func;
|
||||
var form = layui.form;
|
||||
var laydate = layui.laydate;
|
||||
|
||||
/**
|
||||
* 系统管理--操作日志
|
||||
*/
|
||||
var LoginLog = {
|
||||
var Log = {
|
||||
tableId: "logTable" //表格id
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化表格的列
|
||||
*/
|
||||
LoginLog.initColumn = function () {
|
||||
Log.initColumn = function () {
|
||||
return [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'operationLogId', hide: true, sort: true, title: 'id'},
|
||||
{field: 'logType', align: "center", sort: true, title: '日志类型'},
|
||||
{field: 'logId', hide: true, sort: true, title: 'id'},
|
||||
/*{field: 'logType', align: "center", sort: true, title: '日志类型'},*/
|
||||
{field: 'logName', align: "center", sort: true, title: '日志名称'},
|
||||
{field: 'userName', align: "center", sort: true, title: '用户名称'},
|
||||
{field: 'className', align: "center", sort: true, title: '类名'},
|
||||
{field: 'method', align: "center", sort: true, title: '方法名'},
|
||||
{field: 'createUser', align: "center", sort: true, title: '用户名称'},
|
||||
{field: 'appName', align: "center", sort: true, title: '服务器名'},
|
||||
{field: 'requestUrl', align: "center", sort: true, title: '方法名'},
|
||||
{field: 'createTime', align: "center", sort: true, title: '时间'},
|
||||
{field: 'regularMessage', align: "center", sort: true, title: '具体消息'},
|
||||
{field: 'logContent', align: "center", sort: true, title: '具体消息'},
|
||||
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 100}
|
||||
]];
|
||||
};
|
||||
|
@ -33,13 +34,13 @@ layui.use(['layer', 'table', 'ax', 'laydate'], function () {
|
|||
/**
|
||||
* 点击查询按钮
|
||||
*/
|
||||
LoginLog.search = function () {
|
||||
Log.search = function () {
|
||||
var queryData = {};
|
||||
queryData['beginTime'] = $("#beginTime").val();
|
||||
queryData['endTime'] = $("#endTime").val();
|
||||
queryData['beginDateTime'] = $("#beginTime").val();
|
||||
queryData['endDateTime'] = $("#endTime").val();
|
||||
queryData['logName'] = $("#logName").val();
|
||||
queryData['logType'] = $("#logType").val();
|
||||
table.reload(LoginLog.tableId, {
|
||||
// queryData['logType'] = $("#logType").val();
|
||||
table.reload(Log.tableId, {
|
||||
where: queryData, page: {curr: 1}
|
||||
});
|
||||
};
|
||||
|
@ -47,79 +48,81 @@ layui.use(['layer', 'table', 'ax', 'laydate'], function () {
|
|||
/**
|
||||
* 导出excel按钮
|
||||
*/
|
||||
LoginLog.exportExcel = function () {
|
||||
var checkRows = table.checkStatus(LoginLog.tableId);
|
||||
if (checkRows.data.length === 0) {
|
||||
Feng.error("请选择要导出的数据");
|
||||
} else {
|
||||
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
|
||||
}
|
||||
};
|
||||
// Log.exportExcel = function () {
|
||||
// var checkRows = table.checkStatus(Log.tableId);
|
||||
// if (checkRows.data.length === 0) {
|
||||
// Feng.error("请选择要导出的数据");
|
||||
// } else {
|
||||
// table.exportFile(tableResult.config.id, checkRows.data, 'xls');
|
||||
// }
|
||||
// };
|
||||
|
||||
/**
|
||||
* 日志详情
|
||||
*/
|
||||
LoginLog.logDetail = function (param) {
|
||||
var ajax = new $ax(Feng.ctxPath + "/log/detail/" + param.operationLogId, function (data) {
|
||||
Feng.infoDetail("日志详情", data.regularMessage);
|
||||
}, function (data) {
|
||||
Feng.error("获取详情失败!");
|
||||
});
|
||||
ajax.start();
|
||||
};
|
||||
// Log.logDetail = function (param) {
|
||||
// var ajax = new $ax(Feng.ctxPath + "/log/detail/" + param.operationLogId, function (data) {
|
||||
// Feng.infoDetail("日志详情", data.regularMessage);
|
||||
// }, function (data) {
|
||||
// Feng.error("获取详情失败!");
|
||||
// });
|
||||
// ajax.start();
|
||||
// };
|
||||
|
||||
/**
|
||||
* 清空日志
|
||||
*/
|
||||
LoginLog.cleanLog = function () {
|
||||
Feng.confirm("是否清空所有日志?", function () {
|
||||
var ajax = new $ax(Feng.ctxPath + "/log/delLog", function (data) {
|
||||
Feng.success("清空日志成功!");
|
||||
LoginLog.search();
|
||||
}, function (data) {
|
||||
Feng.error("清空日志失败!");
|
||||
});
|
||||
ajax.start();
|
||||
});
|
||||
};
|
||||
// Log.cleanLog = function () {
|
||||
// Feng.confirm("是否清空所有日志?", function () {
|
||||
// var ajax = new $ax(Feng.ctxPath + "/log/delLog", function (data) {
|
||||
// Feng.success("清空日志成功!");
|
||||
// Log.search();
|
||||
// }, function (data) {
|
||||
// Feng.error("清空日志失败!");
|
||||
// });
|
||||
// ajax.start();
|
||||
// });
|
||||
// };
|
||||
|
||||
//渲染时间选择框
|
||||
// 渲染时间选择框
|
||||
laydate.render({
|
||||
elem: '#beginTime'
|
||||
elem: '#createTime'
|
||||
});
|
||||
|
||||
//渲染时间选择框
|
||||
laydate.render({
|
||||
elem: '#endTime'
|
||||
});
|
||||
// 渲染时间选择框
|
||||
// laydate.render({
|
||||
// elem: '#createTime'
|
||||
// });
|
||||
|
||||
// 渲染表格
|
||||
var tableResult = table.render({
|
||||
elem: '#' + LoginLog.tableId,
|
||||
url: Feng.ctxPath + '/log/list',
|
||||
elem: '#' + Log.tableId,
|
||||
url: Feng.ctxPath + '/logManager/page',
|
||||
page: true,
|
||||
height: "full-98",
|
||||
height: "full-158",
|
||||
cellMinWidth: 100,
|
||||
cols: LoginLog.initColumn()
|
||||
cols: Log.initColumn(),
|
||||
request: {pageName: 'pageNo', limitName: 'pageSize'},
|
||||
parseData: Feng.parseData
|
||||
});
|
||||
|
||||
// 搜索按钮点击事件
|
||||
$('#btnSearch').click(function () {
|
||||
LoginLog.search();
|
||||
Log.search();
|
||||
});
|
||||
|
||||
// 搜索按钮点击事件
|
||||
$('#btnClean').click(function () {
|
||||
LoginLog.cleanLog();
|
||||
});
|
||||
// $('#btnClean').click(function () {
|
||||
// Log.cleanLog();
|
||||
// });
|
||||
|
||||
// 工具条点击事件
|
||||
table.on('tool(' + LoginLog.tableId + ')', function (obj) {
|
||||
var data = obj.data;
|
||||
var layEvent = obj.event;
|
||||
|
||||
if (layEvent === 'detail') {
|
||||
LoginLog.logDetail(data);
|
||||
}
|
||||
});
|
||||
// table.on('tool(' + Log.tableId + ')', function (obj) {
|
||||
// var data = obj.data;
|
||||
// var layEvent = obj.event;
|
||||
//
|
||||
// if (layEvent === 'detail') {
|
||||
// Log.logDetail(data);
|
||||
// }
|
||||
// });
|
||||
});
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
layui.use(['table', 'admin', 'form', 'func', 'HttpRequest', 'dropdown'], function () {
|
||||
let $ = layui.$;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let func = layui.func;
|
||||
let HttpRequest = layui.HttpRequest;
|
||||
let dropdown = layui.dropdown;
|
||||
|
||||
// 定时表管理
|
||||
let Position = {
|
||||
tableId: "timerTable"
|
||||
};
|
||||
|
||||
// 初始化表格的列
|
||||
Position.initColumn = function () {
|
||||
return [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'timerId', hide: true, title: '主键id'},
|
||||
{field: 'timerName', sort: true, title: '任务名称'},
|
||||
{field: 'cron', sort: true, title: 'cron表达式'},
|
||||
{field: 'jobStatus', sort: true, templet: '#statusTpl', title: '状态'},
|
||||
{field: 'actionClass', sort: true, title: '任务class'},
|
||||
{field: 'remark', sort: true, title: '备注信息'},
|
||||
{field: 'createUser', sort: true, title: '创建人'},
|
||||
{field: 'updateUser', sort: true, title: '修改人'},
|
||||
{field: 'createTime', sort: true, title: '创建时间'},
|
||||
{field: 'updateTime', sort: true, title: '修改时间'},
|
||||
{align: 'center', toolbar: '#tableBar', title: '操作'}
|
||||
]];
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
Position.search = function () {
|
||||
let queryData = {};
|
||||
queryData['timerName'] = $("#timerName").val();
|
||||
queryData['jobStatus'] = $("#jobStatus").val();
|
||||
table.reload(Position.tableId, {
|
||||
where: queryData,
|
||||
page: {curr: 1}
|
||||
});
|
||||
};
|
||||
|
||||
// 弹出添加对话框
|
||||
Position.openAddDlg = function () {
|
||||
func.open({
|
||||
height: 800,
|
||||
title: '添加定时任务',
|
||||
content: Feng.ctxPath + '/sysTimers/addView',
|
||||
tableId: Position.tableId
|
||||
});
|
||||
};
|
||||
|
||||
// 点击编辑
|
||||
Position.openEditDlg = function (data) {
|
||||
func.open({
|
||||
height: 800,
|
||||
title: '修改定时任务',
|
||||
content: Feng.ctxPath + '/sysTimers/editView?timerId=' + data.timerId,
|
||||
tableId: Position.tableId
|
||||
});
|
||||
};
|
||||
|
||||
// 点击删除
|
||||
Position.delete = function (data) {
|
||||
let operation = function () {
|
||||
let httpRequest = new HttpRequest(Feng.ctxPath + "/sysTimers/delete", 'post', function (data) {
|
||||
Feng.success("删除成功!");
|
||||
table.reload(Position.tableId);
|
||||
}, function (data) {
|
||||
Feng.error("删除失败!" + data.message + "!");
|
||||
});
|
||||
httpRequest.set(data);
|
||||
httpRequest.start(true);
|
||||
};
|
||||
Feng.confirm("是否删除?", operation);
|
||||
};
|
||||
|
||||
// 修改定时任务状态
|
||||
Position.updateStatus = function (timerId, checked) {
|
||||
// 1-启动 2-停止
|
||||
let updateStatusUrl = checked == 1 ? "/sysTimers/start" : "/sysTimers/stop";
|
||||
|
||||
let httpRequest = new HttpRequest(Feng.ctxPath + updateStatusUrl, 'post', function (data) {
|
||||
Feng.success("修改成功!");
|
||||
}, function (data) {
|
||||
Feng.error("修改失败!" + data.responseJSON.message);
|
||||
table.reload(Position.tableId);
|
||||
});
|
||||
httpRequest.set({"timerId": timerId});
|
||||
httpRequest.start(true);
|
||||
};
|
||||
|
||||
// 渲染表格
|
||||
let tableResult = table.render({
|
||||
elem: '#' + Position.tableId,
|
||||
url: Feng.ctxPath + '/sysTimers/page',
|
||||
page: true,
|
||||
request: {pageName: 'pageNo', limitName: 'pageSize'},
|
||||
height: "full-158",
|
||||
cellMinWidth: 100,
|
||||
cols: Position.initColumn(),
|
||||
parseData: Feng.parseData
|
||||
});
|
||||
|
||||
// 搜索按钮点击事件
|
||||
$('#btnSearch').click(function () {
|
||||
Position.search();
|
||||
});
|
||||
|
||||
// 添加按钮点击事件
|
||||
$('#btnAdd').click(function () {
|
||||
Position.openAddDlg();
|
||||
});
|
||||
|
||||
// 工具条点击事件
|
||||
table.on('tool(' + Position.tableId + ')', function (obj) {
|
||||
let data = obj.data;
|
||||
let event = obj.event;
|
||||
if (event === 'edit') {
|
||||
Position.openEditDlg(data);
|
||||
} else if (event === 'delete') {
|
||||
Position.delete(data);
|
||||
}
|
||||
dropdown.hideAll();
|
||||
});
|
||||
|
||||
// 修改状态
|
||||
form.on('switch(status)', function (obj) {
|
||||
let timerId = obj.elem.value;
|
||||
let checked = obj.elem.checked ? 1 : 2;
|
||||
Position.updateStatus(timerId, checked);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,48 @@
|
|||
layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||
let $ = layui.$;
|
||||
let form = layui.form;
|
||||
let admin = layui.admin;
|
||||
let HttpRequest = layui.HttpRequest;
|
||||
|
||||
// 正则不全-弃用
|
||||
form.verify({
|
||||
corn: function (value, item) {
|
||||
// corn 正则验证
|
||||
let cornRegEx = '/^[^\\s]*\\s[^\\s]*\\s[^\\s]*\\s((\\*|(1[0-2]|[0-9])|(1[0-2]|[0-9])-(1[0-2]|[0-9]))(\\/(1[0-2]|[0-9]))*|(((1[0-2]|[0-9])|(1[0-2]|[0-9])-(1[0-2]|[0-9]))+(,((1[0-2]|[0-9])|(1[0-2]|[0-9])-(1[0-2]|[0-9])))*)|(((jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)|(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec))))\\s[^\\s]*$/i\n';
|
||||
if (value == "") {
|
||||
return 'corn表达式不能为空';
|
||||
}
|
||||
if (!new RegExp(cornRegEx).test(value)) {
|
||||
return 'corn表达式错误';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 渲染任务job class实现类
|
||||
$.ajax({
|
||||
url: Feng.ctxPath + '/sysTimers/getActionClasses',
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
//使用循环遍历,给下拉列表赋值
|
||||
$.each(data.data, function (index, value) {
|
||||
$('#actionClass').append(new Option(value, value));// 下拉菜单里添加元素
|
||||
});
|
||||
layui.form.render("select");//重新渲染 固定写法
|
||||
}
|
||||
})
|
||||
|
||||
//表单提交事件
|
||||
form.on('submit(btnSubmit)', function (data) {
|
||||
let request = new HttpRequest(Feng.ctxPath + "/sysTimers/add", 'post', function (data) {
|
||||
admin.closeThisDialog();
|
||||
Feng.success("添加成功!");
|
||||
admin.putTempData('formOk', true);
|
||||
}, function (data) {
|
||||
admin.closeThisDialog();
|
||||
Feng.error("添加失败!" + data.message);
|
||||
});
|
||||
request.set(data.field);
|
||||
request.start(true);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,48 @@
|
|||
layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||
let $ = layui.$;
|
||||
let form = layui.form;
|
||||
let admin = layui.admin;
|
||||
let HttpRequest = layui.HttpRequest;
|
||||
//获取详情信息,填充表单
|
||||
|
||||
|
||||
//获取用户详情
|
||||
let request = new HttpRequest(Feng.ctxPath + "/sysTimers/detail?timerId=" + Feng.getUrlParam("timerId"), 'get');
|
||||
let result = request.start();
|
||||
// 处理下拉框回显
|
||||
let actionClass = result.data.actionClass;
|
||||
$('#actionClass').append(new Option(actionClass, actionClass));
|
||||
|
||||
// 渲染任务job class实现类下拉框
|
||||
$.ajax({
|
||||
url: Feng.ctxPath + '/sysTimers/getActionClasses',
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
//使用循环遍历,给下拉列表赋值
|
||||
$.each(data.data, function (index, value) {
|
||||
if (actionClass != value) {
|
||||
$('#actionClass').append(new Option(value, value));
|
||||
}
|
||||
});
|
||||
layui.form.render("select");
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
form.val('positionForm', result.data);
|
||||
|
||||
//表单提交事件
|
||||
form.on('submit(btnSubmit)', function (data) {
|
||||
let request = new HttpRequest(Feng.ctxPath + "/sysTimers/edit", 'post', function (data) {
|
||||
Feng.success("修改成功!");
|
||||
admin.putTempData('formOk', true);
|
||||
admin.closeThisDialog();
|
||||
}, function (data) {
|
||||
admin.closeThisDialog();
|
||||
Feng.error("修改失败!" + data.message);
|
||||
});
|
||||
request.set(data.field);
|
||||
request.start(true);
|
||||
});
|
||||
});
|
|
@ -169,7 +169,7 @@
|
|||
</div>
|
||||
<div class="layui-form-item layui-input-icon-group">
|
||||
<i class="layui-icon layui-icon-password"></i>
|
||||
<input class="layui-input" id="password" name="password" placeholder="请输入登录密码" value="111111" type="password" lay-verType="tips" lay-verify="required" required/>
|
||||
<input class="layui-input" id="password" name="password" placeholder="请输入登录密码" value="123456" type="password" lay-verType="tips" lay-verify="required" required/>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-fluid" id="submit">登录</button>
|
||||
|
|
|
@ -1,35 +1,136 @@
|
|||
@layout("/layout/_container.html",{js:["/assets/modular/auth/resource/resource.js"]}){
|
||||
@layout("/layout/_container.html",{js:["/assets/modular/auth/resource/resource_detail.js"]}){
|
||||
|
||||
<div class="layui-body-header">
|
||||
<span class="layui-body-header-title">资源管理</span>
|
||||
</div>
|
||||
<form class="layui-form" id="resourceForm" lay-filter="resourceForm">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form toolbar">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<input id="resourceName" class="layui-input" type="text" placeholder="资源名称"/>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">应用标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="appCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input id="url" class="layui-input" type="text" placeholder="资源url"/>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="resourceCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="resourceName" placeholder="资源名称" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">项目编码</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="projectCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">控制器类名</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="className" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">方法名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="methodName" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源所属模块</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="modularCode" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">模块中文名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="modularName" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">初始化地址</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="ipAddress" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否视图类型</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="viewFlag" type="checkbox" lay-skin="switch" lay-filter="viewFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">请求路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="url" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">请求方法</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="httpMethod" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否需要登录</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="requiredLoginFlag" type="checkbox" lay-skin="switch" lay-filter="requiredLoginFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">是否需要鉴权</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="requiredPermissionFlag" type="checkbox" lay-skin="switch" lay-filter="requiredPermissionFlag" lay-text="是|否" disabled=""/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">资源添加日期</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="createTime" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">创建人</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="createUser" type="text" disabled readonly class="layui-input layui-disabled"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-table" id="resourceTable" lay-filter="resourceTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group-bottom text-center" style="z-index: 200">
|
||||
<button type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog"> 关闭 </button>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
|
||||
</script>
|
||||
@}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@/* 加入contextPath属性和session超时的配置 */
|
||||
|
||||
<script type="text/javascript">
|
||||
var Feng = {
|
||||
ctxPath: "${ctxPath}",
|
||||
|
@ -42,25 +42,39 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
|
||||
layui.use(['ztree','ax'], function () {
|
||||
layui.use(['ztree', 'admin', 'HttpRequest'], function () {
|
||||
var $ = layui.$;
|
||||
var $ZTree = layui.ztree;
|
||||
var $ax = layui.ax;
|
||||
|
||||
var ZTreeDlg = {
|
||||
index: parent.layer.getFrameIndex(window.name)
|
||||
};
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var admin = layui.admin;
|
||||
|
||||
$("#saveButton").bind("click", function () {
|
||||
var ids = Feng.zTreeCheckedNodes("zTree");
|
||||
var ajax = new $ax(Feng.ctxPath + "/role/setAuthority", function (data) {
|
||||
Feng.success("分配角色成功!");
|
||||
parent.layer.close(ZTreeDlg.index);
|
||||
|
||||
var zTree = $.fn.zTree.getZTreeObj("zTree");
|
||||
var nodes = zTree.getCheckedNodes();
|
||||
var ids = [];
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
// 剔除掉不能被选择的节点(虚拟节点)
|
||||
if (nodes[i].resourceFlag) {
|
||||
ids.push(nodes[i].code);
|
||||
}
|
||||
}
|
||||
|
||||
var request = new HttpRequest(Feng.ctxPath + "/sysRole/grantResource", 'post', function (data) {
|
||||
Feng.success("分配接口成功!");
|
||||
|
||||
//传给上个页面,刷新table用
|
||||
admin.putTempData('formOk', true);
|
||||
|
||||
//关掉对话框
|
||||
admin.closeThisDialog();
|
||||
|
||||
}, function (data) {
|
||||
Feng.error("分配角色失败!" + data.responseJSON.message + "!");
|
||||
Feng.error("分配接口失败!" + data.message + "!");
|
||||
});
|
||||
ajax.set("ids", ids);
|
||||
ajax.set("roleId", "${roleId}");
|
||||
ajax.start();
|
||||
request.set("grantResourceList", ids);
|
||||
request.set("roleId", Feng.getUrlParam("roleId"));
|
||||
request.start(true);
|
||||
});
|
||||
|
||||
var setting = {
|
||||
|
@ -73,12 +87,19 @@
|
|||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
enable: true,
|
||||
idKey: "code",
|
||||
pIdKey: "parentCode",
|
||||
rootPId: "-1"
|
||||
},
|
||||
key: {
|
||||
checked: "checked",
|
||||
name: "nodeName"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ztree = new $ZTree("zTree", "/menu/menuTreeListByRoleId/${roleId}");
|
||||
var ztree = new $ZTree("zTree", "/resource/getLateralTree?roleId=" + Feng.getUrlParam("roleId"));
|
||||
ztree.setSettings(setting);
|
||||
ztree.init();
|
||||
});
|
||||
|
@ -88,3 +109,4 @@
|
|||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>${constants.getSystemName()}</title>
|
||||
<meta name="description" content="${constants.getSystemName()}">
|
||||
<meta name="author" content="stylefeng">
|
||||
|
||||
<link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
|
||||
<link href="${ctxPath}/assets/expand/plugins/ztree/zTreeStyle.css?v=${constants.getReleaseVersion()}" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="deptForm" class="layui-fluid">
|
||||
<div class="layui-row" style="margin-top:15px;background: #f2f7f8;padding: 20px;">
|
||||
<ul id="zTree" class="ztree"></ul>
|
||||
</div>
|
||||
<div class="layui-row" style="background: #CFD4D5;padding: 10px;">
|
||||
<div style="text-align: center;">
|
||||
<button class="layui-btn layui-btn-sm" id="saveButton">保存</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var Feng = {
|
||||
ctxPath: "${ctxPath}",
|
||||
version: '${constants.getReleaseVersion()}'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>
|
||||
|
||||
<!--其他插件js-->
|
||||
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/jquery/jquery-3.2.1.min.js?v=${constants.getReleaseVersion()}"></script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/ztree/jquery.ztree.all.min.js?v=${constants.getReleaseVersion()}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
layui.use(['ztree', 'admin', 'HttpRequest'], function () {
|
||||
var $ = layui.$;
|
||||
var $ZTree = layui.ztree;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var admin = layui.admin;
|
||||
|
||||
$("#saveButton").bind("click", function () {
|
||||
|
||||
var zTree = $.fn.zTree.getZTreeObj("zTree");
|
||||
var nodes = zTree.getCheckedNodes();
|
||||
var menuIds = [];
|
||||
var buttonList = [];
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
// 剔除掉不能被选择的节点(虚拟节点)
|
||||
if (nodes[i].menuFlag) {
|
||||
menuIds.push(nodes[i].id);
|
||||
} else {
|
||||
buttonList.push({
|
||||
"buttonId": nodes[i].id,
|
||||
"buttonCode": nodes[i].buttonCode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var request = new HttpRequest(Feng.ctxPath + "/sysRole/grantMenuAndButton", 'post', function (data) {
|
||||
Feng.success("分配成功!");
|
||||
|
||||
//传给上个页面,刷新table用
|
||||
admin.putTempData('formOk', true);
|
||||
|
||||
//关掉对话框
|
||||
admin.closeThisDialog();
|
||||
|
||||
}, function (data) {
|
||||
Feng.error("分配失败!" + data.message + "!");
|
||||
});
|
||||
request.set("grantMenuIdList", menuIds);
|
||||
request.set("grantMenuButtonIdList", buttonList);
|
||||
request.set("roleId", Feng.getUrlParam("roleId"));
|
||||
request.start(true);
|
||||
});
|
||||
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true,
|
||||
chkboxType: {
|
||||
"Y": "ps",
|
||||
"N": "ps"
|
||||
}
|
||||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: "id",
|
||||
pIdKey: "pid",
|
||||
rootPId: "-1"
|
||||
},
|
||||
key: {
|
||||
checked: "checked",
|
||||
name: "name"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ztree = new $ZTree("zTree", "/sysMenu/menuAndButtonTree?roleId=" + Feng.getUrlParam("roleId"));
|
||||
ztree.setSettings(setting);
|
||||
ztree.init();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>${constants.getSystemName()}</title>
|
||||
<link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
|
||||
<link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css?v=${constants.getReleaseVersion()}"/>
|
||||
<link rel="stylesheet" href="${ctxPath}/assets/expand/css/style.css?v=${constants.getReleaseVersion()}" media="all"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15" >
|
||||
<div class="layui-col-lg12">
|
||||
<iframe id="iframe" src="http://localhost:${port}/druid/index.html" frameborder="no" width="100%" scrolling="auto" ></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- js部分 -->
|
||||
@/* 加入contextPath属性和session超时的配置 */
|
||||
<script type="text/javascript">
|
||||
var Feng = {
|
||||
ctxPath: "${ctxPath}",
|
||||
version: '${constants.getReleaseVersion()}'
|
||||
};
|
||||
document.getElementById("iframe").height = document.documentElement.clientHeight+'px;'
|
||||
</script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
|
||||
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -20,19 +20,18 @@
|
|||
<div class="layui-inline">
|
||||
<input id="logName" class="layui-input" type="text" placeholder="日志名称"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<!-- <div class="layui-inline">
|
||||
<select id="logType">
|
||||
<option value="">类型</option>
|
||||
<option value="0">全部</option>
|
||||
<option value="1">业务日志</option>
|
||||
<option value="2">异常日志</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="layui-inline">
|
||||
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||
@if(shiro.hasPermission("/log/delLog")){
|
||||
|
||||
<button id="btnClean" class="layui-btn icon-btn layui-btn-danger"><i class="layui-icon"></i>清空日志</button>
|
||||
@}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,7 +41,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
|
||||
</script>
|
||||
|
||||
@}
|
|
@ -0,0 +1,45 @@
|
|||
@layout("/layout/_container.html",{js:["/assets/modular/system/timers/timers.js"]}){
|
||||
|
||||
<div class="layui-body-header">
|
||||
<span class="layui-body-header-title">定时管理</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form toolbar">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline" aria-placeholder="任务名称">
|
||||
<input id="timerName" class="layui-input" type="text" placeholder="任务名称"/>
|
||||
</div>
|
||||
<div class="layui-inline" aria-placeholder="状态">
|
||||
<select id="jobStatus" lay-filter="type">
|
||||
<option value="">请选择</option>
|
||||
<option value="1">运行</option>
|
||||
<option value="2">停止</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
||||
<button id="btnAdd" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-table" id="timerTable" lay-filter="timerTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="tableBar">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="statusTpl">
|
||||
<input type="checkbox" lay-filter="status" value="{{d.timerId}}" lay-skin="switch" lay-text="运行|停止" {{d.jobStatus=='1'?'checked':''}}/>
|
||||
</script>
|
||||
@}
|
|
@ -0,0 +1,48 @@
|
|||
@layout("/layout/_form.html",{js:["/assets/modular/system/timers/timers_add.js"]}){
|
||||
|
||||
<form class="layui-form" id="timerForm" lay-filter="positionForm">
|
||||
<div class="layui-fluid" style="padding-bottom: 75px;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">基本信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
<input name="timerId" type="hidden"/>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">任务名称<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<input id="timerName" name="timerName" placeholder="请输入任务名称" type="text" class="layui-input" lay-verify="required" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">任务job<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<select name="actionClass" id="actionClass" lay-verify="required" lay-filter="actionClass">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label" style="width: auto">cron表达式<span style="color: red;">*</span></label>
|
||||
<!-- http://89tool.com/cron -->
|
||||
<div class="layui-input-block" style="width: auto">
|
||||
<input id="cron" name="cron" placeholder="请输入cron表达式" type="text" class="layui-input" lay-verify="required" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="remark" name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group-bottom text-center">
|
||||
<button class="layui-btn" lay-filter="btnSubmit" lay-submit> 提交 </button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog"> 取消 </button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@}
|
|
@ -0,0 +1,49 @@
|
|||
@layout("/layout/_form.html",{js:["/assets/modular/system/timers/timers_edit.js"]}){
|
||||
|
||||
<form class="layui-form" id="positionForm" lay-filter="positionForm">
|
||||
<div class="layui-fluid" style="padding-bottom: 75px;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">基本信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
<input name="timerId" type="hidden"/>
|
||||
<input name="jobStatus" type="hidden"/>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">任务名称<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<input id="timerName" name="timerName" placeholder="请输入任务名称" type="text" class="layui-input" lay-verify="required" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">任务job<span style="color: red;">*</span></label>
|
||||
<!-- http://89tool.com/cron -->
|
||||
<div class="layui-input-block">
|
||||
<select name="actionClass" id="actionClass" lay-verify="required" lay-filter="actionClass">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label" style="width: auto">cron表达式<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block" style="width: auto">
|
||||
<input id="cron" name="cron" placeholder="请输入cron表达式" type="text" class="layui-input" lay-verify="required" required/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="remark" name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group-bottom text-center">
|
||||
<button class="layui-btn" lay-filter="btnSubmit" lay-submit> 提交 </button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog"> 取消 </button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@}
|
Loading…
Reference in New Issue