From 79c88e302f2057ce57d376ae71593b8a24a040e6 Mon Sep 17 00:00:00 2001 From: Administrator <55846420@qq.com> Date: Mon, 7 Dec 2015 17:55:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=EF=BC=8C=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E4=BF=A1=E6=81=AF=E7=BB=B4=E6=8A=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/cloud/controller/AlarmRuleCtl.java | 286 +++++++++++++ .../ai/cloud/controller/ApplicationCtl.java | 133 ++++++ .../controller/HelloSkyWalkingUICtl.java | 62 ++- .../com/ai/cloud/dao/impl/AlarmRuleMDAO.java | 122 ++++++ .../ai/cloud/dao/impl/ApplicationMDAO.java | 106 +++++ .../com/ai/cloud/dao/impl/UserInfoMDAO.java | 37 +- .../ai/cloud/dao/inter/IAlarmRuleMDAO.java | 15 + .../ai/cloud/dao/inter/IApplicationMDAO.java | 17 + .../com/ai/cloud/dao/inter/IUserInfoMDAO.java | 2 + .../cloud/service/impl/AlarmRuleSerImpl.java | 40 ++ .../service/impl/ApplicationSerImpl.java | 73 ++++ .../ai/cloud/service/impl/UserSerImpl.java | 38 +- .../ai/cloud/service/inter/IAlarmRuleSer.java | 15 + .../cloud/service/inter/IApplicationSer.java | 22 + .../com/ai/cloud/service/inter/IUserSer.java | 3 + .../java/com/ai/cloud/util/Constants.java | 16 + .../com/ai/cloud/vo/mvo/AlarmRuleMVO.java | 7 + .../ai/cloud/vo/mvo/ApplicationInfoMVO.java | 7 + .../java/com/ai/cloud/vo/mvo/MenuInfoMVO.java | 51 +++ .../com/ai/cloud/vo/mvo/TraceLogEntry.java | 6 +- .../java/com/ai/cloud/vo/mvo/UserInfoMVO.java | 35 +- .../com/ai/cloud/vo/svo/AlarmRuleSVO.java | 119 ++++++ .../ai/cloud/vo/svo/ApplicationInfoSVO.java | 62 +++ .../java/com/ai/cloud/vo/svo/UserInfoSVO.java | 82 ++++ .../src/main/webapp/ftl/applist.ftl | 398 ++++++++++++++++++ .../src/main/webapp/ftl/index.ftl | 3 +- .../main/webapp/ftl/lib/ai.cloud/common.ftl | 37 +- .../src/main/webapp/ftl/login.ftl | 4 +- .../src/main/webapp/ftl/regist.ftl | 69 +++ .../src/main/webapp/js/jquery/jquery-md5.js | 250 +++++++++++ .../src/main/webapp/js/webui-0.1.js | 35 ++ 31 files changed, 2088 insertions(+), 64 deletions(-) create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/controller/ApplicationCtl.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/dao/impl/ApplicationMDAO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IAlarmRuleMDAO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IApplicationMDAO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/service/impl/AlarmRuleSerImpl.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/service/impl/ApplicationSerImpl.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/service/inter/IAlarmRuleSer.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/service/inter/IApplicationSer.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/AlarmRuleMVO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/ApplicationInfoMVO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/MenuInfoMVO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ApplicationInfoSVO.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/svo/UserInfoSVO.java create mode 100644 skywalking-webui/src/main/webapp/ftl/applist.ftl create mode 100644 skywalking-webui/src/main/webapp/ftl/regist.ftl create mode 100644 skywalking-webui/src/main/webapp/js/jquery/jquery-md5.js diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java new file mode 100644 index 000000000..52beb277f --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/AlarmRuleCtl.java @@ -0,0 +1,286 @@ +package com.ai.cloud.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.ai.cloud.service.inter.IAlarmRuleSer; +import com.ai.cloud.util.Constants; +import com.ai.cloud.util.common.StringUtil; +import com.ai.cloud.vo.mvo.AlarmRuleMVO; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +@Controller +public class AlarmRuleCtl { + + @Autowired + IAlarmRuleSer alarmRuleSer; + + private static Logger logger = LogManager.getLogger(AlarmRuleCtl.class); + + /*** + * 查询用户默认规则 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/alarmRule/default", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + @ResponseBody + public String queryUserDefaultAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String json) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if (StringUtil.isBlank(uid)) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + ruleMVO.setUid(uid); + + ruleMVO = alarmRuleSer.queryUserDefaultAlarmRule(ruleMVO); + + + if (ruleMVO != null && !StringUtil.isBlank(ruleMVO.getRuleId())) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "查询到默认数据"); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO)); + } else { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据"); + } + + + return reJson.toJSONString(); + } + + /*** + * 查询用户默认规则 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/alarmRule/{appId}", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + @ResponseBody + public String queryAppAlarmRule(HttpServletRequest request, ModelMap root, @PathVariable("appId") String appId) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if (StringUtil.isBlank(uid)) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + ruleMVO.setAppId(appId); + ruleMVO.setUid(uid); + + ruleMVO = alarmRuleSer.queryAppAlarmRule(ruleMVO); + + if (ruleMVO != null && !StringUtil.isBlank(ruleMVO.getRuleId())) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "查询到默认数据"); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO)); + } else { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据"); + } + + return reJson.toJSONString(); + } + + /*** + * 创建用户默认规则 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/alarmRule/create", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + @ResponseBody + public String createAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if (StringUtil.isBlank(uid)) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + JSONObject json = JSON.parseObject(jsonStr); + if(!json.containsKey("isGlobal")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到isGlobal参数信息"); + } + String isGlobal = json.getString("isGlobal"); + if(!json.containsKey("period")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警间隔参数信息"); + } + String period = json.getString("period"); + if(!json.containsKey("todoType")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到操作类型参数信息"); + } + String todoType = json.getString("todoType"); + if(!json.containsKey("todoContent")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + if("1".equals(todoType)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调地址参数信息"); + } + else{ + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板参数信息"); + } + } + String todoContent = json.getString("todoContent"); + + AlarmRuleMVO srchRuleMVO = new AlarmRuleMVO(); + srchRuleMVO.setUid(uid); + srchRuleMVO.setSts(Constants.STR_VAL_A); + srchRuleMVO.setIsGlobal(isGlobal); + + //判断是否为全局规则 + if(Constants.IS_GLOBAL_FALG_1.equals(isGlobal)){ + srchRuleMVO = alarmRuleSer.queryUserDefaultAlarmRule(srchRuleMVO); + if (srchRuleMVO != null && !StringUtil.isBlank(srchRuleMVO.getRuleId())) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "默认告警规则已经存在"); + return reJson.toJSONString(); + } + }else{ + if(!json.containsKey("appId")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到appId参数信息"); + return reJson.toJSONString(); + }else{ + srchRuleMVO.setAppId(json.getString("appId")); + srchRuleMVO = alarmRuleSer.queryAppAlarmRule(srchRuleMVO); + if (srchRuleMVO != null && !StringUtil.isBlank(srchRuleMVO.getRuleId())) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "当前应用已经存在告警规则"); + return reJson.toJSONString(); + } + } + } + + AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + ruleMVO.setUid(uid); + ruleMVO.setAppId(json.getString("appId")); + ruleMVO.setSts(Constants.STR_VAL_A); + ruleMVO.setIsGlobal(isGlobal); + ruleMVO.setTodoType(todoType); + ruleMVO.setTodoContent(todoContent); + JSONObject confArgs = new JSONObject(); + confArgs.put("period", period); + ruleMVO.setConfigArgs(confArgs.toJSONString()); + + try{ + ruleMVO = alarmRuleSer.createAlarmRule(ruleMVO); + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "操作成功"); + + }catch(Exception e){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建告警规则失败"); + e.printStackTrace(); + } + return reJson.toJSONString(); + } + + /*** + * 创建用户默认规则 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/alarmRule/modify", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + @ResponseBody + public String modifyAppAlarmRule(HttpServletRequest request, ModelMap root, @RequestBody String jsonStr) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if (StringUtil.isBlank(uid)) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + JSONObject json = JSON.parseObject(jsonStr); + if(!json.containsKey("isGlobal")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到isGlobal参数信息"); + } + String isGlobal = json.getString("isGlobal"); + if(!json.containsKey("period")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警间隔参数信息"); + } + String period = json.getString("period"); + if(!json.containsKey("todoType")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到操作类型参数信息"); + } + String ruleId = json.getString("ruleId"); + if(!json.containsKey("ruleId")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到告警规则参数信息"); + } + String todoType = json.getString("todoType"); + if(!json.containsKey("todoContent")){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + if("1".equals(todoType)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到回调地址参数信息"); + } + else{ + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未找到邮件模板参数信息"); + } + } + String todoContent = json.getString("todoContent"); + + AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + ruleMVO.setRuleId(ruleId); + ruleMVO.setTodoType(todoType); + ruleMVO.setTodoContent(todoContent); + JSONObject confArgs = new JSONObject(); + confArgs.put("period", period); + ruleMVO.setConfigArgs(confArgs.toJSONString()); + + try{ + ruleMVO = alarmRuleSer.modifyAlarmRule(ruleMVO); + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "操作成功"); + + }catch(Exception e){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建告警规则失败"); + e.printStackTrace(); + } + return reJson.toJSONString(); + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/ApplicationCtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/ApplicationCtl.java new file mode 100644 index 000000000..c85904651 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/ApplicationCtl.java @@ -0,0 +1,133 @@ +package com.ai.cloud.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.ai.cloud.service.inter.IApplicationSer; +import com.ai.cloud.util.Constants; +import com.ai.cloud.util.common.StringUtil; +import com.ai.cloud.vo.mvo.ApplicationInfoMVO; +import com.ai.cloud.vo.svo.ApplicationInfoSVO; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +/** + * 用户应用请求处理 + * + * @author tz + * @date 2015年11月10日 下午2:41:30 + * @version V0.3 + */ +@Controller +public class ApplicationCtl { + + @Autowired + IApplicationSer applicationSer; + + private static Logger logger = LogManager.getLogger(ApplicationCtl.class); + + /*** + * 登录后默认页面 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/applist") + public String showIndexPage(HttpServletRequest request, ModelMap root) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + if(StringUtil.isBlank(uid)){ + return "404"; + } + + List appList = applicationSer.queryUserAppListByUid(uid); + root.put("applist", appList); + return "applist"; + } + + /*** + * 创建app_code + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/appinfo/create", method = RequestMethod.POST, produces="application/json; charset=UTF-8") + @ResponseBody + public String createAppInfo(HttpServletRequest request, ModelMap root, @RequestBody String json) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if(StringUtil.isBlank(uid)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + JSONObject appJson = JSON.parseObject(json); + + String appCode = null; + if(appJson.containsKey("appCode")){ + appCode = appJson.getString("appCode"); + } + if(StringUtil.isBlank(appCode)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建应用名称为空"); + } + + ApplicationInfoSVO appSVO = new ApplicationInfoSVO(); + appSVO.setAppCode(appCode); + appSVO.setUid(uid); + appSVO.setSts(Constants.STR_VAL_A); + return applicationSer.createApplicationInfo(appSVO); + } + + /*** + * 登录后默认页面 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/appinfo/delete/{appId}", method = RequestMethod.POST, produces="application/json; charset=UTF-8") + @ResponseBody + public String deleteAppInfo(HttpServletRequest request, ModelMap root, @PathVariable("appId") String appId) throws Exception { + HttpSession session = request.getSession(); + String uid = (String) session.getAttribute("uid"); + + JSONObject reJson = new JSONObject(); + + if(StringUtil.isBlank(uid)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时"); + return reJson.toJSONString(); + } + + if(StringUtil.isBlank(appId)){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "删除应用编码不存在"); + } + + ApplicationInfoSVO appSVO = new ApplicationInfoSVO(); + appSVO.setAppId(appId); + return applicationSer.delete(appSVO); + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java index 4df417c04..46cbc2c7d 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java @@ -25,8 +25,10 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.ai.cloud.service.inter.IQueryTraceLogSer; import com.ai.cloud.service.inter.IUserSer; import com.ai.cloud.util.Constants; +import com.ai.cloud.vo.mvo.MenuInfoMVO; import com.ai.cloud.vo.mvo.TraceLogEntry; import com.ai.cloud.vo.mvo.UserInfoMVO; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; /** @@ -121,10 +123,10 @@ public class HelloSkyWalkingUICtl { return arg0.getColId().compareTo(arg1.getColId()); } }); - int m = 1; - for (TraceLogEntry tmpEntry : valueList) { - logger.info("sort result level:{} : {}", m++, tmpEntry); - } +// int m = 1; +// for (TraceLogEntry tmpEntry : valueList) { +// logger.info("sort result level:{} : {}", m++, tmpEntry); +// } long beginTime = valueList.get(0).getStartDate(); root.put("traceId", traceId); root.put("valueList", valueList); @@ -172,13 +174,50 @@ public class HelloSkyWalkingUICtl { session.setAttribute("isLogin", "1"); session.setAttribute("uid", reUserInfo.getUid()); session.setAttribute("userName", reUserInfo.getUserName()); - session.setAttribute("menuList", ""); + + JSONArray menuArr = new JSONArray(); + List menuList = new ArrayList(); + menuList.add(new MenuInfoMVO("1", "应用配置", "applist")); + menuArr.addAll(menuList); + session.setAttribute("menuList", menuArr.toJSONString()); }else{ json.put("result", "FAIL"); json.put("msg", "用户名或者密码错误"); } return json.toJSONString(); } + + /*** + * 登录页面 + * + * @param root + * @return + * @throws Exception + */ + @RequestMapping(value = "/regist") + public String registPage(ModelMap root) throws Exception { + return "regist"; + } + + /*** + * 登录页面 + * + * @param root + * @return + * @throws Exception + */ + + @RequestMapping(value = "/regist/{userName}/{password}", method = RequestMethod.POST, produces="application/json; charset=UTF-8") + @ResponseBody + public String registAction(HttpServletRequest request, ModelMap root, @PathVariable("userName") String userName, @PathVariable("password") String password) throws Exception { + UserInfoMVO userInfo = new UserInfoMVO(); + userInfo.setUserName(userName); + userInfo.setPassword(password); + userInfo.setRoleType(Constants.ROLE_TYPE_USER); + userInfo.setSts(Constants.STR_VAL_A); + JSONObject reUserInfo = userSer.regist(userInfo); + return reUserInfo.toJSONString(); + } /*** * 退出 @@ -188,8 +227,17 @@ public class HelloSkyWalkingUICtl { * @throws Exception */ @RequestMapping(value = "/logout") - public String logout(ModelMap root) throws Exception { - return "traceLog"; + @ResponseBody + public String logout(HttpServletRequest request, ModelMap root) throws Exception { + HttpSession session = request.getSession(); + session.removeAttribute("isLogin"); + session.removeAttribute("uid"); + session.removeAttribute("userName"); + session.removeAttribute("menuList"); + JSONObject json = new JSONObject(); + json.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + json.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "退出成功"); + return json.toJSONString(); } /*** diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java new file mode 100644 index 000000000..ffbf572a7 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/AlarmRuleMDAO.java @@ -0,0 +1,122 @@ +package com.ai.cloud.dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementCreator; +import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Repository; + +import com.ai.cloud.dao.inter.IAlarmRuleMDAO; +import com.ai.cloud.vo.mvo.AlarmRuleMVO; + +@Repository +public class AlarmRuleMDAO implements IAlarmRuleMDAO { + + @Autowired + private JdbcTemplate jdbcTemplate; + + private static Logger logger = LogManager.getLogger(AlarmRuleMDAO.class); + + @Override + public AlarmRuleMVO queryUserDefaultAlarmRule(AlarmRuleMVO rule) { + final AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time from alarm_rule a where a.uid = ? and a.is_global = '1' and a.sts='A'"; + final Object[] params = new Object[] { rule.getUid() }; + jdbcTemplate.query(sql, params, new RowCallbackHandler() { + @Override + public void processRow(ResultSet rs) throws SQLException { + ruleMVO.setRuleId(rs.getString("rule_id")); + ruleMVO.setAppId(rs.getString("app_id")); + ruleMVO.setUid(rs.getString("uid")); + ruleMVO.setConfigArgs(rs.getString("config_args")); + ruleMVO.setIsGlobal(rs.getString("is_global")); + ruleMVO.setTodoType(rs.getString("todo_type")); + ruleMVO.setTodoContent(rs.getString("todo_content")); + ruleMVO.setCreateTime(rs.getTimestamp("create_time")); + ruleMVO.setSts(rs.getString("sts")); + ruleMVO.setModifyTime(rs.getTimestamp("modify_time")); + } + }); + logger.info("result : {}", ruleMVO); + return ruleMVO; + } + + @Override + public AlarmRuleMVO queryAppAlarmRule(AlarmRuleMVO rule) { + final AlarmRuleMVO ruleMVO = new AlarmRuleMVO(); + String sql = "select rule_id,app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time from alarm_rule a where a.uid = ? and app_id = ? and a.is_global = '0' and a.sts='A'"; + final Object[] params = new Object[] { rule.getUid(), rule.getAppId() }; + jdbcTemplate.query(sql, params, new RowCallbackHandler() { + @Override + public void processRow(ResultSet rs) throws SQLException { + ruleMVO.setRuleId(rs.getString("rule_id")); + ruleMVO.setAppId(rs.getString("app_id")); + ruleMVO.setUid(rs.getString("uid")); + ruleMVO.setConfigArgs(rs.getString("config_args")); + ruleMVO.setIsGlobal(rs.getString("is_global")); + ruleMVO.setTodoType(rs.getString("todo_type")); + ruleMVO.setTodoContent(rs.getString("todo_content")); + ruleMVO.setCreateTime(rs.getTimestamp("create_time")); + ruleMVO.setSts(rs.getString("sts")); + ruleMVO.setModifyTime(rs.getTimestamp("modify_time")); + } + }); + logger.info("result : {}", ruleMVO); + return ruleMVO; + } + + @Override + public AlarmRuleMVO createAlarmRule(final AlarmRuleMVO ruleMVO) { + final String sql = "insert into alarm_rule (app_id,uid,config_args,is_global,todo_type,todo_content,create_time,sts,modify_time) values (?,?,?,?,?,?,sysdate(),?,sysdate())"; + KeyHolder keyHolder = new GeneratedKeyHolder(); + + int count = jdbcTemplate.update(new PreparedStatementCreator() { + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { + PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + int i = 0; + pstmt.setString(++i, ruleMVO.getAppId()); + pstmt.setString(++i, ruleMVO.getUid()); + pstmt.setString(++i, ruleMVO.getConfigArgs()); + pstmt.setString(++i, ruleMVO.getIsGlobal()); + pstmt.setString(++i, ruleMVO.getTodoType()); + pstmt.setString(++i, ruleMVO.getTodoContent()); + pstmt.setString(++i, ruleMVO.getSts()); + return pstmt; + } + }, keyHolder); + logger.info("创建应用成功:{}", keyHolder.getKey().intValue()); + ruleMVO.setRuleId(keyHolder.getKey().toString()); + + return ruleMVO; + } + + @Override + public AlarmRuleMVO modifyAlarmRule(final AlarmRuleMVO ruleMVO) { + final String sql = "update alarm_rule set config_args = ?,todo_type = ?,todo_content = ? where rule_id = ?"; + + int count = jdbcTemplate.update(new PreparedStatementCreator() { + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { + PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + int i = 0; + pstmt.setString(++i, ruleMVO.getConfigArgs()); + pstmt.setString(++i, ruleMVO.getTodoType()); + pstmt.setString(++i, ruleMVO.getTodoContent()); + pstmt.setString(++i, ruleMVO.getRuleId()); + return pstmt; + } + }); + + return ruleMVO; + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/ApplicationMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/ApplicationMDAO.java new file mode 100644 index 000000000..871bdff6b --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/ApplicationMDAO.java @@ -0,0 +1,106 @@ +package com.ai.cloud.dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementCreator; +import org.springframework.jdbc.core.PreparedStatementSetter; +import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Repository; + +import com.ai.cloud.dao.inter.IApplicationMDAO; +import com.ai.cloud.vo.mvo.ApplicationInfoMVO; +import com.ai.cloud.vo.svo.ApplicationInfoSVO; + +@Repository +public class ApplicationMDAO implements IApplicationMDAO { + + @Autowired + private JdbcTemplate jdbcTemplate; + + private static Logger logger = LogManager.getLogger(ApplicationMDAO.class); + + @Override + public List queryAppListByUid(String uid) { + String sqlQuery = "select a.app_id,a.uid,a.app_code,a.create_time,a.sts from application_info a where a.uid = ? and a.sts= 'A'"; + final Object[] params = new Object[] { uid }; + final List appList = new ArrayList(); + jdbcTemplate.query(sqlQuery, params, new RowCallbackHandler() { // editing + public void processRow(ResultSet rs) throws SQLException { + ApplicationInfoMVO mvo = new ApplicationInfoMVO(); + mvo.setAppId(rs.getString("app_id")); + mvo.setUid(rs.getString("uid")); + mvo.setAppCode(rs.getString("app_code")); + mvo.setCreateTime(rs.getTimestamp("create_time")); + mvo.setSts(rs.getString("sts")); + appList.add(mvo); + } + }); + + return appList; + } + + @Override + public ApplicationInfoSVO addApplicationInfo(final ApplicationInfoSVO appSVO) { + final String sql = "insert into application_info(uid,app_code,create_time,sts) values(?,?,sysdate(),?)"; + KeyHolder keyHolder = new GeneratedKeyHolder(); + + int count = jdbcTemplate.update(new PreparedStatementCreator() { + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { + PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + int i = 0; + pstmt.setString(++i, appSVO.getUid()); + pstmt.setString(++i, appSVO.getAppCode()); + pstmt.setString(++i, appSVO.getSts()); + return pstmt; + } + }, keyHolder); + logger.info("创建应用成功:{}", keyHolder.getKey().intValue()); + appSVO.setAppId(keyHolder.getKey().toString()); + + return appSVO; + } + + @Override + public void deleteAppInfoById(final ApplicationInfoSVO appSVO) { + String sql = "update application_info set sts = 'P' where app_id = ?"; + int count = jdbcTemplate.update(sql, new PreparedStatementSetter() { + @Override + public void setValues(PreparedStatement pstmt) throws SQLException { + pstmt.setString(1, appSVO.getAppId()); + } + }); + } + + @Override + public List queryUserAppListByAppCode(ApplicationInfoSVO appSVO) { + String sqlQuery = "select a.app_id,a.uid,a.app_code,a.create_time,a.sts from application_info a where a.app_code = ? and a.uid= ? and a.sts= 'A'"; + final Object[] params = new Object[] { appSVO.getAppCode(), appSVO.getUid() }; + final List appList = new ArrayList(); + jdbcTemplate.query(sqlQuery, params, new RowCallbackHandler() { // editing + public void processRow(ResultSet rs) throws SQLException { + ApplicationInfoMVO mvo = new ApplicationInfoMVO(); + mvo.setAppId(rs.getString("app_id")); + mvo.setUid(rs.getString("uid")); + mvo.setAppCode(rs.getString("app_code")); + mvo.setCreateTime(rs.getTimestamp("create_time")); + mvo.setSts(rs.getString("sts")); + appList.add(mvo); + } + }); + + return appList; + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/UserInfoMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/UserInfoMDAO.java index 006566afa..3328e6b05 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/UserInfoMDAO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/UserInfoMDAO.java @@ -1,13 +1,20 @@ package com.ai.cloud.dao.impl; +import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementCreator; +import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; import org.springframework.stereotype.Repository; import com.ai.cloud.dao.inter.IUserInfoMDAO; @@ -15,10 +22,10 @@ import com.ai.cloud.vo.mvo.UserInfoMVO; @Repository public class UserInfoMDAO implements IUserInfoMDAO { - + @Autowired private JdbcTemplate jdbcTemplate; - + private static Logger logger = LogManager.getLogger(UserInfoMDAO.class); @Override @@ -28,14 +35,36 @@ public class UserInfoMDAO implements IUserInfoMDAO { final Object[] params = new Object[] { userName }; jdbcTemplate.query(sql, params, new RowCallbackHandler() { @Override - public void processRow(ResultSet rs) throws SQLException { + public void processRow(ResultSet rs) throws SQLException { userInfo.setUid(rs.getString("uid")); userInfo.setUserName(rs.getString("user_name")); userInfo.setPassword(rs.getString("password")); - } + } }); logger.info("result : {}", userInfo); return userInfo; } + @Override + public UserInfoMVO addUser(final UserInfoMVO userInfo) { + final String sql = "insert into user_info(user_name,password,role_type,create_time,sts,modify_time) values (?,?,?,sysdate(),?,sysdate())"; + KeyHolder keyHolder = new GeneratedKeyHolder(); + + int count = jdbcTemplate.update(new PreparedStatementCreator() { + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { + PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + int i = 0; + pstmt.setString(++i, userInfo.getUserName()); + pstmt.setString(++i, userInfo.getPassword()); + pstmt.setString(++i, userInfo.getRoleType()); + pstmt.setString(++i, userInfo.getSts()); + return pstmt; + } + }, keyHolder); + logger.info("用户注册成功:{}", keyHolder.getKey().intValue()); + + userInfo.setUid(keyHolder.getKey().toString()); + return userInfo; + } + } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IAlarmRuleMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IAlarmRuleMDAO.java new file mode 100644 index 000000000..9b8c9d84c --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IAlarmRuleMDAO.java @@ -0,0 +1,15 @@ +package com.ai.cloud.dao.inter; + +import com.ai.cloud.vo.mvo.AlarmRuleMVO; + +public interface IAlarmRuleMDAO { + + public AlarmRuleMVO queryUserDefaultAlarmRule(AlarmRuleMVO rule); + + public AlarmRuleMVO queryAppAlarmRule(AlarmRuleMVO ruleMVO); + + public AlarmRuleMVO createAlarmRule(AlarmRuleMVO ruleMVO); + + public AlarmRuleMVO modifyAlarmRule(AlarmRuleMVO ruleMVO); + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IApplicationMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IApplicationMDAO.java new file mode 100644 index 000000000..5a13b07c5 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IApplicationMDAO.java @@ -0,0 +1,17 @@ +package com.ai.cloud.dao.inter; + +import java.util.List; + +import com.ai.cloud.vo.mvo.ApplicationInfoMVO; +import com.ai.cloud.vo.svo.ApplicationInfoSVO; + +public interface IApplicationMDAO { + + public List queryAppListByUid(String uid); + + public ApplicationInfoSVO addApplicationInfo(ApplicationInfoSVO appSVO); + + public List queryUserAppListByAppCode(ApplicationInfoSVO appCode); + + public void deleteAppInfoById(ApplicationInfoSVO appSVO); +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IUserInfoMDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IUserInfoMDAO.java index d6ff47f0e..894c743c2 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IUserInfoMDAO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IUserInfoMDAO.java @@ -6,4 +6,6 @@ public interface IUserInfoMDAO { public UserInfoMVO queryUserInfoByName(String userName); + public UserInfoMVO addUser(final UserInfoMVO userInfo); + } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/AlarmRuleSerImpl.java b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/AlarmRuleSerImpl.java new file mode 100644 index 000000000..d1ae8b5c6 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/AlarmRuleSerImpl.java @@ -0,0 +1,40 @@ +package com.ai.cloud.service.impl; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.ai.cloud.dao.inter.IAlarmRuleMDAO; +import com.ai.cloud.service.inter.IAlarmRuleSer; +import com.ai.cloud.vo.mvo.AlarmRuleMVO; + +@Service +public class AlarmRuleSerImpl implements IAlarmRuleSer { + + @Autowired + IAlarmRuleMDAO alarmRuleMDAO; + + private static Logger logger = LogManager.getLogger(ApplicationSerImpl.class); + + @Override + public AlarmRuleMVO queryUserDefaultAlarmRule(AlarmRuleMVO rule) { + return alarmRuleMDAO.queryUserDefaultAlarmRule(rule); + } + + @Override + public AlarmRuleMVO queryAppAlarmRule(AlarmRuleMVO ruleMVO) { + return alarmRuleMDAO.queryAppAlarmRule(ruleMVO); + } + + @Override + public AlarmRuleMVO createAlarmRule(AlarmRuleMVO ruleMVO) { + return alarmRuleMDAO.createAlarmRule(ruleMVO); + } + + @Override + public AlarmRuleMVO modifyAlarmRule(AlarmRuleMVO ruleMVO) { + return alarmRuleMDAO.modifyAlarmRule(ruleMVO); + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/ApplicationSerImpl.java b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/ApplicationSerImpl.java new file mode 100644 index 000000000..cfccd65ea --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/ApplicationSerImpl.java @@ -0,0 +1,73 @@ +package com.ai.cloud.service.impl; + +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.ai.cloud.dao.impl.ApplicationMDAO; +import com.ai.cloud.dao.inter.IApplicationMDAO; +import com.ai.cloud.service.inter.IApplicationSer; +import com.ai.cloud.util.Constants; +import com.ai.cloud.vo.mvo.ApplicationInfoMVO; +import com.ai.cloud.vo.svo.ApplicationInfoSVO; +import com.alibaba.fastjson.JSONObject; + +@Service +public class ApplicationSerImpl implements IApplicationSer { + + @Autowired + IApplicationMDAO applicationMDAO; + + private static Logger logger = LogManager.getLogger(ApplicationSerImpl.class); + + @Override + public List queryUserAppListByUid(String uid) { + return applicationMDAO.queryAppListByUid(uid); + } + + @Override + public String createApplicationInfo(ApplicationInfoSVO appSVO) { + + JSONObject reJson = new JSONObject(); + + List appList = applicationMDAO.queryUserAppListByAppCode(appSVO); + if(appList != null && appList.size()>0){ + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "当前用户下存在相同应用名"); + return reJson.toJSONString(); + } + + try { + applicationMDAO.addApplicationInfo(appSVO); + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建应用信息成功"); + } catch (Exception e) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "创建应用信息异常"); + e.printStackTrace(); + return reJson.toJSONString(); + } + return reJson.toJSONString(); + } + + @Override + public String delete(ApplicationInfoSVO appSVO) { + JSONObject reJson = new JSONObject(); + + try { + applicationMDAO.deleteAppInfoById(appSVO); + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "删除应用信息成功"); + } catch (Exception e) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "删除应用信息异常"); + e.printStackTrace(); + return reJson.toJSONString(); + } + return reJson.toJSONString(); + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/UserSerImpl.java b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/UserSerImpl.java index 9388b6961..5acc7c50f 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/UserSerImpl.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/UserSerImpl.java @@ -1,23 +1,55 @@ package com.ai.cloud.service.impl; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ai.cloud.dao.inter.IUserInfoMDAO; import com.ai.cloud.service.inter.IUserSer; +import com.ai.cloud.util.Constants; +import com.ai.cloud.util.common.StringUtil; import com.ai.cloud.vo.mvo.UserInfoMVO; +import com.alibaba.fastjson.JSONObject; @Service public class UserSerImpl implements IUserSer { - + @Autowired IUserInfoMDAO userInfoMDAO; + private static Logger logger = LogManager.getLogger(UserSerImpl.class); + @Override - public UserInfoMVO login(UserInfoMVO userInfo){ + public UserInfoMVO login(UserInfoMVO userInfo) { String userName = userInfo.getUserName(); userInfo = userInfoMDAO.queryUserInfoByName(userName); return userInfo; } - + + @Override + public JSONObject regist(UserInfoMVO userInfo) { + String userName = userInfo.getUserName(); + JSONObject reJson = new JSONObject(); + UserInfoMVO reUserInfo = userInfoMDAO.queryUserInfoByName(userName); + if (reUserInfo != null && !StringUtil.isBlank(reUserInfo.getUid())) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户已经存在"); + return reJson; + } else { + try { + userInfoMDAO.addUser(userInfo); + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "注册成功"); + } catch (Exception e) { + reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL); + reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户注册失败"); + e.printStackTrace(); + return reJson; + } + } + + return reJson; + } + } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IAlarmRuleSer.java b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IAlarmRuleSer.java new file mode 100644 index 000000000..ac7c3dde6 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IAlarmRuleSer.java @@ -0,0 +1,15 @@ +package com.ai.cloud.service.inter; + +import com.ai.cloud.vo.mvo.AlarmRuleMVO; + +public interface IAlarmRuleSer { + + public AlarmRuleMVO queryUserDefaultAlarmRule(AlarmRuleMVO rule); + + public AlarmRuleMVO queryAppAlarmRule(AlarmRuleMVO ruleMVO); + + public AlarmRuleMVO createAlarmRule(AlarmRuleMVO ruleMVO); + + public AlarmRuleMVO modifyAlarmRule(AlarmRuleMVO ruleMVO); + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IApplicationSer.java b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IApplicationSer.java new file mode 100644 index 000000000..8272156d5 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IApplicationSer.java @@ -0,0 +1,22 @@ +package com.ai.cloud.service.inter; + +import java.util.List; + +import com.ai.cloud.vo.mvo.ApplicationInfoMVO; +import com.ai.cloud.vo.svo.ApplicationInfoSVO; + +/** + * + * @author tz + * @date 2015年11月18日 下午5:56:04 + * @version V0.1 + */ +public interface IApplicationSer { + + public List queryUserAppListByUid(String uid); + + public String createApplicationInfo(ApplicationInfoSVO appSVO); + + public String delete(ApplicationInfoSVO appSVO); + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IUserSer.java b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IUserSer.java index 2ab14d7cb..dff6a224f 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IUserSer.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IUserSer.java @@ -1,9 +1,12 @@ package com.ai.cloud.service.inter; import com.ai.cloud.vo.mvo.UserInfoMVO; +import com.alibaba.fastjson.JSONObject; public interface IUserSer { public UserInfoMVO login(UserInfoMVO userInfo); + public JSONObject regist(UserInfoMVO userInfo); + } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java index 2943b2000..c90e02aa4 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java @@ -57,5 +57,21 @@ public class Constants { put("9", "MISSING"); } }; + + public static final String JSON_RESULT_KEY_RESULT = "result"; + public static final String JSON_RESULT_KEY_RESULT_OK = "OK"; + public static final String JSON_RESULT_KEY_RESULT_FAIL = "FAIL"; + + public static final String JSON_RESULT_KEY_RESULT_MSG = "msg"; + public static final String JSON_RESULT_KEY_RESULT_DATA = "data"; + + public static final String ROLE_TYPE_USER = "user"; + public static final String ROLE_TYPE_ADMIN = "admin"; + + public static final String STR_VAL_A = "A"; + public static final String STR_VAL_P = "P"; + + public static final String IS_GLOBAL_FALG_0 = "0"; + public static final String IS_GLOBAL_FALG_1 = "1"; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/AlarmRuleMVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/AlarmRuleMVO.java new file mode 100644 index 000000000..2fc58dabd --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/AlarmRuleMVO.java @@ -0,0 +1,7 @@ +package com.ai.cloud.vo.mvo; + +import com.ai.cloud.vo.svo.AlarmRuleSVO; + +public class AlarmRuleMVO extends AlarmRuleSVO { + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/ApplicationInfoMVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/ApplicationInfoMVO.java new file mode 100644 index 000000000..c5b72134f --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/ApplicationInfoMVO.java @@ -0,0 +1,7 @@ +package com.ai.cloud.vo.mvo; + +import com.ai.cloud.vo.svo.ApplicationInfoSVO; + +public class ApplicationInfoMVO extends ApplicationInfoSVO{ + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/MenuInfoMVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/MenuInfoMVO.java new file mode 100644 index 000000000..26411452f --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/MenuInfoMVO.java @@ -0,0 +1,51 @@ +package com.ai.cloud.vo.mvo; + +public class MenuInfoMVO { + + private String menuId; + + private String menuName; + + private String url; + + public MenuInfoMVO() { + super(); + } + + public MenuInfoMVO(String menuId, String menuName, String url) { + super(); + this.menuId = menuId; + this.menuName = menuName; + this.url = url; + } + + public String getMenuId() { + return menuId; + } + + public void setMenuId(String menuId) { + this.menuId = menuId; + } + + public String getMenuName() { + return menuName; + } + + public void setMenuName(String menuName) { + this.menuName = menuName; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String toString() { + return "MenuInfoMVO [menuId=" + menuId + ", menuName=" + menuName + ", url=" + url + "]"; + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java index b2e693af7..b5a785f8f 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java @@ -149,9 +149,9 @@ public class TraceLogEntry extends Span { result.statusCodeName = statusCodeName; result.applicationIdStr = result.applicationId; - if (!StringUtil.isBlank(result.viewPointId) && result.viewPointId.length() > 40) { - result.viewPointIdSub = result.viewPointId.substring(0, 20) + "..." - + result.viewPointId.substring(result.viewPointId.length() - 20); + if (!StringUtil.isBlank(result.viewPointId) && result.viewPointId.length() > 60) { + result.viewPointIdSub = result.viewPointId.substring(0, 30) + "..." + + result.viewPointId.substring(result.viewPointId.length() - 30); } else { result.viewPointIdSub = result.viewPointId; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/UserInfoMVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/UserInfoMVO.java index 9b3370347..a882fc354 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/UserInfoMVO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/UserInfoMVO.java @@ -1,38 +1,7 @@ package com.ai.cloud.vo.mvo; -public class UserInfoMVO { - private String uid; - - private String userName; - - private String password; +import com.ai.cloud.vo.svo.UserInfoSVO; - public String getUid() { - return uid; - } +public class UserInfoMVO extends UserInfoSVO { - public void setUid(String uid) { - this.uid = uid; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "UserInfoMVO [uid=" + uid + ", userName=" + userName + ", password=" + password + "]"; - } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java new file mode 100644 index 000000000..64d3ba350 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/AlarmRuleSVO.java @@ -0,0 +1,119 @@ +package com.ai.cloud.vo.svo; + +import java.sql.Timestamp; + +public class AlarmRuleSVO { + + private String ruleId; + + private String appId; + + private String uid; + + private String configArgs; + + private String isGlobal; + + private String todoType; + + private String todoContent; + + private Timestamp createTime; + + private String sts; + + private Timestamp modifyTime; + + public String getRuleId() { + return ruleId; + } + + public void setRuleId(String ruleId) { + this.ruleId = ruleId; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getConfigArgs() { + return configArgs; + } + + public void setConfigArgs(String configArgs) { + this.configArgs = configArgs; + } + + public String getIsGlobal() { + return isGlobal; + } + + public void setIsGlobal(String isGlobal) { + this.isGlobal = isGlobal; + } + + public String getTodoType() { + return todoType; + } + + public void setTodoType(String todoType) { + this.todoType = todoType; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public String getSts() { + return sts; + } + + public void setSts(String sts) { + this.sts = sts; + } + + public String getTodoContent() { + return todoContent; + } + + public void setTodoContent(String todoContent) { + this.todoContent = todoContent; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + + @Override + public String toString() { + return "AlarmRuleSVO [ruleId=" + ruleId + ", appId=" + appId + ", uid=" + uid + ", configArgs=" + configArgs + + ", isGlobal=" + isGlobal + ", todoType=" + todoType + ", todoContent=" + todoContent + ", createTime=" + + createTime + ", sts=" + sts + ", modifyTime=" + modifyTime + ", getRuleId()=" + getRuleId() + + ", getAppId()=" + getAppId() + ", getUid()=" + getUid() + ", getConfigArgs()=" + getConfigArgs() + + ", getIsGlobal()=" + getIsGlobal() + ", getTodoType()=" + getTodoType() + ", getCreateTime()=" + + getCreateTime() + ", getSts()=" + getSts() + ", getTodoContent()=" + getTodoContent() + + ", getModifyTime()=" + getModifyTime() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + + ", toString()=" + super.toString() + "]"; + } + +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ApplicationInfoSVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ApplicationInfoSVO.java new file mode 100644 index 000000000..cdfe17aa3 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/ApplicationInfoSVO.java @@ -0,0 +1,62 @@ +package com.ai.cloud.vo.svo; + +import java.sql.Timestamp; + +public class ApplicationInfoSVO { + + private String appId; + + private String uid; + + private String appCode; + + private Timestamp createTime; + + private String sts; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getAppCode() { + return appCode; + } + + public void setAppCode(String appCode) { + this.appCode = appCode; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public String getSts() { + return sts; + } + + public void setSts(String sts) { + this.sts = sts; + } + + @Override + public String toString() { + return "ApplicationInfoSVO [appId=" + appId + ", uid=" + uid + ", appCode=" + appCode + ", createTime=" + + createTime + ", sts=" + sts + "]"; + } +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/UserInfoSVO.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/UserInfoSVO.java new file mode 100644 index 000000000..ed5fa8be3 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/svo/UserInfoSVO.java @@ -0,0 +1,82 @@ +package com.ai.cloud.vo.svo; + +import java.sql.Timestamp; + +public class UserInfoSVO { + private String uid; + + private String userName; + + private String password; + + private String roleType; + + private Timestamp createTime; + + private String sts; + + private Timestamp modifyTime; + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRoleType() { + return roleType; + } + + public void setRoleType(String roleType) { + this.roleType = roleType; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public String getSts() { + return sts; + } + + public void setSts(String sts) { + this.sts = sts; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + + @Override + public String toString() { + return "UserInfoSVO [uid=" + uid + ", userName=" + userName + ", password=" + password + ", roleType=" + + roleType + ", createTime=" + createTime + ", sts=" + sts + ", modifyTime=" + modifyTime + "]"; + } + +} diff --git a/skywalking-webui/src/main/webapp/ftl/applist.ftl b/skywalking-webui/src/main/webapp/ftl/applist.ftl new file mode 100644 index 000000000..ed67c48b0 --- /dev/null +++ b/skywalking-webui/src/main/webapp/ftl/applist.ftl @@ -0,0 +1,398 @@ +<#import "./lib/ai.cloud/common.ftl" as common> + + + + + +Sky Walking + + + + + + + +
+ + + + + + + + + + + + + +<#if applist??> + +<#list applist as appInfo> + + + + + + + + +
+ +   + +   + +
序号应用名称操作
${appInfo_index + 1}${appInfo.appCode!} + + + +
+
+ + <@common.importJavaScript /> + + + \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/ftl/index.ftl b/skywalking-webui/src/main/webapp/ftl/index.ftl index a6b9a013a..1c745a999 100644 --- a/skywalking-webui/src/main/webapp/ftl/index.ftl +++ b/skywalking-webui/src/main/webapp/ftl/index.ftl @@ -21,7 +21,7 @@ + <@common.importJavaScript /> diff --git a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl index 36ee399ed..a9d9f402a 100644 --- a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl +++ b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl @@ -3,6 +3,7 @@ + @@ -29,7 +30,7 @@ ${userInfo} + + <@common.importJavaScript /> + + + \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/js/jquery/jquery-md5.js b/skywalking-webui/src/main/webapp/js/jquery/jquery-md5.js new file mode 100644 index 000000000..bbbb85007 --- /dev/null +++ b/skywalking-webui/src/main/webapp/js/jquery/jquery-md5.js @@ -0,0 +1,250 @@ +/** + * jQuery MD5 hash algorithm function + * + * + * Calculate the md5 hash of a String + * String $.md5 ( String str ) + * + * + * Calculates the MD5 hash of str using the » RSA Data Security, Inc. MD5 + * Message-Digest Algorithm, and returns that hash. MD5 (Message-Digest + * algorithm 5) is a widely-used cryptographic hash function with a 128-bit hash + * value. MD5 has been employed in a wide variety of security applications, and + * is also commonly used to check the integrity of data. The generated hash is + * also non-reversable. Data cannot be retrieved from the message digest, the + * digest uniquely identifies the data. MD5 was developed by Professor Ronald L. + * Rivest in 1994. Its 128 bit (16 byte) message digest makes it a faster + * implementation than SHA-1. This script is used to process a variable length + * message into a fixed-length output of 128 bits using the MD5 algorithm. It is + * fully compatible with UTF-8 encoding. It is very useful when u want to + * transfer encrypted passwords over the internet. If you plan using UTF-8 + * encoding in your project don't forget to set the page encoding to UTF-8 + * (Content-Type meta tag). This function orginally get from the WebToolkit and + * rewrite for using as the jQuery plugin. + * + * Example Code + * $.md5("I'm Persian."); + * Result + * "b8c901d0f02223f9761016cfff9d68df" + * + * + * @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com > + * @link http://www.semnanweb.com/jquery-plugin/md5.html + * @see http://www.webtoolkit.info/ + * @license http://www.gnu.org/licenses/gpl.html [GNU General Public License] + * @param {jQuery} + * {md5:function(string)) + * @return string + */ + +(function($) { + + var rotateLeft = function(lValue, iShiftBits) { + return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); + } + + var addUnsigned = function(lX, lY) { + var lX4, lY4, lX8, lY8, lResult; + lX8 = (lX & 0x80000000); + lY8 = (lY & 0x80000000); + lX4 = (lX & 0x40000000); + lY4 = (lY & 0x40000000); + lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); + if (lX4 & lY4) + return (lResult ^ 0x80000000 ^ lX8 ^ lY8); + if (lX4 | lY4) { + if (lResult & 0x40000000) + return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); + else + return (lResult ^ 0x40000000 ^ lX8 ^ lY8); + } else { + return (lResult ^ lX8 ^ lY8); + } + } + + var F = function(x, y, z) { + return (x & y) | ((~x) & z); + } + + var G = function(x, y, z) { + return (x & z) | (y & (~z)); + } + + var H = function(x, y, z) { + return (x ^ y ^ z); + } + + var I = function(x, y, z) { + return (y ^ (x | (~z))); + } + + var FF = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + + var GG = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + + var HH = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + + var II = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + + var convertToWordArray = function(string) { + var lWordCount; + var lMessageLength = string.length; + var lNumberOfWordsTempOne = lMessageLength + 8; + var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64; + var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16; + var lWordArray = Array(lNumberOfWords - 1); + var lBytePosition = 0; + var lByteCount = 0; + while (lByteCount < lMessageLength) { + lWordCount = (lByteCount - (lByteCount % 4)) / 4; + lBytePosition = (lByteCount % 4) * 8; + lWordArray[lWordCount] = (lWordArray[lWordCount] | (string + .charCodeAt(lByteCount) << lBytePosition)); + lByteCount++; + } + lWordCount = (lByteCount - (lByteCount % 4)) / 4; + lBytePosition = (lByteCount % 4) * 8; + lWordArray[lWordCount] = lWordArray[lWordCount] + | (0x80 << lBytePosition); + lWordArray[lNumberOfWords - 2] = lMessageLength << 3; + lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; + return lWordArray; + }; + + var wordToHex = function(lValue) { + var WordToHexValue = "", WordToHexValueTemp = "", lByte, lCount; + for (lCount = 0; lCount <= 3; lCount++) { + lByte = (lValue >>> (lCount * 8)) & 255; + WordToHexValueTemp = "0" + lByte.toString(16); + WordToHexValue = WordToHexValue + + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, + 2); + } + return WordToHexValue; + }; + + var uTF8Encode = function(string) { + string = string.replace(/\x0d\x0a/g, "\x0a"); + var output = ""; + for (var n = 0; n < string.length; n++) { + var c = string.charCodeAt(n); + if (c < 128) { + output += String.fromCharCode(c); + } else if ((c > 127) && (c < 2048)) { + output += String.fromCharCode((c >> 6) | 192); + output += String.fromCharCode((c & 63) | 128); + } else { + output += String.fromCharCode((c >> 12) | 224); + output += String.fromCharCode(((c >> 6) & 63) | 128); + output += String.fromCharCode((c & 63) | 128); + } + } + return output; + }; + + $.extend({ + md5 : function(string) { + var x = Array(); + var k, AA, BB, CC, DD, a, b, c, d; + var S11 = 7, S12 = 12, S13 = 17, S14 = 22; + var S21 = 5, S22 = 9, S23 = 14, S24 = 20; + var S31 = 4, S32 = 11, S33 = 16, S34 = 23; + var S41 = 6, S42 = 10, S43 = 15, S44 = 21; + string = uTF8Encode(string); + x = convertToWordArray(string); + a = 0x67452301; + b = 0xEFCDAB89; + c = 0x98BADCFE; + d = 0x10325476; + for (k = 0; k < x.length; k += 16) { + AA = a; + BB = b; + CC = c; + DD = d; + a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); + d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); + c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB); + b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); + a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); + d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); + c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613); + b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501); + a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8); + d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); + c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); + b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); + a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122); + d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193); + c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E); + b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821); + a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); + d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340); + c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); + b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); + a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); + d = GG(d, a, b, c, x[k + 10], S22, 0x2441453); + c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); + b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); + a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); + d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); + c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); + b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); + a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); + d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); + c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); + b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); + a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); + d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681); + c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); + b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); + a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); + d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); + c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); + b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); + a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); + d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); + c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); + b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05); + a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); + d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); + c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); + b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); + a = II(a, b, c, d, x[k + 0], S41, 0xF4292244); + d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97); + c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); + b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039); + a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3); + d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); + c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); + b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1); + a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); + d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); + c = II(c, d, a, b, x[k + 6], S43, 0xA3014314); + b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); + a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82); + d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); + c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); + b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391); + a = addUnsigned(a, AA); + b = addUnsigned(b, BB); + c = addUnsigned(c, CC); + d = addUnsigned(d, DD); + } + var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + + wordToHex(d); + return tempValue.toLowerCase(); + } + }); +})(jQuery); \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/js/webui-0.1.js b/skywalking-webui/src/main/webapp/js/webui-0.1.js index 757907c9a..fee057468 100644 --- a/skywalking-webui/src/main/webapp/js/webui-0.1.js +++ b/skywalking-webui/src/main/webapp/js/webui-0.1.js @@ -7,6 +7,7 @@ $().ready(function() { var baseUrl = $("#baseUrl").val(); var traceId = $("#traceId").val(); + var uid = $("#uid").val(); /** 搞个默认值测试*/ // traceId = "6fbbe463f5b74873aecaf9eb3511846e123"; @@ -21,6 +22,9 @@ $().ready(function() { changeFrameUrl(baseUrl + "/showTraceLog/" + srchKey); } } else { + if(uid>0){ + changeFrameUrl(baseUrl + "/applist"); + } $("#srchKey").val(""); } @@ -38,4 +42,35 @@ $().ready(function() { }); }); + $("#regist").bind('click', function() { + changeFrameUrl(baseUrl + "/" + $(this).attr("url")); + }); + + $("#login").bind('click', function() { + changeFrameUrl(baseUrl + "/" + $(this).attr("url")); + }); + + $("#logout").bind('click', function() { + var urlStr = baseUrl + '/logout'; + $.ajax({ + type: 'POST', + url: urlStr, + data:{}, + dataType: 'json', + async : false, + success: function(data){ + console.log(data); + var result = data.result; + if(result == 'OK'){ + window.location.reload(); + }else{ + alert(data.msg); + } + }, + error: function(xhr, type){ + alert("退出失败"); + } + }); + }); + }); From 101f44480b2de7187eeb43061f4342ba4b3abc4e Mon Sep 17 00:00:00 2001 From: Administrator <55846420@qq.com> Date: Mon, 7 Dec 2015 18:00:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skywalking-webui/src/main/sql/table.mysql | 138 ++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 skywalking-webui/src/main/sql/table.mysql diff --git a/skywalking-webui/src/main/sql/table.mysql b/skywalking-webui/src/main/sql/table.mysql new file mode 100644 index 000000000..c4dac8e51 --- /dev/null +++ b/skywalking-webui/src/main/sql/table.mysql @@ -0,0 +1,138 @@ +DROP TABLE IF EXISTS `user_info` ; + +CREATE TABLE IF NOT EXISTS `user_info` ( + `uid` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `user_name` VARCHAR(100) NOT NULL COMMENT '', + `password` VARCHAR(32) NOT NULL COMMENT '', + `role_type` VARCHAR(45) NOT NULL DEFAULT 'user' COMMENT '', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + `sts` VARCHAR(2) NOT NULL COMMENT '', + `modify_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + PRIMARY KEY (`uid`) COMMENT '', + UNIQUE INDEX `user_name_UNIQUE` (`user_name` ASC) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `user_info_ext` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `user_info_ext` ; + +CREATE TABLE IF NOT EXISTS `user_info_ext` ( + `eid` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `uid` INT NOT NULL COMMENT '', + `email` VARCHAR(200) NULL COMMENT '', + `create_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + PRIMARY KEY (`eid`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `login_log` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `login_log` ; + +CREATE TABLE IF NOT EXISTS `login_log` ( + `log_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `uid` INT NOT NULL COMMENT '', + `login_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + PRIMARY KEY (`log_id`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `application_info` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `application_info` ; + +CREATE TABLE IF NOT EXISTS `application_info` ( + `app_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `uid` INT NOT NULL COMMENT '', + `app_code` VARCHAR(200) NOT NULL COMMENT '', + `create_time` DATETIME NULL COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + PRIMARY KEY (`app_id`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `data_info` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `data_info` ; + +CREATE TABLE IF NOT EXISTS `data_info` ( + `did` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `tab_info` VARCHAR(45) NOT NULL COMMENT '', + `col_info` VARCHAR(45) NOT NULL COMMENT '', + `code` VARCHAR(45) NOT NULL COMMENT '', + `word` VARCHAR(45) NOT NULL COMMENT '', + `word_desc` VARCHAR(200) NULL COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + `create_time` DATETIME NULL COMMENT '', + PRIMARY KEY (`did`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `alarm_rule` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `alarm_rule` ; + +CREATE TABLE IF NOT EXISTS `alarm_rule` ( + `rule_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `app_id` VARCHAR(45) NULL COMMENT '', + `uid` VARCHAR(45) NOT NULL COMMENT '', + `config_args` VARCHAR(200) NULL COMMENT '', + `is_global` VARCHAR(2) NOT NULL COMMENT '', + `todo_type` VARCHAR(4) NOT NULL COMMENT '', + `todo_content` VARCHAR(1000) NULL COMMENT '', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + `modify_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', + PRIMARY KEY (`rule_id`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `include_rule` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `include_rule` ; + +CREATE TABLE IF NOT EXISTS `include_rule` ( + `irid` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `rule_value` VARCHAR(200) NULL COMMENT '', + `create_time` DATETIME NULL COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + `rule_id` INT UNSIGNED NOT NULL COMMENT '', + PRIMARY KEY (`irid`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `exclude_rule` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `exclude_rule` ; + +CREATE TABLE IF NOT EXISTS `exclude_rule` ( + `erid` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `rule_value` VARCHAR(200) NULL COMMENT '', + `create_time` DATETIME NULL COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + `rule_id` INT UNSIGNED NOT NULL COMMENT '', + PRIMARY KEY (`erid`) COMMENT '') +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `email_expression` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `email_expression` ; + +CREATE TABLE IF NOT EXISTS `email_expression` ( + `tid` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '', + `expr_name` VARCHAR(100) NOT NULL COMMENT '', + `expr_val` VARCHAR(100) NOT NULL COMMENT '', + `create_time` DATETIME NULL COMMENT '', + `sts` VARCHAR(2) NULL COMMENT '', + PRIMARY KEY (`tid`) COMMENT '') +ENGINE = InnoDB; \ No newline at end of file