This commit is contained in:
bwcx_jzy 2019-09-26 10:26:54 +08:00
parent 21f144e202
commit 222fc5c6ab
31 changed files with 129 additions and 31 deletions

View File

@ -26,6 +26,7 @@ public class JpomServerApplication implements ApplicationEventLoad {
* 启动执行
*
* @param args 参数
* @throws Exception 异常
*/
public static void main(String[] args) throws Exception {
JpomApplication jpomApplication = new JpomApplication(Type.Server, JpomServerApplication.class, args);

View File

@ -57,6 +57,7 @@ public class BuildManage extends BaseBuild implements Runnable {
* 取消构建
*
* @param id id
* @return bool
*/
public static boolean cancel(String id) {
BuildManage buildManage = BUILD_MANAGE_MAP.get(id);

View File

@ -34,6 +34,10 @@ public class GlobalDefaultExceptionHandler {
/**
* 声明要捕获的异常
*
* @param request 请求
* @param response 响应
* @param e 异常
*/
@ExceptionHandler({AgentException.class, AuthorizeException.class, RuntimeException.class, Exception.class})
public void paramExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {

View File

@ -39,6 +39,7 @@ public class NodeForward {
* @param nodeModel 节点
* @param request 请求
* @param nodeUrl 节点的url
* @param <T> 泛型
* @return JSON
*/
public static <T> JsonMessage<T> request(NodeModel nodeModel, HttpServletRequest request, NodeUrl nodeUrl) {
@ -48,8 +49,10 @@ public class NodeForward {
/**
* 普通消息转发
*
* @param nodeModel 节点
* @param nodeUrl 节点的url
* @param nodeModel 节点
* @param nodeUrl 节点的url
* @param jsonObject 数据
* @param userModel user
* @return JSON
*/
public static JsonMessage request(NodeModel nodeModel, NodeUrl nodeUrl, UserModel userModel, JSONObject jsonObject) {
@ -61,6 +64,9 @@ public class NodeForward {
*
* @param nodeModel 节点
* @param nodeUrl 节点的url
* @param pName 主参数名
* @param pVal 主参数值
* @param val 其他参数
* @return JSON
*/
public static JsonMessage requestBySys(NodeModel nodeModel, NodeUrl nodeUrl, String pName, Object pVal, Object... val) {
@ -73,6 +79,13 @@ public class NodeForward {
* @param nodeModel 节点
* @param request 请求
* @param nodeUrl 节点的url
* @param pVal 主参数值
* @param pName 主参数名
* @param userModel 用户
* @param jsonData 数据
* @param mustUser 是否必须需要user
* @param val 其他参数
* @param <T> 泛型
* @return JSON
*/
private static <T> JsonMessage<T> request(NodeModel nodeModel,
@ -144,10 +157,13 @@ public class NodeForward {
/**
* 普通消息转发,并解析数据
*
* @param nodeModel 节点
* @param nodeUrl 节点的url
* @param tClass 要解析的类
* @param <T> 泛型
* @param nodeModel 节点
* @param nodeUrl 节点的url
* @param tClass 要解析的类
* @param <T> 泛型
* @param name 参数名
* @param parameters 其他参数
* @param value
* @return T
*/
public static <T> T requestData(NodeModel nodeModel, NodeUrl nodeUrl, Class<T> tClass, String name, Object value, Object... parameters) {

View File

@ -133,6 +133,7 @@ public class LoginControl extends BaseServerController {
*
* @param userName 登录名
* @param userPwd 登录密码
* @param code 验证码
* @return json
*/
@RequestMapping(value = "userLogin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)

View File

@ -56,6 +56,8 @@ public class MonitorListController extends BaseServerController {
/**
* 展示监控页面
*
* @return page
*/
@RequestMapping(value = "list.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.LIST)
@ -65,6 +67,9 @@ public class MonitorListController extends BaseServerController {
/**
* 修改监控
*
* @param id id
* @return json
*/
@RequestMapping(value = "edit.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.EDIT)
@ -97,6 +102,8 @@ public class MonitorListController extends BaseServerController {
/**
* 展示监控列表
*
* @return json
*/
@RequestMapping(value = "getMonitorList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -108,6 +115,9 @@ public class MonitorListController extends BaseServerController {
/**
* 删除列表
*
* @param id id
* @return json
*/
@RequestMapping(value = "deleteMonitor", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -126,6 +136,11 @@ public class MonitorListController extends BaseServerController {
/**
* 增加或修改监控
*
* @param id id
* @param name name
* @param notifyUser user
* @return json
*/
@RequestMapping(value = "updateMonitor", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -181,6 +196,11 @@ public class MonitorListController extends BaseServerController {
/**
* 开启或关闭监控
*
* @param id id
* @param status 状态
* @param type 类型
* @return json
*/
@RequestMapping(value = "changeStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -20,7 +20,6 @@ import io.jpom.plugin.ClassFeature;
import io.jpom.plugin.Feature;
import io.jpom.plugin.MethodFeature;
import io.jpom.service.dblog.DbMonitorNotifyLogService;
import io.jpom.service.node.NodeService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -46,6 +45,8 @@ public class MonitorLogController extends BaseServerController {
/**
* 展示监控页面
*
* @return page
*/
@RequestMapping(value = "log.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.LOG)
@ -62,6 +63,11 @@ public class MonitorLogController extends BaseServerController {
/**
* 展示用户列表
*
* @param selectNode 节点
* @param limit 限制
* @param notifyStatus 状态
* @return json
*/
@RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -30,6 +30,7 @@ public class ConsoleController extends BaseServerController {
/**
* 管理项目
*
* @param id id
* @return page
*/
@RequestMapping(value = "console", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)

View File

@ -80,6 +80,7 @@ public class EditProjectController extends BaseServerController {
/**
* 保存项目
*
* @param id id
* @return json
*/
@RequestMapping(value = "saveProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)

View File

@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
/**
@ -89,13 +88,14 @@ public class ProjectManageControl extends BaseServerController {
/**
* 删除项目
*
* @param id id
* @return json
*/
@RequestMapping(value = "deleteProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@OptLog(value = UserOperateLogV1.OptType.DelProject)
@Feature(method = MethodFeature.DEL)
public String deleteProject(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id) throws IOException {
public String deleteProject(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id) {
NodeModel nodeModel = getNode();
// 检查节点分发
List<OutGivingModel> outGivingModels = outGivingServer.list();

View File

@ -35,6 +35,7 @@ public class ProjectFileControl extends BaseServerController {
* 文件管理页面
*
* @param id 项目id
* @return page
*/
@RequestMapping(value = "list.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.FILE)
@ -50,6 +51,8 @@ public class ProjectFileControl extends BaseServerController {
/**
* 列出目录下的文件
*
* @return json
*/
@RequestMapping(value = "getFileList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -23,9 +23,11 @@ public class InternalController extends BaseServerController {
/**
* 获取内存信息
*
* @return page
*/
@RequestMapping(value = "internal", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public String getInternal(String tag) throws Exception {
public String getInternal(String tag) {
setAttribute("tag", tag);
JSONObject data = NodeForward.requestData(getNode(), NodeUrl.Manage_internal_data, getRequest(), JSONObject.class);
setAttribute("data", data);
@ -34,6 +36,8 @@ public class InternalController extends BaseServerController {
/**
* 查询监控线程列表
*
* @return json
*/
@RequestMapping(value = "threadInfos", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -57,7 +61,7 @@ public class InternalController extends BaseServerController {
@RequestMapping(value = "ram", method = RequestMethod.GET)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.ExportRam)
public void ram() throws Exception {
public void ram() {
NodeForward.requestDownload(getNode(), getRequest(), getResponse(), NodeUrl.Manage_internal_ram);
}
}

View File

@ -41,6 +41,8 @@ public class NginxController extends BaseServerController {
/**
* 配置列表
*
* @return json
*/
@RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -80,6 +82,8 @@ public class NginxController extends BaseServerController {
/**
* 获取nginx状态
*
* @return json
*/
@RequestMapping(value = "status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -90,6 +94,8 @@ public class NginxController extends BaseServerController {
/**
* 获取nginx配置状态
*
* @return json
*/
@RequestMapping(value = "config", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -100,6 +106,8 @@ public class NginxController extends BaseServerController {
/**
* 启动nginx
*
* @return json
*/
@RequestMapping(value = "open", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -110,6 +118,8 @@ public class NginxController extends BaseServerController {
/**
* 关闭nginx
*
* @return json
*/
@RequestMapping(value = "close", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -121,6 +131,8 @@ public class NginxController extends BaseServerController {
/**
* 修改nginx
*
* @return json
*/
@RequestMapping(value = "updateConf", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -60,6 +60,8 @@ public class CertificateController extends BaseServerController {
/**
* 证书列表
*
* @return json
*/
@RequestMapping(value = "/getCertList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@ -71,14 +73,13 @@ public class CertificateController extends BaseServerController {
/**
* 删除证书
*
* @param id id
* @return json
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.DelCert)
@Feature(method = MethodFeature.DEL)
public String delete(String id) {
public String delete() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.System_Certificate_delete).toString();
}
@ -90,7 +91,7 @@ public class CertificateController extends BaseServerController {
@ResponseBody
@OptLog(UserOperateLogV1.OptType.ExportCert)
@Feature(method = MethodFeature.DOWNLOAD)
public void export(String id) {
public void export() {
NodeForward.requestDownload(getNode(), getRequest(), getResponse(), NodeUrl.System_Certificate_export);
}
}

View File

@ -55,6 +55,7 @@ public class TomcatManageController extends BaseServerController {
/**
* 查询tomcat的项目
*
* @param id id
* @return tomcat的项目信息
*/
@RequestMapping(value = "getTomcatProject", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE)

View File

@ -75,6 +75,7 @@ public class CacheManageController extends BaseServerController {
/**
* 清空缓存
*
* @param type 类型
* @return json
*/
@RequestMapping(value = "clearCache.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)

View File

@ -32,6 +32,8 @@ public class SystemMailConfigController extends BaseServerController {
/**
* 展示监控页面
*
* @return page
*/
@RequestMapping(value = "mailConfig.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@SystemPermission

View File

@ -37,6 +37,8 @@ public class UserListController extends BaseServerController {
/**
* 展示用户列表
*
* @return page
*/
@RequestMapping(value = "list", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.LIST)
@ -49,6 +51,8 @@ public class UserListController extends BaseServerController {
/**
* 查询所有用户
*
* @return json
*/
@RequestMapping(value = "getUserList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -17,7 +17,6 @@ import io.jpom.plugin.ClassFeature;
import io.jpom.plugin.Feature;
import io.jpom.plugin.MethodFeature;
import io.jpom.service.dblog.DbUserOperateLogService;
import io.jpom.service.node.NodeService;
import io.jpom.service.user.UserService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -45,6 +44,8 @@ public class UserOptLogController extends BaseServerController {
/**
* 展示用户列表
*
* @return page
*/
@RequestMapping(value = "list.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
@Feature(method = MethodFeature.LOG)
@ -61,6 +62,10 @@ public class UserOptLogController extends BaseServerController {
/**
* 展示用户列表
*
* @param limit 大小
* @param page page
* @return json
*/
@RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -62,6 +62,8 @@ public class UserRoleListController extends BaseServerController {
/**
* 查询所有用户
*
* @return json
*/
@RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody

View File

@ -21,7 +21,6 @@ import io.jpom.service.node.NodeService;
import io.jpom.service.node.OutGivingServer;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
@ -53,11 +52,12 @@ public class OutGivingRun implements Callable<OutGivingNodeProject.Status> {
* @param id 分发id
* @param file 文件
* @param userModel 操作的用户
* @param unzip 解压
*/
public static void startRun(String id,
File file,
UserModel userModel,
boolean unzip) throws IOException {
boolean unzip) {
OutGivingServer outGivingServer = SpringUtil.getBean(OutGivingServer.class);
OutGivingModel item = outGivingServer.getItem(id);
Objects.requireNonNull(item, "不存在分发");

View File

@ -192,6 +192,7 @@ public interface BaseDynamicService {
*
* @param classFeature 功能
* @param jsonArray array
* @return list
*/
default List<RoleModel.TreeLevel> parserChildren(ClassFeature classFeature, JSONArray jsonArray) {
Set<ClassFeature> children = DynamicData.getChildren(classFeature);

View File

@ -46,7 +46,7 @@ public class CacheControllerFeature {
* 获取url 功能方法对象
*
* @param url url
* @return
* @return url功能
*/
public static UrlFeature getUrlFeature(String url) {
return URL_FEATURE_MAP.get(url);

View File

@ -56,7 +56,6 @@ public class DynamicData {
/**
* 获取子级功能
*
* @param classFeature 功能
* @return 子级
*/
public static List<ClassFeature> getRoot() {

View File

@ -30,8 +30,9 @@ public class DbMonitorNotifyLogService extends BaseDbLogService<MonitorNotifyLog
/**
* 修改执行结果
*
* @param logId 通知id
* @param status 状态
* @param logId 通知id
* @param status 状态
* @param errorMsg 错误消息
*/
public void updateStatus(String logId, boolean status, String errorMsg) {
Entity entity = new Entity();

View File

@ -227,11 +227,11 @@ public class SshService extends BaseOperService<SshModel> implements BaseDynamic
/**
* 下载文件
*
* @param sshModel
* @param remoteFile
* @param save
* @throws FileNotFoundException
* @throws SftpException
* @param sshModel 实体
* @param remoteFile 远程文件
* @param save 文件对象
* @throws FileNotFoundException io
* @throws SftpException sftp
*/
public void download(SshModel sshModel, String remoteFile, File save) throws FileNotFoundException, SftpException {
Session session = null;

View File

@ -24,6 +24,7 @@ public class WhitelistDirectoryService {
/**
* 获取项目路径白名单
*
* @param model 实体
* @return project
*/
public List<String> getProjectDirectory(NodeModel model) {

View File

@ -44,6 +44,7 @@ public class RoleService extends BaseOperService<RoleModel> {
*
* @param roleId 角色id
* @param classFeature 功能
* @param dataId 数据id
* @return list
*/
public List<String> listDynamicData(String roleId, ClassFeature classFeature, String dataId) {
@ -58,10 +59,10 @@ public class RoleService extends BaseOperService<RoleModel> {
/**
* 调用对应功能动态数据list
*
* @param roleId
* @param classFeature
* @param roleId 角色id
* @param classFeature 功能
* @param dataId 数据id
* @return
* @return array
*/
public JSONArray listDynamic(String roleId, ClassFeature classFeature, String dataId) {
Map<ClassFeature, DynamicData> dynamicDataMap = DynamicData.getDynamicDataMap();

View File

@ -90,6 +90,7 @@ public class ServiceFileTailWatcher<T> extends BaseFileTailWatcher<T> {
* 关闭文件读取流
*
* @param fileName 文件名
* @param session 回话
*/
public static void offlineFile(File fileName, WebSocketSession session) {
ServiceFileTailWatcher<WebSocketSession> serviceFileTailWatcher = CONCURRENT_HASH_MAP.get(fileName);

View File

@ -12,6 +12,7 @@ public class CheckPassword {
* 密码强度
* Z = 字母 S = 数字 T = 特殊字符
*
* @param passwordStr 密码字符串
* @return 0 1 2强
*/
public static int checkPassword(String passwordStr) {

View File

@ -41,8 +41,10 @@ public class SvnKitUtil {
/**
* 判断当前仓库url是否匹配
*
* @param wcDir 仓库路径
* @param url url
* @param wcDir 仓库路径
* @param url url
* @param userName 用户名
* @param userPwd 密码
* @return true 匹配
* @throws SVNException 异常
*/
@ -76,7 +78,12 @@ public class SvnKitUtil {
/**
* SVN检出
*
* @param userName 用户名
* @param userPwd 密码
* @param svnPath 仓库路径
* @param targetPath 目录
* @return Boolean
* @throws SVNException svn
*/
public static String checkOut(String svnPath, String userName, String userPwd, File targetPath) throws SVNException {
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);