├── .gitignore ├── LICENSE ├── README.md ├── README_EN.MD ├── data-center-admin ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── yjq │ │ │ └── data │ │ │ └── admin │ │ │ ├── AdminBootstrap.java │ │ │ ├── common │ │ │ ├── AlarmRuleEnum.java │ │ │ ├── BeanUtil.java │ │ │ ├── Constant.java │ │ │ ├── CookiesUtil.java │ │ │ ├── ErrorEnum.java │ │ │ ├── FreemarkerConstant.java │ │ │ ├── GlobalStatusEnum.java │ │ │ ├── MD5.java │ │ │ ├── PaginationEnum.java │ │ │ ├── ProgressEnum.java │ │ │ ├── RSAHelper.java │ │ │ ├── RoleTypeEnum.java │ │ │ ├── SqlOperationTypeEnum.java │ │ │ ├── exception │ │ │ │ ├── AbstractException.java │ │ │ │ ├── ParamInvalidException.java │ │ │ │ ├── ServiceException.java │ │ │ │ └── SessionInvalidException.java │ │ │ └── validation │ │ │ │ ├── MyValidator.java │ │ │ │ └── ValidationMarker.java │ │ │ ├── config │ │ │ ├── BeanConfig.java │ │ │ ├── FastJsonConverter.java │ │ │ └── MyFreemarkerConfig.java │ │ │ ├── mapper │ │ │ ├── IAlarmConfigMapper.java │ │ │ ├── IAlarmHistoryMapper.java │ │ │ ├── IApiInvokeRecordMapper.java │ │ │ ├── IAppInfoMapper.java │ │ │ ├── IAppUserGroupMappingMapper.java │ │ │ ├── IBaseMapper.java │ │ │ ├── ISqlOperationRecordMapper.java │ │ │ ├── ISqlTemplateMapper.java │ │ │ ├── IUserGroupMapper.java │ │ │ ├── IUserGroupMappingMapper.java │ │ │ └── IUserInfoMapper.java │ │ │ ├── model │ │ │ ├── AbstractModel.java │ │ │ ├── domain │ │ │ │ ├── AlarmConfig.java │ │ │ │ ├── AlarmHistory.java │ │ │ │ ├── ApiInvokeRecord.java │ │ │ │ ├── AppInfo.java │ │ │ │ ├── AppUserGroupMapping.java │ │ │ │ ├── SqlOperationRecord.java │ │ │ │ ├── SqlTemplate.java │ │ │ │ ├── UserGroup.java │ │ │ │ ├── UserGroupMapping.java │ │ │ │ └── UserInfo.java │ │ │ └── dto │ │ │ │ ├── AbstractDTO.java │ │ │ │ ├── request │ │ │ │ ├── AlarmConfigRequestDTO.java │ │ │ │ ├── AlarmHistoryRequestDTO.java │ │ │ │ ├── ApiInvokeRecordPageRequestDTO.java │ │ │ │ ├── PageRequestDTO.java │ │ │ │ ├── SqlOperationRecordPageRequestDTO.java │ │ │ │ ├── SqlTemplateInsertRequestDTO.java │ │ │ │ ├── SqlTemplateRequestDTO.java │ │ │ │ ├── SqlTemplateUpdateRequestDTO.java │ │ │ │ ├── UserGroupAppDTO.java │ │ │ │ └── UserGroupRequestDTO.java │ │ │ │ └── response │ │ │ │ ├── LayuiResponseDTO.java │ │ │ │ ├── PageResponseDTO.java │ │ │ │ └── ResponseDTO.java │ │ │ ├── service │ │ │ ├── AbstractBaseService.java │ │ │ ├── AlarmConfigService.java │ │ │ ├── AlarmHistoryService.java │ │ │ ├── ApiInvokeRecordService.java │ │ │ ├── AppInfoService.java │ │ │ ├── AppUserGroupMappingService.java │ │ │ ├── SqlOperationRecordService.java │ │ │ ├── SqlTemplateService.java │ │ │ ├── UserGroupMappingService.java │ │ │ ├── UserGroupService.java │ │ │ └── UserInfoService.java │ │ │ └── web │ │ │ ├── advice │ │ │ ├── ExceptionConfig.java │ │ │ └── RequestParamAspect.java │ │ │ └── controller │ │ │ ├── AbstractController.java │ │ │ ├── AlarmConfigController.java │ │ │ ├── AlarmHistoryController.java │ │ │ ├── ApiInvokeRecordController.java │ │ │ ├── ApiTestController.java │ │ │ ├── AppInfoController.java │ │ │ ├── AppUserGroupMappingController.java │ │ │ ├── LoginController.java │ │ │ ├── SqlOperationRecordController.java │ │ │ ├── SqlTemplateController.java │ │ │ ├── UserGroupController.java │ │ │ ├── UserInfoController.java │ │ │ └── test │ │ │ └── AppInfoTestController.java │ └── resources │ │ ├── META-INF │ │ └── spring-devtools.properties │ │ ├── application-dev.properties │ │ ├── application-prod.properties │ │ ├── application-sit.properties │ │ ├── application.properties │ │ ├── config │ │ └── logging-config.xml │ │ ├── mapper │ │ ├── alarm-config-sqlmap.xml │ │ ├── alarm-history-sqlmap.xml │ │ ├── api-invoke-record-sqlmap.xml │ │ ├── app-info-sqlmap.xml │ │ ├── app-user-group-mapping-sqlmap.xml │ │ ├── sql-operation-record-sqlmap.xml │ │ ├── sqltemplate-sqlmap.xml │ │ ├── user-group-mapping.xml │ │ ├── user-group-sqlmap.xml │ │ └── user-info-sqlmap.xml │ │ ├── spring-dubbo.xml │ │ └── static │ │ ├── alarm-config.html │ │ ├── alarm-history.html │ │ ├── api-invoke-record.html │ │ ├── app-manage.html │ │ ├── css │ │ └── login.css │ │ ├── images │ │ ├── l-line-white.png │ │ ├── l-line.png │ │ ├── login │ │ │ ├── login_bg.png │ │ │ ├── login_line.jpg │ │ │ └── yzm.jpg │ │ └── logo.png │ │ ├── index.html │ │ ├── js │ │ ├── jquery.cookie.js │ │ └── jsencrypt.min.js │ │ ├── layui │ │ ├── css │ │ │ ├── layui.css │ │ │ ├── layui.mobile.css │ │ │ └── modules │ │ │ │ ├── code.css │ │ │ │ ├── laydate │ │ │ │ └── default │ │ │ │ │ └── laydate.css │ │ │ │ └── layer │ │ │ │ └── default │ │ │ │ ├── icon-ext.png │ │ │ │ ├── icon.png │ │ │ │ ├── layer.css │ │ │ │ ├── loading-0.gif │ │ │ │ ├── loading-1.gif │ │ │ │ └── loading-2.gif │ │ ├── font │ │ │ ├── iconfont.eot │ │ │ ├── iconfont.svg │ │ │ ├── iconfont.ttf │ │ │ └── iconfont.woff │ │ ├── images │ │ │ └── face │ │ │ │ ├── 0.gif │ │ │ │ ├── 1.gif │ │ │ │ ├── 10.gif │ │ │ │ ├── 11.gif │ │ │ │ ├── 12.gif │ │ │ │ ├── 13.gif │ │ │ │ ├── 14.gif │ │ │ │ ├── 15.gif │ │ │ │ ├── 16.gif │ │ │ │ ├── 17.gif │ │ │ │ ├── 18.gif │ │ │ │ ├── 19.gif │ │ │ │ ├── 2.gif │ │ │ │ ├── 20.gif │ │ │ │ ├── 21.gif │ │ │ │ ├── 22.gif │ │ │ │ ├── 23.gif │ │ │ │ ├── 24.gif │ │ │ │ ├── 25.gif │ │ │ │ ├── 26.gif │ │ │ │ ├── 27.gif │ │ │ │ ├── 28.gif │ │ │ │ ├── 29.gif │ │ │ │ ├── 3.gif │ │ │ │ ├── 30.gif │ │ │ │ ├── 31.gif │ │ │ │ ├── 32.gif │ │ │ │ ├── 33.gif │ │ │ │ ├── 34.gif │ │ │ │ ├── 35.gif │ │ │ │ ├── 36.gif │ │ │ │ ├── 37.gif │ │ │ │ ├── 38.gif │ │ │ │ ├── 39.gif │ │ │ │ ├── 4.gif │ │ │ │ ├── 40.gif │ │ │ │ ├── 41.gif │ │ │ │ ├── 42.gif │ │ │ │ ├── 43.gif │ │ │ │ ├── 44.gif │ │ │ │ ├── 45.gif │ │ │ │ ├── 46.gif │ │ │ │ ├── 47.gif │ │ │ │ ├── 48.gif │ │ │ │ ├── 49.gif │ │ │ │ ├── 5.gif │ │ │ │ ├── 50.gif │ │ │ │ ├── 51.gif │ │ │ │ ├── 52.gif │ │ │ │ ├── 53.gif │ │ │ │ ├── 54.gif │ │ │ │ ├── 55.gif │ │ │ │ ├── 56.gif │ │ │ │ ├── 57.gif │ │ │ │ ├── 58.gif │ │ │ │ ├── 59.gif │ │ │ │ ├── 6.gif │ │ │ │ ├── 60.gif │ │ │ │ ├── 61.gif │ │ │ │ ├── 62.gif │ │ │ │ ├── 63.gif │ │ │ │ ├── 64.gif │ │ │ │ ├── 65.gif │ │ │ │ ├── 66.gif │ │ │ │ ├── 67.gif │ │ │ │ ├── 68.gif │ │ │ │ ├── 69.gif │ │ │ │ ├── 7.gif │ │ │ │ ├── 70.gif │ │ │ │ ├── 71.gif │ │ │ │ ├── 8.gif │ │ │ │ └── 9.gif │ │ ├── lay │ │ │ └── modules │ │ │ │ ├── carousel.js │ │ │ │ ├── code.js │ │ │ │ ├── colorpicker.js │ │ │ │ ├── element.js │ │ │ │ ├── flow.js │ │ │ │ ├── form.js │ │ │ │ ├── jquery.js │ │ │ │ ├── laydate.js │ │ │ │ ├── layedit.js │ │ │ │ ├── layer.js │ │ │ │ ├── laypage.js │ │ │ │ ├── laytpl.js │ │ │ │ ├── mobile.js │ │ │ │ ├── rate.js │ │ │ │ ├── slider.js │ │ │ │ ├── table.js │ │ │ │ ├── tree.js │ │ │ │ ├── upload.js │ │ │ │ └── util.js │ │ ├── layui.all.js │ │ └── layui.js │ │ ├── login.html │ │ ├── nav.html │ │ └── user-group.html │ └── test │ └── java │ └── com │ └── yjq │ └── data │ └── test │ ├── BeetlTest.java │ └── FreemarkerTest.java ├── data-center-client ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── yjq │ └── data │ └── client │ └── api │ ├── core │ ├── DataQueryErrorEnum.java │ ├── DataQueryException.java │ ├── Page.java │ └── ResponseMessage.java │ ├── invoke │ └── DataQueryInvoker.java │ ├── manage │ ├── DataQueryManage.java │ └── DataQueryManageImpl.java │ └── query │ ├── AbstractQuery.java │ ├── PageQuery.java │ └── SimpleQuery.java ├── data-center-service ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── yjq │ │ └── data │ │ └── service │ │ ├── ServiceBootstrap.java │ │ ├── alarm │ │ ├── AlarmChecker.java │ │ ├── AlarmMessageSender.java │ │ ├── AlarmMessageSenderImpl.java │ │ ├── AlarmScheduleTask.java │ │ └── MailSendHandler.java │ │ ├── api │ │ └── impl │ │ │ └── DataQueryInvokerImpl.java │ │ ├── aspect │ │ └── ApiInvokeRecordAspect.java │ │ ├── common │ │ ├── AlarmRuleEnum.java │ │ ├── BeanUtil.java │ │ ├── Constant.java │ │ ├── PaginationEnum.java │ │ ├── ParamMappingException.java │ │ ├── ProgressEnum.java │ │ ├── SqlException.java │ │ ├── SqltextReg.java │ │ └── SuccessStatusEnum.java │ │ ├── config │ │ ├── BeanConfig.java │ │ └── MyFreemarkerConfig.java │ │ ├── mapper │ │ ├── IAlarmConfigMapper.java │ │ ├── IAlarmHistoryMapper.java │ │ ├── IApiInvokeRecordMapper.java │ │ ├── IDynamicSqlMapper.java │ │ ├── ISqlTemplateMapper.java │ │ ├── IUserGroupMappingMapper.java │ │ └── IUserInfoMapper.java │ │ └── model │ │ ├── AlarmConfig.java │ │ ├── AlarmHistory.java │ │ ├── ApiInvokeRecord.java │ │ ├── SqlTemplate.java │ │ ├── UserGroupMapping.java │ │ └── UserInfo.java │ └── resources │ ├── META-INFO │ └── spring-devtools.properties │ ├── application-dev.properties │ ├── application-prod.properties │ ├── application-sit.properties │ ├── application.properties │ ├── config │ └── logging-config.xml │ ├── mapper │ ├── alarm-config-sqlmap.xml │ ├── alarm-history-sqlmap.xml │ ├── api-invoke-record-sqlmap.xml │ ├── dynamic-sqlmap.xml │ ├── sqltemplate-sqlmap.xml │ ├── user-group-mapping.xml │ └── user-info-sqlmap.xml │ └── spring-dubbo.xml ├── pom.xml └── script ├── data_center.sql ├── design.jpg ├── index.png ├── login.png └── table.jpg /README.md: -------------------------------------------------------------------------------- 1 | 2 | [English Document](https://github.com/netyjq/data-center/blob/master/README_EN.MD) 3 | 4 | ## 项目简介 5 | 6 | 公司有个数据采集的共享库,对应着一个数据中心的项目,每次业务方有数据查询的需求,都需要投入开发同学做SQL查询,提供接口和数据,调试和发布项目,一顿操作下来,耗时费力,伸缩性极差。 7 | 8 | data-center是一个能实现任意sql(动态/静态)执行、统一管理、异常监控的数据查询中台项目。 9 | 它真正做到了无需数据中心项目投入人力参与到业务方需求,业务方同学只需在后台录入SQL拿到sqlId,就可以使用dubbo进行调用。 10 | 11 | 项目核心功能: 12 | 13 | 1. SQL管理 14 | 2. 统一RPC接口 15 | 3. 监控告警 16 | 4. 权限管理 17 | 5. 报表统计 18 | 19 | 20 | ## 方案 21 | 22 | ### 设计图 23 | 24 | ![](script/design.jpg) 25 | 26 | ### 技术方案 27 | 28 | #### Dubbo(RPC) + Freemarker(解析SQL) + Mybatis(执行SQL) 29 | 30 | 假设下面的sql需要根据parentId和name动态查询,其中parent_id和name有值传递过来就参与查询,否则不查询 31 | ```sql 32 | SELECT * from unit_info where and parent_id = #{parentId} and name = #{name}; 33 | ``` 34 | 那么需要在数据中心配置下面的sql模板: 35 | ```sql 36 | SELECT * from unit_info where 1=1 <#if parentId??>and parent_id = #{parentId} <#if name?? && name != ''>and name = #{name} 37 | ``` 38 | 39 | 接下来业务方通过Dubbo调用了数据中心的RPC接口,并传递了参数parentId=1,最终sql被解析并被mybatis执行。 40 | 41 | ```sql 42 | SELECT * from unit_info where 1=1 and parent_id = 1 43 | ``` 44 | 45 | #### 项目模块 46 | 47 | 1. data-center-admin 管理员后台 部署形式:war 48 | 2. data-center-service 提供业务接口 部署形式war 49 | 3. data-center-client 封装接口给业务方 部署形式jar 50 | 4. script sql脚本 51 | 52 | 53 | 54 | ### 业务流程 55 | 56 | 1. 业务方申请应用,得到appId 57 | 2. 配置sql,包含**sqltext**、**是否分页**、**表字段映射**,系统自带校验和测试功能。 58 | 3. 业务方集成数据中心client jar,配置duboo接口,调用api并传递对应参数 59 | 4. 数据中心响应请求,异步记录此次调用信息。 60 | 61 | 62 | ### SQL管理 63 | 64 | 供业务方进行sql模板的配置(如果动态条件则需要使用freemarker编写sql模板) 、sql的模拟测试、上下架管理等功能。 65 | 66 | ### 监控告警 67 | 68 | 支持2种形式的告警:**ERROR_COUNT**以及**SLOW_COUNT**。系统通过定时扫描,对符合条件的查询以邮件的形式发送到用户或组。 69 | 70 | ### 报表统计 71 | 72 | 数据中心会记录每次的调用请求,为日后报表统计类业务做铺垫。同时Admin后台也将以图形的方式展现部分维度下的Top调用量情况。 73 | 74 | ### 权限管理 75 | 76 | 1. 用户组与用户间的关系 —— 用于告警发送邮件以及SQL管理权限的判定 77 | 2. 用户组与应用的关系 —— 用于告警发送邮件 78 | 2. 应用与sql间的关系 —— 用于应用方调用权限的判定 79 | 80 | ## 预览 81 | 82 | ![登录页](script/login.png) 83 | 84 | ![首页](script/index.png) 85 | 86 | 87 | ## 风险点 88 | 89 | 1. 负载风险:宕机引发整体服务不可用 90 | 2. 流控风险:某个业务查询时间过长过高影响其它业务正常运行 91 | 3. 安全风险:大表查询未limit、未走索引、全表扫描;未按需查询、大字段未过滤;锁表;SQL注入:Update、Delete、Truncate等 92 | 4. 其它待补充 93 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/AdminBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.web.support.SpringBootServletInitializer; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 10 | import org.springframework.context.annotation.ImportResource; 11 | import org.springframework.scheduling.annotation.EnableScheduling; 12 | 13 | /** 14 | * SpringBoot 启动类 15 | * @date 2017/6/7 16 | * @author netyjq@gmail.com 17 | */ 18 | @SpringBootApplication 19 | @MapperScan("com.yjq.data.admin.mapper") 20 | @ComponentScan("com.yjq") 21 | @ImportResource("classpath:spring-dubbo.xml") 22 | @EnableScheduling 23 | @EnableAspectJAutoProxy 24 | public class AdminBootstrap extends SpringBootServletInitializer { 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(AdminBootstrap.class, args); 28 | } 29 | 30 | @Override 31 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 32 | return application.sources(AdminBootstrap.class); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/AlarmRuleEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * 告警规则 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-05 7 | */ 8 | public enum AlarmRuleEnum { 9 | 10 | /** 11 | * 慢查询数量 12 | */ 13 | SLOW_COUNT(1), 14 | 15 | /** 16 | * 错误数量 17 | */ 18 | ERROR_COUNT(2); 19 | 20 | public static AlarmRuleEnum getByRuleCode(int code) { 21 | for (AlarmRuleEnum alarmRuleEnum : AlarmRuleEnum.values()) { 22 | if (alarmRuleEnum.getRuleCode() == code) { 23 | return alarmRuleEnum; 24 | } 25 | } 26 | return null; 27 | } 28 | 29 | private int ruleCode; 30 | 31 | AlarmRuleEnum(int ruleCode) { 32 | this.ruleCode = ruleCode; 33 | } 34 | 35 | public int getRuleCode() { 36 | return ruleCode; 37 | } 38 | 39 | public void setRuleCode(int ruleCode) { 40 | this.ruleCode = ruleCode; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * 静态常量 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-05 7 | */ 8 | public class Constant { 9 | 10 | /** 11 | * 分表分隔符 12 | */ 13 | public static final String TABLE_SPLITTER = "_"; 14 | 15 | /** 16 | * 告警历史表 分表数量 17 | */ 18 | public static final int ALARM_HISTORY_TABLE_SPLIT_SIZE = 5; 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/CookiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | import javax.servlet.http.Cookie; 4 | import javax.servlet.http.HttpServletRequest; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by xiezg@317hu.com on 2017/1/4 0004. 10 | */ 11 | public class CookiesUtil { 12 | 13 | /** 14 | * 从cookie中获取值 15 | * @param request 16 | * @param name 17 | * @return 18 | */ 19 | public static String getCookieValue(HttpServletRequest request, String name) { 20 | Map cookieMap = ReadCookieMap(request); 21 | if (cookieMap.containsKey(name)) { 22 | Cookie cookie = (Cookie) cookieMap.get(name); 23 | return cookie.getValue(); 24 | } 25 | return null; 26 | } 27 | 28 | 29 | /** 30 | * 将cookie封装到Map里面 31 | * 32 | * @param request 33 | * @return 34 | */ 35 | public static Map ReadCookieMap(HttpServletRequest request) { 36 | Map cookieMap = new HashMap(); 37 | Cookie[] cookies = request.getCookies(); 38 | if (null != cookies) { 39 | for (Cookie cookie : cookies) { 40 | cookieMap.put(cookie.getName(), cookie); 41 | } 42 | } 43 | return cookieMap; 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/ErrorEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * 前后交互状态码 5 | * @date 2016/12/8. 6 | * @author netyjq@gmail.com 7 | */ 8 | public enum ErrorEnum { 9 | 10 | /** 11 | * 请求成功 12 | * 200 成功/正常 13 | */ 14 | SUCCESS(200, "请求成功"), 15 | 16 | /** 17 | * 业务异常 18 | */ 19 | BIZ_ERROR(1000, "业务异常"), 20 | 21 | /** 22 | * 用户会话异常 23 | */ 24 | SESSION_LOST_ERROR(1001, "用户会话异常"), 25 | 26 | /** 27 | * 系统运行期异常 28 | */ 29 | RUNTIME_ERROR(3000, "系统运行期异常"), 30 | 31 | /** 32 | * 前端传入参数错误,一般表现为:参数漏传,类型传错 33 | */ 34 | WEB_PARAM_ERROR(3001, "入参错误"), 35 | 36 | /** 37 | * 数据库执行异常 38 | */ 39 | DB_EXECUTE_ERROR(3002, "数据库执行异常"), 40 | 41 | /** 42 | * 唯一索引 43 | */ 44 | DB_UNIQUE_ERROR(3003, "无法操作成功,破坏了数据库唯一索引"), 45 | 46 | /** 47 | * RPC服务调用异常 48 | */ 49 | RPC_ERROR(4000, "远程服务异常"), 50 | 51 | /** 52 | * 系统未知系统 53 | */ 54 | UNKNOWN_ERROR(6000, "系统未知异常"); 55 | 56 | 57 | private int code; 58 | 59 | private String msg; 60 | 61 | ErrorEnum(int code, String msg) { 62 | this.code = code; 63 | this.msg = msg; 64 | } 65 | 66 | public ErrorEnum buildMessage(String msg) { 67 | this.setMsg(msg); 68 | return this; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return msg + "." + this.name() + ", code:" + code; 74 | } 75 | 76 | public int getCode() { 77 | return code; 78 | } 79 | 80 | public void setCode(int code) { 81 | this.code = code; 82 | } 83 | 84 | public String getMsg() { 85 | return msg; 86 | } 87 | 88 | public void setMsg(String msg) { 89 | this.msg = msg; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/FreemarkerConstant.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | import com.yjq.data.admin.config.MyFreemarkerConfig; 4 | 5 | /** 6 | * 模板引擎常量 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-29 9 | */ 10 | public class FreemarkerConstant { 11 | 12 | public static MyFreemarkerConfig myFreemarkerConfig; 13 | } 14 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/GlobalStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * 全局状态 5 | * @author netyjq@gmail.com 6 | * @date 2019-04-29 7 | */ 8 | public enum GlobalStatusEnum { 9 | 10 | /** 11 | * 可用正常状态 12 | */ 13 | AVAILABLE(0), 14 | 15 | /** 16 | * 不可用状态 17 | */ 18 | DISABLED(-1); 19 | 20 | private int status; 21 | 22 | GlobalStatusEnum(int status) { 23 | this.status = status; 24 | } 25 | 26 | public static GlobalStatusEnum getByStatusCode(int status) { 27 | for (GlobalStatusEnum globalStatusEnum : GlobalStatusEnum.values()) { 28 | if (globalStatusEnum.status == status) { 29 | return globalStatusEnum; 30 | } 31 | } 32 | return null; 33 | } 34 | 35 | public int getStatus() { 36 | return status; 37 | } 38 | 39 | public void setStatus(int status) { 40 | this.status = status; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/MD5.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | import org.apache.commons.codec.digest.DigestUtils; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | 7 | /** 8 | * @author netyjq@gmail.com 9 | * @date 2019-05-05 10 | */ 11 | public class MD5 { 12 | 13 | public MD5() { 14 | } 15 | 16 | public static String sign(String text, String key, String input_charset) { 17 | text = text + key; 18 | return DigestUtils.md5Hex(getContentBytes(text, input_charset)); 19 | } 20 | 21 | public static String sign(String text) { 22 | return DigestUtils.md5Hex(getContentBytes(text, "utf-8")); 23 | } 24 | 25 | public static boolean verify(String text, String sign, String key, String input_charset) { 26 | text = text + key; 27 | String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); 28 | return mysign.equals(sign); 29 | } 30 | 31 | private static byte[] getContentBytes(String content, String charset) { 32 | if (charset != null && !"".equals(charset)) { 33 | try { 34 | return content.getBytes(charset); 35 | } catch (UnsupportedEncodingException var3) { 36 | throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); 37 | } 38 | } else { 39 | return content.getBytes(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/PaginationEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * 分页 5 | * @author netyjq@gmail.com 6 | * @date 2019-04-29 7 | */ 8 | public enum PaginationEnum { 9 | 10 | /** 11 | * 分页 12 | */ 13 | YES(0), 14 | 15 | /** 16 | * 不分页 17 | */ 18 | NO(-1); 19 | 20 | public int code; 21 | 22 | PaginationEnum(int code) { 23 | this.code = code; 24 | } 25 | 26 | public static PaginationEnum getByCode(int code) { 27 | for (PaginationEnum paginationEnum : PaginationEnum.values()) { 28 | if (paginationEnum.code == code) { 29 | return paginationEnum; 30 | } 31 | } 32 | return null; 33 | } 34 | 35 | public int getCode() { 36 | return code; 37 | } 38 | 39 | public void setCode(int code) { 40 | this.code = code; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/ProgressEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-07 6 | */ 7 | public enum ProgressEnum { 8 | 9 | /** 10 | * 已处理 11 | */ 12 | PROCESSED(1), 13 | 14 | /** 15 | * 未处理 16 | */ 17 | UN_PROCESSED(-1); 18 | 19 | private int code; 20 | 21 | ProgressEnum(int code) { 22 | this.code = code; 23 | } 24 | 25 | public int getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(int code) { 30 | this.code = code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/RoleTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-05 6 | */ 7 | public enum RoleTypeEnum { 8 | 9 | /** 10 | * 普通用户 11 | */ 12 | COMMON_USER(0), 13 | 14 | /** 15 | * 管理员 16 | */ 17 | ADMIN(1); 18 | 19 | private int roleType; 20 | 21 | RoleTypeEnum(int roleType) { 22 | this.roleType = roleType; 23 | } 24 | 25 | public int getRoleType() { 26 | return roleType; 27 | } 28 | 29 | public void setRoleType(int roleType) { 30 | this.roleType = roleType; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/SqlOperationTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common; 2 | 3 | /** 4 | * sql操作类型 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-06 7 | */ 8 | public enum SqlOperationTypeEnum { 9 | 10 | /** 11 | * 新增 12 | */ 13 | INSERT(1), 14 | 15 | /** 16 | * 更新 17 | */ 18 | UPDATE(2), 19 | 20 | /** 21 | * 删除 22 | */ 23 | DELETE(3); 24 | 25 | private int type; 26 | 27 | SqlOperationTypeEnum(int type) { 28 | this.type = type; 29 | } 30 | 31 | public int getType() { 32 | return type; 33 | } 34 | 35 | public void setType(int type) { 36 | this.type = type; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/exception/AbstractException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.exception; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-04-28 6 | */ 7 | public abstract class AbstractException extends RuntimeException { 8 | 9 | private String message; 10 | 11 | /** 12 | * 构建异常信息 13 | * @return String 14 | */ 15 | abstract String buildErrorMessage(); 16 | 17 | public AbstractException(String message) { 18 | this.message = message; 19 | } 20 | 21 | @Override 22 | public String getMessage() { 23 | return message; 24 | } 25 | 26 | public void setMessage(String message) { 27 | this.message = message; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/exception/ParamInvalidException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.exception; 2 | 3 | import com.yjq.data.admin.common.ErrorEnum; 4 | 5 | /** 6 | * 参数异常 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | public class ParamInvalidException extends AbstractException { 11 | 12 | private String field; 13 | 14 | @Override 15 | String buildErrorMessage() { 16 | return ErrorEnum.WEB_PARAM_ERROR.buildMessage(this.getMessage()).toString(); 17 | } 18 | 19 | public ParamInvalidException(String field, String message) { 20 | super("参数" + field + message); 21 | this.field = field; 22 | } 23 | 24 | public String getField() { 25 | return field; 26 | } 27 | 28 | public void setField(String field) { 29 | this.field = field; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/exception/ServiceException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.exception; 2 | 3 | import com.yjq.data.admin.common.ErrorEnum; 4 | 5 | /** 6 | * @author netyjq@gmail.com 7 | * @date 2019-04-28 8 | */ 9 | public class ServiceException extends AbstractException { 10 | 11 | @Override 12 | String buildErrorMessage() { 13 | return ErrorEnum.BIZ_ERROR.buildMessage(this.getMessage()).toString(); 14 | } 15 | 16 | public ServiceException(String message) { 17 | super(message); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/exception/SessionInvalidException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.exception; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-05 6 | */ 7 | public class SessionInvalidException extends AbstractException { 8 | 9 | public SessionInvalidException(String message) { 10 | super(message); 11 | } 12 | 13 | @Override 14 | String buildErrorMessage() { 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/validation/MyValidator.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.validation; 2 | 3 | import com.yjq.data.admin.common.exception.ParamInvalidException; 4 | import org.springframework.validation.BindingResult; 5 | import org.springframework.validation.FieldError; 6 | 7 | import javax.validation.ConstraintViolation; 8 | import javax.validation.Validation; 9 | import javax.validation.ValidatorFactory; 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | /** 14 | * Hibernate参数验证器 15 | * @date 2017/6/5 16 | * @author netyjq@gmail.com 17 | */ 18 | public class MyValidator { 19 | 20 | /** 21 | * 验证前端参数,有错误直接抛出异常 22 | * @param result BindResult 23 | * @throws ParamInvalidException 参数异常 24 | * @return 25 | */ 26 | public static void validateBindResult(BindingResult result) throws ParamInvalidException { 27 | if (result !=null && result.hasErrors()) { 28 | List errors = result.getFieldErrors(); 29 | for (FieldError error : errors) { 30 | throw new ParamInvalidException(error.getField(), error.getDefaultMessage()); 31 | } 32 | } 33 | } 34 | 35 | /** 36 | * Hibernate MyValidator 验证器 37 | * @param object 需要校验的对象 38 | * @throws ParamInvalidException 参数异常 39 | */ 40 | public static void validate(Object object) throws ParamInvalidException { 41 | ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); 42 | javax.validation.Validator validator = factory.getValidator(); 43 | Set> constraintViolations = validator.validate(object); 44 | for (ConstraintViolation constraintViolation : constraintViolations) { 45 | throw new ParamInvalidException(constraintViolation.getPropertyPath().toString(), constraintViolation.getMessage()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/common/validation/ValidationMarker.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.common.validation; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-04-28 6 | */ 7 | public class ValidationMarker { 8 | 9 | public interface InsertGroup{} 10 | 11 | public interface UpdateGroup{} 12 | 13 | public interface SelectGroup{} 14 | 15 | public interface DeleteGroup{} 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/config/FastJsonConverter.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.config; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 5 | import com.google.common.collect.Lists; 6 | import org.springframework.http.MediaType; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * FastJsonHttpMessageConverter 配置 12 | * @date 2017/6/19 13 | * @author netyjq@163.com 14 | */ 15 | public class FastJsonConverter extends FastJsonHttpMessageConverter { 16 | 17 | public FastJsonConverter() { 18 | com.alibaba.fastjson.support.config.FastJsonConfig fastJsonConfig = new com.alibaba.fastjson.support.config.FastJsonConfig(); 19 | fastJsonConfig.setSerializerFeatures( 20 | SerializerFeature.PrettyFormat 21 | ); 22 | 23 | // 解决乱码 24 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 25 | List supportedMediaTypes = Lists.newArrayList(); 26 | supportedMediaTypes.add(MediaType.parseMediaType("text/html;charset=UTF-8")); 27 | supportedMediaTypes.add(MediaType.parseMediaType("application/json")); 28 | fastConverter.setSupportedMediaTypes(supportedMediaTypes); 29 | 30 | // 定义时间和null输出处理 31 | fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); 32 | fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue); 33 | this.setFastJsonConfig(fastJsonConfig); 34 | } 35 | 36 | @Override 37 | protected boolean supports(Class clazz) { 38 | return super.supports(clazz); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/config/MyFreemarkerConfig.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.config; 2 | 3 | import freemarker.cache.StringTemplateLoader; 4 | import freemarker.template.Configuration; 5 | import freemarker.template.Template; 6 | import freemarker.template.TemplateException; 7 | import freemarker.template.Version; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import java.io.IOException; 11 | import java.io.StringWriter; 12 | import java.io.Writer; 13 | import java.util.Map; 14 | /** 15 | * @author netyjq@gmail.com 16 | * @date 2019/4/24 17 | */ 18 | public class MyFreemarkerConfig extends Configuration { 19 | 20 | private StringTemplateLoader stringTemplateLoader; 21 | 22 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 23 | 24 | public MyFreemarkerConfig(Version incompatibleImprovements) { 25 | super(incompatibleImprovements); 26 | } 27 | /** 28 | * 渲染解析sql 29 | * @param templateId 模板id --> sqlId 30 | * @param templateText 模板内容 --> sqlText 31 | * @param model 模型 --> param 32 | * @return the sql that can be executed by mybatis 33 | */ 34 | public String render(String templateId, String templateText, Map model) { 35 | Writer out = new StringWriter(); 36 | try { 37 | stringTemplateLoader.putTemplate(templateId, templateText); 38 | this.setTemplateLoader(stringTemplateLoader); 39 | Template template = this.getTemplate(templateId); 40 | logger.info("get template, name: {}, hashcode: {}", templateId, template.hashCode()); 41 | template.process(model, out); 42 | } catch (TemplateException e) { 43 | e.printStackTrace(); 44 | } catch (IOException e) { 45 | e.printStackTrace(); 46 | } 47 | String sql = out.toString(); 48 | return sql; 49 | } 50 | public StringTemplateLoader getStringTemplateLoader() { 51 | return stringTemplateLoader; 52 | } 53 | public void setStringTemplateLoader(StringTemplateLoader stringTemplateLoader) { 54 | this.stringTemplateLoader = stringTemplateLoader; 55 | this.setTemplateLoader(stringTemplateLoader); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IAlarmConfigMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.AlarmConfig; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface IAlarmConfigMapper extends IBaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IAlarmHistoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.AlarmHistory; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface IAlarmHistoryMapper extends IBaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IApiInvokeRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.ApiInvokeRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-05-06 9 | */ 10 | @Mapper 11 | public interface IApiInvokeRecordMapper extends IBaseMapper { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IAppInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.AppInfo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface IAppInfoMapper extends IBaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IAppUserGroupMappingMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.AppUserGroupMapping; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-28 12 | */ 13 | @Mapper 14 | public interface IAppUserGroupMappingMapper extends IBaseMapper { 15 | 16 | /** 17 | * 根据appId和userGroupId查询单个 18 | * @param appId 应用id 19 | * @param userGroupId groupId 20 | * @return AppUserGroupMapping 21 | */ 22 | AppUserGroupMapping selectByAppIdAndGroupId(@Param("appId") Integer appId, @Param("userGroupId") Integer userGroupId); 23 | 24 | 25 | /** 26 | * 根据用户组id查询 27 | * @param groupIds "1,2,3" 28 | * @return List 29 | */ 30 | List selectByGroupIds(@Param("groupIds") String groupIds); 31 | 32 | /** 33 | * 根据应用id查询 34 | * @param appIds "1,2,3" 35 | * @return List 36 | */ 37 | List selectByAppIds(@Param("appIds") String appIds); 38 | 39 | /** 40 | * 删除关联 41 | * @param appId 42 | * @param userGroupId 43 | */ 44 | void deleteMapping(@Param("appId") Integer appId, @Param("userGroupId") Integer userGroupId); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IBaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * 泛型BaseMapper 11 | * @date 2017/6/6. 12 | * @author netyjq@gmail.com 13 | */ 14 | public interface IBaseMapper { 15 | 16 | /** 17 | * 新增数据 18 | * @param model model实体 19 | * @return id 数据库自增主键 20 | */ 21 | int insertOne(M model); 22 | 23 | /** 24 | * 删除 25 | * @param id 主键id 26 | * @return rows 27 | */ 28 | int deleteOne(ID id); 29 | 30 | /** 31 | * 更新 32 | * @param model model实体 33 | * @return rows 34 | */ 35 | int updateOne(M model); 36 | 37 | /** 38 | * 根据主键获取实体 39 | * @param id 主键id 40 | * @return model实体 41 | */ 42 | M selectOne(ID id); 43 | 44 | /** 45 | * 根据参统计数量 46 | * @param params 参数 47 | * @return int 48 | */ 49 | int count(Map params); 50 | 51 | /** 52 | * 根据参数或者多个对象 53 | * @param params 参数 54 | * @return List 55 | */ 56 | List selectList(Map params); 57 | 58 | /** 59 | * 无参数获取全表对象 60 | * @return List 61 | */ 62 | List selectAll(); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/ISqlOperationRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.SqlOperationRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface ISqlOperationRecordMapper extends IBaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/ISqlTemplateMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.SqlTemplate; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface ISqlTemplateMapper extends IBaseMapper { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IUserGroupMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.UserGroup; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | * @author netyjq@gmail.com 9 | * @date 2019-04-28 10 | */ 11 | @Mapper 12 | public interface IUserGroupMapper extends IBaseMapper { 13 | 14 | /** 15 | * 根据名称查询 16 | * @param name 用户组名称 17 | * @return UserGroup 18 | */ 19 | UserGroup selectByName(@Param("name") String name); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IUserGroupMappingMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.UserGroupMapping; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-05 12 | */ 13 | @Mapper 14 | public interface IUserGroupMappingMapper extends IBaseMapper { 15 | 16 | /** 17 | * 根据用户id、组id查询 18 | * @param userId 用户id 19 | * @param userGroupId 组id 20 | * @return 21 | */ 22 | UserGroupMapping select(@Param("userId") Integer userId, @Param("userGroupId") Integer userGroupId); 23 | 24 | /** 25 | * 删除关联关系 26 | * @param userId 用户id 27 | * @param userGroupId 组id 28 | */ 29 | void deleteMapping(@Param("userGroupId") Integer userGroupId, @Param("userId") Integer userId); 30 | 31 | /** 32 | * 根据用户id查询 33 | * @param userId 用户id 34 | * @return List 35 | */ 36 | List selectByUserId(Integer userId); 37 | } 38 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/mapper/IUserInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.mapper; 2 | 3 | import com.yjq.data.admin.model.domain.UserInfo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-28 12 | */ 13 | @Mapper 14 | public interface IUserInfoMapper extends IBaseMapper { 15 | 16 | /** 17 | * 根据登录账号名称查询 18 | * @param name 账号名称 19 | * @return UserInfo 20 | */ 21 | UserInfo selectByName(String name); 22 | 23 | 24 | /** 25 | * 根据登录账号名称查询 26 | * @param userGroupId 组id 27 | * @return UserInfo 28 | */ 29 | List selectByGroupId(@Param("userGroupId") Integer userGroupId); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/AbstractModel.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author netyjq@gmail.com 7 | * @date 2019/4/24 8 | */ 9 | public class AbstractModel implements Serializable { 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/AlarmConfig.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 告警配置 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class AlarmConfig extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * 应用id 20 | */ 21 | private Integer appId; 22 | 23 | /** 24 | * 应用名称 25 | */ 26 | private String appName; 27 | 28 | /** 29 | * 创建人id 30 | */ 31 | private Integer createId; 32 | 33 | /** 34 | * 创建人姓名 35 | */ 36 | private String createName; 37 | 38 | /** 39 | * 创建时间 40 | */ 41 | private Date createTime; 42 | 43 | /** 44 | * 更新人id 45 | */ 46 | private Integer updateId; 47 | 48 | /** 49 | * 更新人姓名 50 | */ 51 | private String updateName; 52 | 53 | /** 54 | * 更新时间 55 | */ 56 | private Date updateTime; 57 | 58 | /** 59 | * 阈值 60 | */ 61 | private Integer threshold; 62 | 63 | /** 64 | * 告警规则 SLOW_COUNT(1), ERROR_COUNT(2); 65 | */ 66 | private Integer rule; 67 | 68 | /** 69 | * 用户组id 70 | */ 71 | private Integer userGroupId; 72 | 73 | /** 74 | * 用户组名称 75 | */ 76 | private String userGroupName; 77 | 78 | 79 | public AlarmConfig(Integer appId, String appName, Integer createId, String createName, Integer updateId, 80 | String updateName, Integer threshold, Integer rule, Integer userGroupId, String userGroupName) { 81 | this.appId = appId; 82 | this.appName = appName; 83 | this.createId = createId; 84 | this.createName = createName; 85 | this.updateId = updateId; 86 | this.updateName = updateName; 87 | this.threshold = threshold; 88 | this.rule = rule; 89 | this.userGroupId = userGroupId; 90 | this.userGroupName = userGroupName; 91 | } 92 | 93 | public AlarmConfig() { 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/AlarmHistory.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 告警历史 10 | * 生成方式:通过轮询 api_invoke_record表 以及结合 alarm_config表 来生成告警记录添加到 alarm_history表 11 | * 分表规则:根据appId进行取模运算得到操作表 12 | * @author netyjq@gmail.com 13 | * @date 2019-04-26 14 | */ 15 | @Data 16 | public class AlarmHistory extends AbstractModel { 17 | 18 | private Integer id; 19 | 20 | /** 21 | * 应用id 22 | */ 23 | private Integer appId; 24 | 25 | /** 26 | * 应用名称 27 | */ 28 | private String appName; 29 | 30 | /** 31 | * 阈值 32 | */ 33 | private Integer threshold; 34 | 35 | /** 36 | * 告警规则 1.慢查询 2.错误 37 | */ 38 | private Integer alarmRule; 39 | 40 | /** 41 | * 实际数值 42 | */ 43 | private Integer actualNum; 44 | 45 | /** 46 | * 告警内容 47 | */ 48 | private String alarmMessage; 49 | 50 | /** 51 | * 创建时间 52 | */ 53 | private Date createTime; 54 | 55 | /** 56 | * 用户id 57 | */ 58 | private Integer receiverId; 59 | 60 | /** 61 | * 用户名称 62 | */ 63 | private String receiverName; 64 | 65 | 66 | public AlarmHistory(Integer appId, String appName, Integer threshold, Integer alarmRule, Integer actualNum, String alarmMessage) { 67 | this.appId = appId; 68 | this.appName = appName; 69 | this.threshold = threshold; 70 | this.alarmRule = alarmRule; 71 | this.actualNum = actualNum; 72 | this.alarmMessage = alarmMessage; 73 | this.createTime = new Date(); 74 | } 75 | 76 | public AlarmHistory() { 77 | } 78 | 79 | } 80 | 81 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/ApiInvokeRecord.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 接口调用记录 10 | * 告警触发的规则就是定时轮训调用记录,判断是否符合告警的配置 11 | * 轮询完成后会设置标志位字段processed为-1,并记录处理时间 12 | * 13 | * @author netyjq@gmail.com 14 | * @date 2019-05-06 15 | */ 16 | @Data 17 | public class ApiInvokeRecord extends AbstractModel { 18 | 19 | private Integer id; 20 | 21 | /** 22 | * 应用id 23 | */ 24 | private Integer appId; 25 | 26 | /** 27 | * 应用名称 28 | */ 29 | private String appName; 30 | 31 | /** 32 | * sql模板id 33 | */ 34 | private String sqlId; 35 | 36 | /** 37 | * sql模板 38 | */ 39 | private String sqltext; 40 | 41 | /** 42 | * 请求入参 43 | */ 44 | private String requestParam; 45 | 46 | /** 47 | * 接收到请求的时的系统时间 48 | */ 49 | private Date requestTime; 50 | 51 | /** 52 | * 请求响应时系统时间 53 | */ 54 | private Date responseTime; 55 | 56 | /** 57 | * 消耗的时间 毫秒 58 | */ 59 | private Integer cost; 60 | 61 | /** 62 | * 是否调用成功 0 成功 -1 失败 63 | */ 64 | private Integer success; 65 | 66 | /** 67 | * 是否已经轮询处理过了 0未处理 -1已经处理 68 | */ 69 | private Integer processed; 70 | 71 | /** 72 | * 轮询标记的时间 73 | */ 74 | private Date processedTime; 75 | 76 | /** 77 | * 错误详情 执行出错时记录 78 | */ 79 | private String errorDetail; 80 | 81 | } 82 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/AppInfo.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 应用 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class AppInfo extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * 应用名称 20 | */ 21 | private String name; 22 | 23 | /** 24 | * 创建时间 25 | */ 26 | private Date createTime; 27 | 28 | public AppInfo(String name) { 29 | this.name = name; 30 | this.createTime = new Date(); 31 | } 32 | 33 | public AppInfo() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/AppUserGroupMapping.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 用户与应用映射 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class AppUserGroupMapping extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * 应用ID 20 | */ 21 | private Integer appId; 22 | 23 | /** 24 | * 应用名称 25 | */ 26 | private String appName; 27 | 28 | /** 29 | * 用户id 30 | */ 31 | private Integer userGroupId; 32 | 33 | /** 34 | * 用户名称 35 | */ 36 | private String userGroupName; 37 | 38 | /** 39 | * 创建时间 40 | */ 41 | private Date createTime; 42 | 43 | public AppUserGroupMapping(Integer appId, String appName, Integer userGroupId, String userGroupName) { 44 | this.appId = appId; 45 | this.appName = appName; 46 | this.userGroupId = userGroupId; 47 | this.userGroupName = userGroupName; 48 | this.createTime = new Date(); 49 | } 50 | 51 | public AppUserGroupMapping() { 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/SqlOperationRecord.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * sql模板操作记录 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class SqlOperationRecord extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * sql id 20 | */ 21 | private String sqlId; 22 | 23 | /** 24 | * 操作人id 25 | */ 26 | private Integer operatorId; 27 | 28 | /** 29 | * 操作人姓名 30 | */ 31 | private String operatorName; 32 | 33 | /** 34 | * 操作类型 35 | */ 36 | private Integer type; 37 | 38 | /** 39 | * 创建时间 40 | */ 41 | private Date createTime; 42 | 43 | /** 44 | * 修改前sql 45 | */ 46 | private String sqltextBefore; 47 | 48 | /** 49 | * 修改后sql 50 | */ 51 | private String sqltextAfter; 52 | 53 | /** 54 | * 修改前分页情况 55 | */ 56 | private Integer pageBefore; 57 | 58 | /** 59 | * 修改后分页情况 60 | */ 61 | private Integer pageAfter; 62 | 63 | /** 64 | * 修改前表字段映射情况 65 | */ 66 | private String parameterMappingBefore; 67 | 68 | /** 69 | * 修改后表字段映射情况 70 | */ 71 | private String parameterMappingAfter; 72 | 73 | } 74 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/SqlTemplate.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | import java.util.UUID; 8 | 9 | /** 10 | * sql模板 11 | * @author netyjq@gmail.com 12 | * @date 2019/4/24 13 | */ 14 | @Data 15 | public class SqlTemplate extends AbstractModel { 16 | 17 | private String id; 18 | 19 | /** 20 | * sql模板 21 | */ 22 | private String sqltext; 23 | 24 | /** 25 | * 描述 26 | */ 27 | private String description; 28 | 29 | /** 30 | * 应用id 31 | */ 32 | private Integer appId; 33 | 34 | /** 35 | * 应用名称 36 | */ 37 | private String appName; 38 | 39 | /** 40 | * 状态0 正常 -1 禁用 41 | */ 42 | private Integer enableStatus; 43 | 44 | /** 45 | * 是否分页 0分页 -1不分页 46 | */ 47 | private Integer paging; 48 | 49 | /** 50 | * 出参映射 like: {"app_id":"appId","enable_status":enableStatus} 51 | */ 52 | private String parameterMapping; 53 | 54 | /** 55 | * 创建时间 56 | */ 57 | private Date createTime; 58 | 59 | /** 60 | * 创建人 equals User#getName 61 | */ 62 | private String createName; 63 | 64 | /** 65 | * 创建人id 66 | */ 67 | private Integer createId; 68 | 69 | /** 70 | * 更新时间 71 | */ 72 | private Date updateTime; 73 | 74 | /** 75 | * 更新人 76 | */ 77 | private String updateName; 78 | 79 | /** 80 | * 更新人id 81 | */ 82 | private Integer updateId; 83 | 84 | public SqlTemplate(String sqltext, String description, Integer appId, String appName, Integer enableStatus, 85 | Integer paging, String parameterMapping, String createName, Integer createId) { 86 | this.sqltext = sqltext; 87 | this.description = description; 88 | this.appId = appId; 89 | this.appName = appName; 90 | this.enableStatus = enableStatus; 91 | this.paging = paging; 92 | this.parameterMapping = parameterMapping; 93 | this.createTime = new Date(); 94 | this.createName = createName; 95 | this.id = UUID.randomUUID().toString(); 96 | this.createId = createId; 97 | } 98 | 99 | public SqlTemplate() { 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/UserGroup.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 用户组 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class UserGroup extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * 用户组名称 20 | */ 21 | private String name; 22 | 23 | /** 24 | * 描述 25 | */ 26 | private String description; 27 | 28 | /** 29 | * 创建时间 30 | */ 31 | private Date createTime; 32 | 33 | public UserGroup() { 34 | } 35 | 36 | public UserGroup(String name, String description) { 37 | this.name = name; 38 | this.description = description; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/UserGroupMapping.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | /** 7 | * 用户、组之间的映射关系 8 | * @author netyjq@gmail.com 9 | * @date 2019-05-05 10 | */ 11 | @Data 12 | public class UserGroupMapping extends AbstractModel { 13 | 14 | private Integer id; 15 | 16 | /** 17 | * 用户id 18 | */ 19 | private Integer userId; 20 | 21 | /** 22 | * 用户组id 23 | */ 24 | private Integer userGroupId; 25 | 26 | public UserGroupMapping(Integer userId, Integer userGroupId) { 27 | this.userId = userId; 28 | this.userGroupId = userGroupId; 29 | } 30 | 31 | public UserGroupMapping() { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/domain/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.domain; 2 | 3 | import com.yjq.data.admin.model.AbstractModel; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 用户信息 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-26 12 | */ 13 | @Data 14 | public class UserInfo extends AbstractModel { 15 | 16 | private Integer id; 17 | 18 | /** 19 | * 姓名 邮箱前缀 like yejq 20 | */ 21 | private String name; 22 | 23 | /** 24 | * 邮箱地址 25 | */ 26 | private String email; 27 | 28 | /** 29 | * 最后一次登录时间 30 | */ 31 | private Date lastLogin; 32 | 33 | /** 34 | * 用户组id 35 | */ 36 | private Integer userGroupId; 37 | 38 | /** 39 | * 角色权限 0 普通用户 1 管理员用户 40 | */ 41 | private Integer roleType; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/AbstractDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-04-29 6 | */ 7 | public abstract class AbstractDTO { 8 | 9 | /** 10 | * 参数验证 11 | * @return boolean 12 | */ 13 | public abstract boolean validate(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/AlarmConfigRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.AlarmRuleEnum; 4 | import com.yjq.data.admin.common.validation.ValidationMarker; 5 | import lombok.Data; 6 | import org.hibernate.validator.constraints.Range; 7 | 8 | import javax.validation.constraints.NotNull; 9 | 10 | /** 11 | * @author netyjq@gmail.com 12 | * @date 2019-05-05 13 | */ 14 | @Data 15 | public class AlarmConfigRequestDTO extends PageRequestDTO { 16 | 17 | 18 | /** 19 | * id 20 | */ 21 | @NotNull(groups = {ValidationMarker.UpdateGroup.class, ValidationMarker.DeleteGroup.class}) 22 | private Integer id; 23 | 24 | /** 25 | * 应用id 26 | */ 27 | @NotNull(groups = {ValidationMarker.InsertGroup.class, ValidationMarker.UpdateGroup.class}) 28 | private Integer appId; 29 | 30 | /** 31 | * 阈值 32 | */ 33 | @NotNull(groups = {ValidationMarker.InsertGroup.class, ValidationMarker.UpdateGroup.class}) 34 | @Range(min = 1, max = 100, groups = {ValidationMarker.InsertGroup.class, ValidationMarker.UpdateGroup.class}) 35 | private Integer threshold; 36 | 37 | /** 38 | * 告警类型 39 | */ 40 | @NotNull(groups = {ValidationMarker.InsertGroup.class, ValidationMarker.UpdateGroup.class}) 41 | private Integer rule; 42 | 43 | /** 44 | * 用户组id 45 | */ 46 | @NotNull(groups = {ValidationMarker.InsertGroup.class, ValidationMarker.UpdateGroup.class}) 47 | private Integer userGroupId; 48 | 49 | @Override 50 | public boolean validate() { 51 | AlarmRuleEnum alarmRuleEnum = AlarmRuleEnum.getByRuleCode(rule); 52 | if (alarmRuleEnum == null) { 53 | return false; 54 | } 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/AlarmHistoryRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.Constant; 4 | import lombok.Data; 5 | import org.hibernate.validator.constraints.Range; 6 | 7 | import javax.validation.constraints.NotNull; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-06 12 | */ 13 | public class AlarmHistoryRequestDTO extends PageRequestDTO { 14 | 15 | /** 16 | * 数据库下标 17 | */ 18 | private Integer tableSuffix; 19 | 20 | /** 21 | * 应用id 22 | */ 23 | @NotNull 24 | private Integer appId; 25 | 26 | /** 27 | * 告警规则 1.慢查询 2.错误 28 | */ 29 | private Integer alarmRule; 30 | 31 | @NotNull 32 | @Range(min = 1) 33 | private Integer page; 34 | 35 | @NotNull 36 | @Range(min = 1) 37 | private Integer limit; 38 | 39 | public Integer getAppId() { 40 | return appId; 41 | } 42 | 43 | public void setAppId(Integer appId) { 44 | this.appId = appId; 45 | this.tableSuffix = appId % Constant.ALARM_HISTORY_TABLE_SPLIT_SIZE; 46 | } 47 | 48 | public Integer getAlarmRule() { 49 | return alarmRule; 50 | } 51 | 52 | public void setAlarmRule(Integer alarmRule) { 53 | this.alarmRule = alarmRule; 54 | } 55 | 56 | public Integer getTableSuffix() { 57 | return tableSuffix; 58 | } 59 | 60 | public void setTableSuffix(Integer tableSuffix) { 61 | this.tableSuffix = tableSuffix; 62 | } 63 | 64 | public Integer getPage() { 65 | return page; 66 | } 67 | 68 | public void setPage(Integer page) { 69 | this.setPageNum(page); 70 | this.page = page; 71 | } 72 | 73 | public Integer getLimit() { 74 | return limit; 75 | } 76 | 77 | public void setLimit(Integer limit) { 78 | this.setPageSize(limit); 79 | this.limit = limit; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/ApiInvokeRecordPageRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.Constant; 4 | import org.hibernate.validator.constraints.Range; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * @author netyjq@gmail.com 10 | * @date 2019-05-13 11 | */ 12 | public class ApiInvokeRecordPageRequestDTO extends PageRequestDTO { 13 | 14 | /** 15 | * sql id 16 | */ 17 | @NotNull 18 | private Integer appId; 19 | 20 | @NotNull 21 | @Range(min = 1) 22 | private Integer page; 23 | 24 | @NotNull 25 | @Range(min = 1) 26 | private Integer limit; 27 | 28 | /** 29 | * 数据库表号 30 | */ 31 | private Integer tableSuffix; 32 | 33 | public Integer getAppId() { 34 | return appId; 35 | } 36 | 37 | public void setAppId(Integer appId) { 38 | this.tableSuffix = appId % Constant.ALARM_HISTORY_TABLE_SPLIT_SIZE; 39 | this.appId = appId; 40 | } 41 | 42 | public Integer getPage() { 43 | return page; 44 | } 45 | 46 | public void setPage(Integer page) { 47 | this.setPageNum(page); 48 | this.page = page; 49 | } 50 | 51 | public Integer getLimit() { 52 | return limit; 53 | } 54 | 55 | public void setLimit(Integer limit) { 56 | this.setPageSize(limit); 57 | this.limit = limit; 58 | } 59 | 60 | public Integer getTableSuffix() { 61 | return tableSuffix; 62 | } 63 | 64 | public void setTableSuffix(Integer tableSuffix) { 65 | this.tableSuffix = tableSuffix; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/PageRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.model.dto.AbstractDTO; 4 | import lombok.Data; 5 | import org.hibernate.validator.constraints.Range; 6 | 7 | /** 8 | * 分页请求dto 9 | * @date 2017/2/20 10 | * @author netyjq@gmail.com 11 | */ 12 | @Data 13 | public class PageRequestDTO extends AbstractDTO { 14 | 15 | private Integer pageNum = 1; 16 | 17 | @Range(min = 0, max = 100) 18 | private Integer pageSize = 5; 19 | 20 | public PageRequestDTO() { 21 | } 22 | 23 | public PageRequestDTO setPageSize(Integer pageSize) { 24 | if (pageSize < 1) { 25 | pageSize = 1; 26 | } 27 | this.pageSize = pageSize; 28 | return this; 29 | } 30 | 31 | public PageRequestDTO setPageNum(Integer pageNum) { 32 | if (pageNum < 0) { 33 | pageNum = 1; 34 | } 35 | this.pageNum = pageNum; 36 | return this; 37 | } 38 | 39 | public PageRequestDTO(Integer pageNum, Integer pageSize) { 40 | setPageNum(pageNum); 41 | setPageSize(pageSize); 42 | } 43 | 44 | @Override 45 | public boolean validate() { 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/SqlOperationRecordPageRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.Range; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * @author netyjq@gmail.com 10 | * @date 2019-05-13 11 | */ 12 | @Data 13 | public class SqlOperationRecordPageRequestDTO extends PageRequestDTO { 14 | 15 | /** 16 | * sql id 17 | */ 18 | @NotNull 19 | private String sqlId; 20 | 21 | @NotNull 22 | @Range(min = 1) 23 | private Integer page; 24 | 25 | @NotNull 26 | @Range(min = 1) 27 | private Integer limit; 28 | 29 | public void setPage(Integer page) { 30 | this.setPageNum(page); 31 | this.page = page; 32 | } 33 | 34 | public void setLimit(Integer limit) { 35 | this.setPageSize(limit); 36 | this.limit = limit; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/SqlTemplateInsertRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yjq.data.admin.common.FreemarkerConstant; 5 | import com.yjq.data.admin.common.exception.ServiceException; 6 | import com.yjq.data.admin.model.dto.AbstractDTO; 7 | import com.google.common.base.Strings; 8 | import freemarker.template.Template; 9 | import lombok.Data; 10 | import org.hibernate.validator.constraints.Length; 11 | import org.hibernate.validator.constraints.NotEmpty; 12 | import org.hibernate.validator.constraints.Range; 13 | 14 | import javax.validation.constraints.NotNull; 15 | import java.io.IOException; 16 | import java.io.StringReader; 17 | import java.util.UUID; 18 | 19 | /** 20 | * @author netyjq@gmail.com 21 | * @date 2019-04-28 22 | */ 23 | @Data 24 | public class SqlTemplateInsertRequestDTO extends AbstractDTO { 25 | 26 | /** 27 | * sql模板 28 | */ 29 | @NotEmpty 30 | private String sqltext; 31 | 32 | /** 33 | * 描述 34 | */ 35 | @NotEmpty 36 | @Length(max = 20) 37 | private String description; 38 | 39 | /** 40 | * 应用id 41 | */ 42 | @NotNull 43 | @Range(min = 1) 44 | private Integer appId; 45 | 46 | /** 47 | * 出参映射 48 | */ 49 | private String parameterMapping; 50 | 51 | /** 52 | * 是否分页 53 | */ 54 | @NotNull 55 | @Range(min = -1, max = 0) 56 | private Integer paging; 57 | 58 | @Override 59 | public boolean validate() { 60 | // 校验sql模板是否正确 61 | if (!(sqltext.contains("select") || sqltext.contains("SELECT"))) { 62 | throw new ServiceException("SQL模板编写错误,非SQL SELECT语句"); 63 | } 64 | if (!(sqltext.contains("from") || sqltext.contains("FROM"))) { 65 | throw new ServiceException("SQL模板编写错误,非SQL SELECT语句"); 66 | } 67 | if (!Strings.isNullOrEmpty(parameterMapping)) { 68 | if (!parameterMapping.contains(":")) { 69 | throw new ServiceException("表字段映射格式输入错误,无法解析"); 70 | } 71 | try { 72 | JSON.parseObject(parameterMapping); 73 | } catch (Exception e) { 74 | throw new ServiceException("表字段映射格式输入错误,无法解析"); 75 | } 76 | } 77 | try { 78 | Template template = new Template(UUID.randomUUID().toString(), new StringReader(sqltext), 79 | FreemarkerConstant.myFreemarkerConfig); 80 | } catch (IOException e) { 81 | throw new ServiceException("SQL模板编写错误,无法解析"); 82 | } 83 | return true; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/SqlTemplateRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.GlobalStatusEnum; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-29 9 | */ 10 | @Data 11 | public class SqlTemplateRequestDTO extends PageRequestDTO { 12 | 13 | private Integer appId; 14 | 15 | private Integer enableStatus; 16 | 17 | private Integer paging; 18 | 19 | @Override 20 | public boolean validate() { 21 | if (paging != null) { 22 | if (paging < 0 || paging > 1) { 23 | return false; 24 | } 25 | } 26 | if (enableStatus != null && GlobalStatusEnum.getByStatusCode(enableStatus) == null) { 27 | return false; 28 | } 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/SqlTemplateUpdateRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yjq.data.admin.common.FreemarkerConstant; 5 | import com.yjq.data.admin.common.exception.ServiceException; 6 | import com.yjq.data.admin.model.dto.AbstractDTO; 7 | import com.google.common.base.Strings; 8 | import freemarker.template.Template; 9 | import lombok.Data; 10 | import org.hibernate.validator.constraints.Length; 11 | import org.hibernate.validator.constraints.NotEmpty; 12 | import org.hibernate.validator.constraints.Range; 13 | 14 | import javax.validation.constraints.NotNull; 15 | import java.io.IOException; 16 | import java.io.StringReader; 17 | import java.util.UUID; 18 | 19 | /** 20 | * @author netyjq@gmail.com 21 | * @date 2019-04-28 22 | */ 23 | @Data 24 | public class SqlTemplateUpdateRequestDTO extends AbstractDTO { 25 | 26 | /** 27 | * sql 模板id 28 | */ 29 | @NotNull 30 | private String id; 31 | 32 | /** 33 | * sql模板 34 | */ 35 | @NotEmpty 36 | private String sqltext; 37 | 38 | /** 39 | * 描述 40 | */ 41 | @NotEmpty 42 | @Length(max = 20) 43 | private String description; 44 | 45 | /** 46 | * 出参映射 47 | */ 48 | private String parameterMapping; 49 | 50 | /** 51 | * 是否分页 52 | */ 53 | @NotNull 54 | @Range(min = -1, max = 0) 55 | private Integer paging; 56 | 57 | @Override 58 | public boolean validate() { 59 | // 校验sql模板是否正确 60 | if (!(sqltext.contains("select") || sqltext.contains("SELECT"))) { 61 | throw new ServiceException("SQL模板编写错误,非SQL SELECT语句"); 62 | } 63 | if (!(sqltext.contains("from") || sqltext.contains("FROM"))) { 64 | throw new ServiceException("SQL模板编写错误,非SQL SELECT语句"); 65 | } 66 | if (!Strings.isNullOrEmpty(parameterMapping)) { 67 | if (!parameterMapping.contains(":")) { 68 | throw new ServiceException("表字段映射格式输入错误,无法解析"); 69 | } 70 | try { 71 | JSON.parseObject(parameterMapping); 72 | } catch (Exception e) { 73 | throw new ServiceException("表字段映射格式输入错误,无法解析"); 74 | } 75 | } 76 | try { 77 | Template template = new Template(UUID.randomUUID().toString(), new StringReader(sqltext), 78 | FreemarkerConstant.myFreemarkerConfig); 79 | } catch (IOException e) { 80 | throw new ServiceException("SQL模板编写错误,无法解析"); 81 | } 82 | return true; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/UserGroupAppDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.validation.ValidationMarker; 4 | import com.yjq.data.admin.model.dto.AbstractDTO; 5 | import lombok.Data; 6 | import org.hibernate.validator.constraints.NotEmpty; 7 | 8 | import javax.validation.constraints.NotNull; 9 | 10 | /** 11 | * @author netyjq@gmail.com 12 | * @date 2019-05-16 13 | */ 14 | @Data 15 | public class UserGroupAppDTO extends AbstractDTO { 16 | 17 | @NotNull(groups = {ValidationMarker.InsertGroup.class, ValidationMarker.DeleteGroup.class}) 18 | private Integer userGroupId; 19 | 20 | @NotEmpty(groups = {ValidationMarker.InsertGroup.class}) 21 | private String appIds; 22 | 23 | @NotNull(groups = {ValidationMarker.DeleteGroup.class}) 24 | private Integer appId; 25 | 26 | @Override 27 | public boolean validate() { 28 | return false; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/request/UserGroupRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.request; 2 | 3 | import com.yjq.data.admin.common.validation.ValidationMarker; 4 | import com.yjq.data.admin.model.dto.AbstractDTO; 5 | import lombok.Data; 6 | import org.hibernate.validator.constraints.Length; 7 | import org.hibernate.validator.constraints.NotEmpty; 8 | 9 | import javax.validation.constraints.NotNull; 10 | 11 | /** 12 | * @author netyjq@gmail.com 13 | * @date 2019-05-05 14 | */ 15 | @Data 16 | public class UserGroupRequestDTO extends AbstractDTO { 17 | 18 | @NotNull(groups = {ValidationMarker.UpdateGroup.class, ValidationMarker.SelectGroup.class, ValidationMarker.DeleteGroup.class}) 19 | private Integer id; 20 | 21 | @NotEmpty(groups = {ValidationMarker.InsertGroup.class}) 22 | @Length(max = 15, groups = {ValidationMarker.InsertGroup.class}) 23 | private String name; 24 | 25 | @NotEmpty(groups = {ValidationMarker.InsertGroup.class}) 26 | @Length(max = 20, groups = {ValidationMarker.InsertGroup.class}) 27 | private String description; 28 | 29 | /** 30 | * 用户id 31 | */ 32 | @NotEmpty(groups = {ValidationMarker.UpdateGroup.class}) 33 | @Length(max = 70, groups = {ValidationMarker.UpdateGroup.class}) 34 | private String userIds; 35 | 36 | @NotNull(groups = {ValidationMarker.DeleteGroup.class}) 37 | private Integer userId; 38 | 39 | @Override 40 | public boolean validate() { 41 | return false; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/response/LayuiResponseDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.response; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author netyjq@gmail.com 9 | * @date 2019-05-08 10 | */ 11 | @Data 12 | public class LayuiResponseDTO { 13 | 14 | private Integer code = 0; 15 | 16 | private String msg; 17 | 18 | private Integer count; 19 | 20 | private List data; 21 | 22 | public LayuiResponseDTO() { 23 | } 24 | 25 | public LayuiResponseDTO(List list) { 26 | this.data = list; 27 | this.count = list.size(); 28 | } 29 | 30 | public LayuiResponseDTO(List list, int count) { 31 | this.data = list; 32 | this.count = count; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/model/dto/response/ResponseDTO.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.model.dto.response; 2 | 3 | 4 | import com.yjq.data.admin.common.ErrorEnum; 5 | import lombok.Data; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * 通用的Response 12 | * @date 2017/2/20. 13 | * @author netyjq@gmail.com 14 | */ 15 | @Data 16 | public class ResponseDTO { 17 | 18 | /** 19 | * 响应code 20 | */ 21 | private Integer result; 22 | 23 | /** 24 | * 错误类型 ref ErrorEnum 25 | */ 26 | private String type; 27 | 28 | /** 29 | * 响应的message 30 | */ 31 | private Object message; 32 | 33 | /** 34 | * 响应的数据 35 | */ 36 | private Object data; 37 | 38 | public ResponseDTO() { 39 | this.result = ErrorEnum.SUCCESS.getCode(); 40 | this.message = ErrorEnum.SUCCESS.getMsg(); 41 | } 42 | 43 | public ResponseDTO(ErrorEnum errorEnum) { 44 | this.result = errorEnum.getCode(); 45 | this.message = errorEnum.getMsg(); 46 | } 47 | 48 | public ResponseDTO(Object object) { 49 | this.data = object; 50 | this.result = ErrorEnum.SUCCESS.getCode(); 51 | this.message = ErrorEnum.SUCCESS.getMsg(); 52 | } 53 | 54 | public ResponseDTO(Object object, String key) { 55 | Map map = new HashMap(); 56 | map.put(key, object); 57 | this.data = map; 58 | this.result = ErrorEnum.SUCCESS.getCode(); 59 | this.message = ErrorEnum.SUCCESS.getMsg(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/AbstractBaseService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.common.BeanUtil; 4 | import com.yjq.data.admin.mapper.IBaseMapper; 5 | import com.yjq.data.admin.model.AbstractModel; 6 | import com.yjq.data.admin.model.dto.request.PageRequestDTO; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | 13 | import java.io.Serializable; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * 泛型 AbstractBaseService 19 | * @date 2017/6/7. 20 | * @author netyjq@gmail.com 21 | */ 22 | public abstract class AbstractBaseService { 23 | 24 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); 25 | 26 | @Autowired 27 | protected IBaseMapper baseMapper; 28 | 29 | /** 30 | * 增 31 | * @param model Model 32 | * @return int 33 | */ 34 | protected int insert(M model) { 35 | return baseMapper.insertOne(model); 36 | } 37 | 38 | /** 39 | * 删 40 | * @param id ID 41 | * @return int 42 | */ 43 | protected int delete(ID id) { 44 | return baseMapper.deleteOne(id); 45 | } 46 | 47 | /** 48 | * 改 49 | * @param model Model 50 | * @return int 51 | */ 52 | protected int update(M model) { 53 | return baseMapper.updateOne(model); 54 | } 55 | 56 | /** 57 | * 主键查询 58 | * @param id ID 59 | * @return Model 60 | */ 61 | protected M get(ID id) { 62 | return (M) baseMapper.selectOne(id); 63 | } 64 | 65 | /** 66 | * 查询所有 67 | * @return List 68 | */ 69 | public List listAll() { 70 | return baseMapper.selectAll(); 71 | } 72 | 73 | /** 74 | * 分页条件查询 75 | * @param requestDTO 分页查询条件 76 | * @return PageInfo 77 | */ 78 | public PageInfo listPage(PageRequestDTO requestDTO) { 79 | Map params = BeanUtil.transBeanToMap(requestDTO); 80 | return PageHelper.startPage(requestDTO.getPageNum(), requestDTO.getPageSize()).doSelectPageInfo(() -> { 81 | baseMapper.selectList(params); 82 | }); 83 | } 84 | 85 | /** 86 | * 条件不分页查询 87 | * @param params Map 88 | * @return List 89 | */ 90 | public List list(Map params) { 91 | return baseMapper.selectList(params); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/AlarmHistoryService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.model.domain.AlarmHistory; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Service 11 | public class AlarmHistoryService extends AbstractBaseService { 12 | } 13 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/ApiInvokeRecordService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.model.domain.ApiInvokeRecord; 4 | import com.yjq.data.admin.model.dto.request.ApiInvokeRecordPageRequestDTO; 5 | import com.github.pagehelper.PageInfo; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author netyjq@gmail.com 10 | * @date 2019-05-13 11 | */ 12 | @Service 13 | public class ApiInvokeRecordService extends AbstractBaseService { 14 | 15 | public PageInfo page(ApiInvokeRecordPageRequestDTO recordPageRequestDTO) { 16 | return this.listPage(recordPageRequestDTO); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/AppInfoService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.common.BeanUtil; 4 | import com.yjq.data.admin.mapper.IUserInfoMapper; 5 | import com.yjq.data.admin.model.domain.AppInfo; 6 | import com.yjq.data.admin.model.domain.AppUserGroupMapping; 7 | import com.yjq.data.admin.model.domain.UserInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.Collections; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.stream.Collectors; 15 | 16 | /** 17 | * @author netyjq@gmail.com 18 | * @date 2019-04-28 19 | */ 20 | @Service 21 | public class AppInfoService extends AbstractBaseService { 22 | 23 | @Autowired 24 | private IUserInfoMapper userInfoMapper; 25 | 26 | @Autowired 27 | private AppUserGroupMappingService appUserGroupMappingService; 28 | 29 | public void insertAppInfo(String name) { 30 | AppInfo appInfo = new AppInfo(name); 31 | super.insert(appInfo); 32 | } 33 | 34 | 35 | public List list(UserInfo userInfo) { 36 | List appUserGroupMappings = appUserGroupMappingService.list(userInfo); 37 | if (appUserGroupMappings == null || appUserGroupMappings.isEmpty()) { 38 | return Collections.emptyList(); 39 | } 40 | Map params = BeanUtil.getPropertyMap("appIdList", appUserGroupMappings 41 | .stream() 42 | .map(AppUserGroupMapping::getAppId) 43 | .collect(Collectors.toList())); 44 | return super.list(params); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/SqlOperationRecordService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.mapper.ISqlOperationRecordMapper; 4 | import com.yjq.data.admin.model.domain.SqlOperationRecord; 5 | import com.yjq.data.admin.model.dto.request.SqlOperationRecordPageRequestDTO; 6 | import com.github.pagehelper.PageInfo; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @author netyjq@gmail.com 12 | * @date 2019-04-28 13 | */ 14 | @Service 15 | public class SqlOperationRecordService extends AbstractBaseService { 16 | 17 | @Autowired 18 | private ISqlOperationRecordMapper sqlOperationRecordMapper; 19 | 20 | /** 21 | * 根据sqlid分页查询 22 | * @param recordPageRequestDTO 分页dto 23 | * @return 24 | */ 25 | public PageInfo page(SqlOperationRecordPageRequestDTO recordPageRequestDTO) { 26 | return this.listPage(recordPageRequestDTO); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/UserGroupMappingService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.mapper.IUserGroupMappingMapper; 4 | import com.yjq.data.admin.model.domain.UserGroupMapping; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author netyjq@gmail.com 12 | * @date 2019-05-17 13 | */ 14 | @Service 15 | public class UserGroupMappingService extends AbstractBaseService { 16 | 17 | @Autowired 18 | private IUserGroupMappingMapper userGroupMappingMapper; 19 | 20 | public List selectByUserId(Integer userId) { 21 | return userGroupMappingMapper.selectByUserId(userId); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/UserGroupService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.common.exception.ServiceException; 4 | import com.yjq.data.admin.mapper.IUserGroupMapper; 5 | import com.yjq.data.admin.mapper.IUserGroupMappingMapper; 6 | import com.yjq.data.admin.mapper.IUserInfoMapper; 7 | import com.yjq.data.admin.model.domain.UserGroup; 8 | import com.yjq.data.admin.model.domain.UserGroupMapping; 9 | import com.google.common.base.Splitter; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | import java.util.stream.Collectors; 15 | 16 | /** 17 | * @author netyjq@gmail.com 18 | * @date 2019-04-28 19 | */ 20 | @Service 21 | public class UserGroupService extends AbstractBaseService { 22 | 23 | @Autowired 24 | private IUserGroupMapper userGroupMapper; 25 | 26 | @Autowired 27 | private IUserGroupMappingMapper userGroupMappingMapper; 28 | 29 | @Autowired 30 | private IUserInfoMapper userInfoMapper; 31 | 32 | /** 33 | * 新增用户组 34 | * @param name 组名称 35 | * @param description 描述 36 | */ 37 | public void insertUserGroup(String name, String description) { 38 | UserGroup userGroup = userGroupMapper.selectByName(name); 39 | if (userGroup != null) { 40 | throw new ServiceException("user group already exists"); 41 | } 42 | userGroup = new UserGroup(name, description); 43 | super.insert(userGroup); 44 | } 45 | 46 | /** 47 | * 添加组成员 48 | * @param groupId 组id 49 | * @param userIds 用户id 50 | */ 51 | public void addGroupMember(Integer groupId, String userIds) { 52 | UserGroup group = userGroupMapper.selectOne(groupId); 53 | if (group == null) { 54 | throw new ServiceException("group not found. id: " + group); 55 | } 56 | List userIdList = Splitter.on(",").splitToList(userIds).stream().map(Integer::valueOf).collect(Collectors.toList()); 57 | userIdList.forEach(userId-> { 58 | UserGroupMapping mapping = userGroupMappingMapper.select(userId, groupId); 59 | if (mapping == null) { 60 | mapping = new UserGroupMapping(userId, groupId); 61 | userGroupMappingMapper.insertOne(mapping); 62 | } 63 | }); 64 | } 65 | 66 | /** 67 | * 删除组成员 68 | * @param groupId 69 | * @param userId 70 | */ 71 | public void deleteMember(Integer groupId, Integer userId) { 72 | userGroupMappingMapper.deleteMapping(groupId, userId); 73 | } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/service/UserInfoService.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.service; 2 | 3 | import com.yjq.data.admin.common.exception.ServiceException; 4 | import com.yjq.data.admin.mapper.IUserInfoMapper; 5 | import com.yjq.data.admin.model.domain.UserInfo; 6 | import org.assertj.core.util.Strings; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * @author netyjq@gmail.com 15 | * @date 2019-04-28 16 | */ 17 | @Service 18 | public class UserInfoService extends AbstractBaseService { 19 | 20 | @Autowired 21 | private IUserInfoMapper userInfoMapper; 22 | 23 | public void insertUserInfo(String name) { 24 | UserInfo userInfo = findByName(name); 25 | if (userInfo == null) { 26 | userInfo = new UserInfo(); 27 | userInfo.setEmail(name+"@317hu.com"); 28 | userInfo.setLastLogin(new Date()); 29 | userInfo.setRoleType(0); 30 | userInfo.setName(name); 31 | userInfoMapper.insertOne(userInfo); 32 | } else { 33 | userInfo.setLastLogin(new Date()); 34 | userInfoMapper.updateOne(userInfo); 35 | } 36 | } 37 | 38 | public UserInfo findByName(String name) { 39 | if (Strings.isNullOrEmpty(name)) { 40 | throw new ServiceException("name must not be null or empty"); 41 | } 42 | return userInfoMapper.selectByName(name); 43 | } 44 | 45 | /** 46 | * 查询用户组成员 47 | * @param groupId 组id 48 | * @return List 49 | */ 50 | public List findMembers(Integer groupId) { 51 | return userInfoMapper.selectByGroupId(groupId); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/advice/RequestParamAspect.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.advice; 2 | 3 | import com.yjq.data.admin.common.validation.MyValidator; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Before; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.validation.BindingResult; 9 | 10 | /** 11 | * 通过aop实现对controller参数的校验 12 | * @date 2017/7/24 13 | * @author netyjq@gmail.com 14 | */ 15 | @Aspect 16 | @Component 17 | public class RequestParamAspect { 18 | 19 | /** 20 | * 对切面 BindingResult类型参数进行校验,基于Hibernate MyValidator 21 | * @throws Throwable 22 | */ 23 | @Before("execution(* com.yjq.data.admin.web.controller.*.*(..))") 24 | public void doBefore(JoinPoint joinPoint) { 25 | Object [] args = joinPoint.getArgs(); 26 | for (Object object : args) { 27 | if (object instanceof BindingResult) { 28 | BindingResult result = (BindingResult) object; 29 | MyValidator.validateBindResult(result); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/AbstractController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.common.exception.SessionInvalidException; 4 | import com.yjq.data.admin.model.domain.UserInfo; 5 | import com.yjq.data.admin.service.UserInfoService; 6 | import org.assertj.core.util.Strings; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | /** 12 | * @author netyjq@gmail.com 13 | * @date 2019-04-29 14 | */ 15 | public abstract class AbstractController { 16 | 17 | @Autowired 18 | private HttpServletRequest request; 19 | 20 | @Autowired 21 | private UserInfoService userInfoService; 22 | 23 | /** 24 | * 这里做自己的获取用户会话的逻辑 25 | * @return UserInfo 26 | */ 27 | public UserInfo getLoginUser() { 28 | // String token = CookiesUtil.getCookieValue(request, "token"); 29 | // if (Strings.isNullOrEmpty(token)) { 30 | // throw new SessionInvalidException("无会话,请重新登录"); 31 | // } 32 | String name = "yejq"; 33 | 34 | if (Strings.isNullOrEmpty(name)) { 35 | throw new SessionInvalidException("会话失效,请重新登录"); 36 | } 37 | UserInfo userInfo = null; 38 | try { 39 | userInfo = userInfoService.findByName(name); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | if (userInfo == null) { 44 | throw new SessionInvalidException("账号不存在, name: " + name); 45 | } 46 | return userInfo; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/AlarmConfigController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.common.validation.ValidationMarker; 4 | import com.yjq.data.admin.model.domain.AlarmConfig; 5 | import com.yjq.data.admin.model.dto.request.AlarmConfigRequestDTO; 6 | import com.yjq.data.admin.model.dto.response.LayuiResponseDTO; 7 | import com.yjq.data.admin.model.dto.response.ResponseDTO; 8 | import com.yjq.data.admin.service.AlarmConfigService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.validation.annotation.Validated; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @author netyjq@gmail.com 19 | * @date 2019-05-05 20 | */ 21 | @RestController 22 | @RequestMapping("/alarm-config") 23 | public class AlarmConfigController extends AbstractController { 24 | 25 | @Autowired 26 | private AlarmConfigService alarmConfigService; 27 | 28 | @RequestMapping("/insert") 29 | public ResponseDTO insert(@Validated({ValidationMarker.InsertGroup.class}) AlarmConfigRequestDTO insertDTO, BindingResult result) { 30 | alarmConfigService.insertAlarmConfig(insertDTO, getLoginUser()); 31 | return new ResponseDTO(); 32 | } 33 | 34 | @RequestMapping("/update") 35 | public ResponseDTO update(@Validated({ValidationMarker.UpdateGroup.class}) AlarmConfigRequestDTO updateDTO, BindingResult result) { 36 | alarmConfigService.updateAlarmConfig(updateDTO, getLoginUser()); 37 | return new ResponseDTO(); 38 | } 39 | 40 | @RequestMapping("/list") 41 | public LayuiResponseDTO list(@Validated({ValidationMarker.SelectGroup.class}) AlarmConfigRequestDTO selectDTO, BindingResult result) { 42 | List list = alarmConfigService.findAlarmConfigListByAppId(selectDTO.getAppId()); 43 | return new LayuiResponseDTO(list); 44 | } 45 | 46 | @RequestMapping("/delete") 47 | public ResponseDTO delete(@Validated({ValidationMarker.DeleteGroup.class}) AlarmConfigRequestDTO deleteDTO, BindingResult result) { 48 | alarmConfigService.deleteAlarmConfig(deleteDTO.getId()); 49 | return new ResponseDTO(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/AlarmHistoryController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.common.validation.ValidationMarker; 4 | import com.yjq.data.admin.model.domain.AlarmHistory; 5 | import com.yjq.data.admin.model.dto.request.AlarmHistoryRequestDTO; 6 | import com.yjq.data.admin.model.dto.response.LayuiResponseDTO; 7 | import com.yjq.data.admin.service.AlarmHistoryService; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.validation.annotation.Validated; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * @author netyjq@gmail.com 17 | * @date 2019-05-06 18 | */ 19 | @RestController 20 | @RequestMapping("/alarm-history") 21 | public class AlarmHistoryController { 22 | 23 | @Autowired 24 | private AlarmHistoryService alarmHistoryService; 25 | 26 | @RequestMapping("/page") 27 | public LayuiResponseDTO page(@Validated(ValidationMarker.SelectGroup.class) AlarmHistoryRequestDTO requestDTO, BindingResult result) { 28 | PageInfo pageInfo = alarmHistoryService.listPage(requestDTO); 29 | LayuiResponseDTO responseDTO = new LayuiResponseDTO(pageInfo.getList(), Integer.valueOf(pageInfo.getTotal()+"")); 30 | return responseDTO; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/ApiInvokeRecordController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.model.domain.ApiInvokeRecord; 4 | import com.yjq.data.admin.model.dto.request.ApiInvokeRecordPageRequestDTO; 5 | import com.yjq.data.admin.model.dto.response.LayuiResponseDTO; 6 | import com.yjq.data.admin.service.ApiInvokeRecordService; 7 | import com.github.pagehelper.PageInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.validation.BindingResult; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | /** 15 | * @author netyjq@gmail.com 16 | * @date 2019-05-13 17 | */ 18 | @RequestMapping("/api-invoke-record") 19 | @RestController 20 | public class ApiInvokeRecordController { 21 | 22 | @Autowired 23 | private ApiInvokeRecordService apiInvokeRecordService; 24 | 25 | @RequestMapping("/page") 26 | public LayuiResponseDTO page(@Validated ApiInvokeRecordPageRequestDTO recordPageRequestDTO, BindingResult result) { 27 | PageInfo recordPageInfo = apiInvokeRecordService.page(recordPageRequestDTO); 28 | return new LayuiResponseDTO(recordPageInfo.getList(), Integer.valueOf(recordPageInfo.getTotal()+"")); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/ApiTestController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.client.api.core.DataQueryErrorEnum; 4 | import com.yjq.data.client.api.core.Page; 5 | import com.yjq.data.client.api.core.ResponseMessage; 6 | import com.yjq.data.client.api.manage.DataQueryManage; 7 | import com.yjq.data.client.api.query.PageQuery; 8 | import com.yjq.data.client.api.query.SimpleQuery; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.LinkedHashMap; 15 | import java.util.List; 16 | 17 | /** 18 | * @author netyjq@gmail.com 19 | * @date 2019-05-07 20 | */ 21 | @RestController 22 | @RequestMapping("/dubbo/test") 23 | public class ApiTestController { 24 | 25 | @Autowired 26 | private DataQueryManage dataQueryManageImpl; 27 | 28 | @RequestMapping("/list") 29 | public ResponseMessage> list(@RequestBody SimpleQuery simpleQuery) { 30 | return dataQueryManageImpl.queryForList(simpleQuery, LinkedHashMap.class); 31 | } 32 | 33 | @RequestMapping("/page") 34 | public ResponseMessage> page(@RequestBody PageQuery pageQuery) { 35 | if (pageQuery == null || pageQuery.invalid()) { 36 | return new ResponseMessage>().error(DataQueryErrorEnum.REQUEST_PARAMETER_INVALID.getDesc()); 37 | } 38 | return dataQueryManageImpl.queryForPage(pageQuery, LinkedHashMap.class); 39 | } 40 | 41 | @RequestMapping("/object") 42 | public ResponseMessage object(@RequestBody SimpleQuery simpleQuery) { 43 | if (simpleQuery == null || simpleQuery.invalid()) { 44 | return new ResponseMessage().error(DataQueryErrorEnum.REQUEST_PARAMETER_INVALID.getDesc()); 45 | } 46 | return dataQueryManageImpl.queryForObject(simpleQuery, LinkedHashMap.class); 47 | } 48 | 49 | @RequestMapping("/count") 50 | public ResponseMessage count(@RequestBody SimpleQuery simpleQuery) { 51 | if (simpleQuery == null || simpleQuery.invalid()) { 52 | return new ResponseMessage().error(DataQueryErrorEnum.REQUEST_PARAMETER_INVALID.getDesc()); 53 | } 54 | return dataQueryManageImpl.queryForCount(simpleQuery); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/AppUserGroupMappingController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.common.validation.ValidationMarker; 4 | import com.yjq.data.admin.model.dto.request.UserGroupAppDTO; 5 | import com.yjq.data.admin.model.dto.response.ResponseDTO; 6 | import com.yjq.data.admin.service.AppUserGroupMappingService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.validation.BindingResult; 9 | import org.springframework.validation.annotation.Validated; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author netyjq@gmail.com 15 | * @date 2019-05-16 16 | */ 17 | @RestController 18 | @RequestMapping("/app-user-group-mapping") 19 | public class AppUserGroupMappingController { 20 | 21 | @Autowired 22 | private AppUserGroupMappingService appUserGroupMappingService; 23 | 24 | @RequestMapping("/insert") 25 | public ResponseDTO insertMapping(@Validated({ValidationMarker.InsertGroup.class}) UserGroupAppDTO userGroupAppDTO, BindingResult result) { 26 | appUserGroupMappingService.insertMapping(userGroupAppDTO.getAppIds(), userGroupAppDTO.getUserGroupId()); 27 | return new ResponseDTO(); 28 | } 29 | 30 | @RequestMapping("/delete") 31 | public ResponseDTO deleteMapping(@Validated({ValidationMarker.DeleteGroup.class}) UserGroupAppDTO userGroupAppDTO, BindingResult result) { 32 | appUserGroupMappingService.deleteMapping(userGroupAppDTO.getAppId(), userGroupAppDTO.getUserGroupId()); 33 | return new ResponseDTO(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.google.common.base.Strings; 4 | import com.yjq.data.admin.common.MD5; 5 | import com.yjq.data.admin.common.exception.ParamInvalidException; 6 | import com.yjq.data.admin.common.exception.ServiceException; 7 | import com.yjq.data.admin.model.domain.UserInfo; 8 | import com.yjq.data.admin.model.dto.response.ResponseDTO; 9 | import com.yjq.data.admin.service.UserInfoService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import javax.servlet.http.Cookie; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.util.UUID; 17 | 18 | /** 19 | * @author netyjq@gmail.com 20 | * @date 2018/9/19 21 | */ 22 | @RestController 23 | @RequestMapping("/login") 24 | public class LoginController { 25 | 26 | @Autowired 27 | private UserInfoService userInfoService; 28 | 29 | /** 30 | * 登录检查 31 | * @return 32 | */ 33 | @RequestMapping("/checkLogin") 34 | public ResponseDTO checkLogin(String uid, String password, HttpServletResponse response) { 35 | if (Strings.isNullOrEmpty(uid)) { 36 | throw new ParamInvalidException("username", "不能为空"); 37 | } 38 | UserInfo userInfo = null; 39 | boolean flag = false; 40 | try { 41 | userInfo = userInfoService.findByName(uid); 42 | if (userInfo != null) { 43 | flag = true; 44 | } 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | if (flag) { 49 | String token = uid + ":" + MD5.sign(UUID.randomUUID().toString()); 50 | Cookie cookie = new Cookie("token", token); 51 | cookie.setMaxAge(2 * 60 * 60 * 1000); 52 | cookie.setPath("/"); 53 | response.addCookie(cookie); 54 | return new ResponseDTO(); 55 | } 56 | throw new ServiceException("登录失败,账号或密码错误"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/SqlOperationRecordController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.model.domain.SqlOperationRecord; 4 | import com.yjq.data.admin.model.dto.request.SqlOperationRecordPageRequestDTO; 5 | import com.yjq.data.admin.model.dto.response.LayuiResponseDTO; 6 | import com.yjq.data.admin.service.SqlOperationRecordService; 7 | import com.github.pagehelper.PageInfo; 8 | import com.google.common.base.Strings; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.validation.annotation.Validated; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * @author netyjq@gmail.com 17 | * @date 2019-05-13 18 | */ 19 | @RequestMapping("/sql-operation-record") 20 | @RestController 21 | public class SqlOperationRecordController { 22 | 23 | @Autowired 24 | private SqlOperationRecordService sqlOperationRecordService; 25 | 26 | @RequestMapping("/page") 27 | public LayuiResponseDTO page(@Validated SqlOperationRecordPageRequestDTO recordPageRequestDTO, BindingResult result) { 28 | PageInfo recordPageInfo = sqlOperationRecordService.page(recordPageRequestDTO); 29 | recordPageInfo.getList().forEach(sqlOperationRecord -> { 30 | if (!Strings.isNullOrEmpty(sqlOperationRecord.getSqltextBefore())) { 31 | sqlOperationRecord.setSqltextBefore(sqlOperationRecord.getSqltextBefore().replace("<", "<").replace(">", ">")); 32 | } 33 | sqlOperationRecord.setSqltextAfter(sqlOperationRecord.getSqltextAfter().replace("<", "<").replace(">", ">")); 34 | }); 35 | return new LayuiResponseDTO(recordPageInfo.getList(), Integer.valueOf(recordPageInfo.getTotal()+"")); 36 | } 37 | 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/SqlTemplateController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.common.BeanUtil; 4 | import com.yjq.data.admin.model.domain.SqlTemplate; 5 | import com.yjq.data.admin.model.dto.request.SqlTemplateInsertRequestDTO; 6 | import com.yjq.data.admin.model.dto.request.SqlTemplateUpdateRequestDTO; 7 | import com.yjq.data.admin.model.dto.response.LayuiResponseDTO; 8 | import com.yjq.data.admin.model.dto.response.ResponseDTO; 9 | import com.yjq.data.admin.service.SqlTemplateService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.validation.BindingResult; 12 | import org.springframework.validation.annotation.Validated; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | * @author netyjq@gmail.com 22 | * @date 2019-04-28 23 | */ 24 | @RestController 25 | @RequestMapping("/sqltemplate") 26 | public class SqlTemplateController extends AbstractController { 27 | 28 | @Autowired 29 | private SqlTemplateService sqlTemplateService; 30 | 31 | @RequestMapping({"/insert"}) 32 | public ResponseDTO insert(@Validated SqlTemplateInsertRequestDTO insertRequestDTO, BindingResult result) { 33 | sqlTemplateService.insertSqlTemplate(insertRequestDTO, getLoginUser()); 34 | return new ResponseDTO(); 35 | } 36 | 37 | @RequestMapping("/update") 38 | public ResponseDTO update(@Validated SqlTemplateUpdateRequestDTO updateRequestDTO, BindingResult result) { 39 | sqlTemplateService.updateSqlTemplate(updateRequestDTO, getLoginUser()); 40 | return new ResponseDTO(); 41 | } 42 | 43 | 44 | @RequestMapping("/list") 45 | public LayuiResponseDTO list(Integer appId) { 46 | if (appId == null) { 47 | return new LayuiResponseDTO(Collections.emptyList()); 48 | } 49 | Map filters = BeanUtil.getPropertyMap("appId", appId); 50 | List list = sqlTemplateService.list(filters); 51 | list.forEach(sqlTemplate -> { 52 | sqlTemplate.setSqltext(sqlTemplate.getSqltext().replace("<", "<").replace(">", ">")); 53 | }); 54 | return new LayuiResponseDTO(list); 55 | } 56 | 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/UserInfoController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller; 2 | 3 | import com.yjq.data.admin.model.dto.response.ResponseDTO; 4 | import com.yjq.data.admin.service.UserInfoService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-05 12 | */ 13 | @RestController 14 | @RequestMapping("/userinfo") 15 | public class UserInfoController extends AbstractController { 16 | 17 | @Autowired 18 | private UserInfoService userInfoService; 19 | 20 | @RequestMapping("/list") 21 | public ResponseDTO list() { 22 | return new ResponseDTO(userInfoService.listAll()); 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /data-center-admin/src/main/java/com/yjq/data/admin/web/controller/test/AppInfoTestController.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.admin.web.controller.test; 2 | 3 | import com.yjq.data.admin.model.domain.AppInfo; 4 | import com.yjq.data.client.api.core.Page; 5 | import com.yjq.data.client.api.core.ResponseMessage; 6 | import com.yjq.data.client.api.manage.DataQueryManage; 7 | import com.yjq.data.client.api.query.PageQuery; 8 | import com.yjq.data.client.api.query.SimpleQuery; 9 | import org.apache.ibatis.annotations.Param; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.List; 17 | 18 | /** 19 | * @author yejiaqian 20 | * @date Created in 2020/3/9 18:18
21 | */ 22 | @RestController 23 | @RequestMapping("/app/test") 24 | public class AppInfoTestController { 25 | 26 | @Resource 27 | private DataQueryManage dataQueryManageImpl; 28 | 29 | @GetMapping("/get") 30 | public ResponseMessage get(@Param("appId") Integer appId, @Param("sqlId") String sqlId) { 31 | return dataQueryManageImpl.queryForObject(new SimpleQuery(appId, sqlId, null), AppInfo.class); 32 | } 33 | 34 | @GetMapping("/list") 35 | public ResponseMessage> list(@Param("appId") Integer appId, @Param("sqlId") String sqlId) { 36 | return dataQueryManageImpl.queryForList(new SimpleQuery(appId, sqlId, null), AppInfo.class); 37 | } 38 | @GetMapping("/count") 39 | public ResponseMessage count(@Param("appId") Integer appId, @Param("sqlId") String sqlId) { 40 | return dataQueryManageImpl.queryForCount(new SimpleQuery(appId, sqlId, null)); 41 | } 42 | 43 | @GetMapping("/page") 44 | public ResponseMessage> page(@Param("appId") Integer appId, @Param("sqlId") String sqlId) { 45 | return dataQueryManageImpl.queryForPage(new PageQuery(appId, sqlId, null, 1, 10), AppInfo.class); 46 | } 47 | 48 | 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.include.mapper=/mapper-[\\w-\\.]+jar 2 | restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar 3 | restart.include.dubbo=/dubbo-[\\d\\.]+\\.jar 4 | restart.include.roc.dubbo=/rpc-dubbo-.*\\.jar -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=logs 3 | 4 | # server 5 | server.port=8082 6 | 7 | ## datasource config 8 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 9 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 10 | spring.datasource.username=root 11 | spring.datasource.password=123456 12 | spring.datasource.sql-script-encoding=utf-8 13 | 14 | ## dubbo config 15 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 16 | spring.dubbo.version=1.0.0.dev 17 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=/opt/data-center-admin/logs 3 | 4 | ## datasource config 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 6 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 7 | spring.datasource.username=root 8 | spring.datasource.password=123456 9 | spring.datasource.sql-script-encoding=utf-8 10 | 11 | ## dubbo config 12 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 13 | spring.dubbo.version=1.0.0 -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/application-sit.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=/opt/data-center-admin/logs 3 | 4 | ## datasource config 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 6 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 7 | spring.datasource.username=root 8 | spring.datasource.password=123456 9 | spring.datasource.sql-script-encoding=utf-8 10 | 11 | ## dubbo config 12 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 13 | spring.dubbo.version=1.0.0.sit -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # active profile 2 | spring.profiles.active=@activatedProperties@ 3 | 4 | # tomcat port 5 | server.port=8080 6 | 7 | ## encoding 8 | spring.http.encoding.charset=UTF-8 9 | spring.http.encoding.force=true 10 | spring.http.encoding.enabled=true 11 | server.tomcat.uri-encoding=UTF-8 12 | 13 | ## mybatis config 14 | mybatis.typeAliasesPackage=com.yjq.data.admin.model 15 | mybatis.mapperLocations=classpath:mapper/*.xml 16 | 17 | #pagehelper 18 | pagehelper.helperDialect=postgresql 19 | pagehelper.reasonable=true 20 | pagehelper.supportMethodsArguments=true 21 | pagehelper.params=count=countSql 22 | 23 | ## log path 24 | logging.path=logging.config=classpath:config/logging-config.xml 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/alarm-history-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 32 | 33 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/api-invoke-record-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/app-info-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 26 | 27 | 30 | 31 | 32 | 35 | 36 | 37 | insert into app_info (name, create_time) values (#{name}, #{createTime}) 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/app-user-group-mapping-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 28 | 29 | 30 | insert into app_user_group_mapping(app_id, app_name, user_group_id, user_group_name) 31 | values (#{appId}, #{appName}, #{userGroupId}, #{userGroupName}) 32 | 33 | 34 | 37 | 38 | 41 | 42 | 45 | 46 | 47 | delete from app_user_group_mapping where app_id = #{appId} and user_group_id = #{userGroupId} 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/sql-operation-record-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 38 | 39 | 40 | 43 | 44 | 45 | insert into sql_operation_record (sql_id, operator_id, operator_name, type, create_time, sqltext_before, 46 | sqltext_after, page_before, page_after, parameter_mapping_before, parameter_mapping_after) values ( 47 | #{sqlId}, #{operatorId}, #{operatorName}, #{type}, #{createTime}, #{sqltextBefore}, #{sqltextAfter}, 48 | #{pageBefore}, #{pageAfter}, #{parameterMappingBefore}, #{parameterMappingAfter} 49 | ) 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/user-group-mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | delete from user_group_mapping where user_group_id = #{userGroupId} and user_id = #{userId} 20 | 21 | 22 | 23 | insert into user_group_mapping(user_id, user_group_id) values (#{userId}, #{userGroupId}) 24 | 25 | 26 | 29 | 30 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/user-group-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | insert into user_group (name, description, create_time) values (#{name}, #{description}, now()) 17 | 18 | 19 | 22 | 23 | 24 | 27 | 28 | 31 | 32 | 33 | insert into user_group(name, description, create_time) values (#{name}, #{description}, #{createTime}) 34 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/mapper/user-info-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 27 | 28 | 29 | insert into user_info (name, email, last_login, role_type) values (#{name}, #{email}, #{lastLogin}, #{roleType}) 30 | 31 | 32 | 33 | update user_info set last_login = #{lastLogin} where id = #{id} 34 | 35 | 36 | 39 | 40 | 43 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/spring-dubbo.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/css/login.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | overflow: hidden; 4 | } 5 | body { 6 | background: url("../images/login/login_line.jpg") left center repeat-x; 7 | height: 100%; 8 | } 9 | /*移除表单填充色*/ 10 | input:-webkit-autofill { 11 | -webkit-box-shadow: 0 0 0 1000px #ececec inset; 12 | } 13 | /*按钮移上去颜色*/ 14 | .layui-btn-primary:hover { 15 | border-color: #1E9FFF; 16 | color: #333; 17 | } 18 | /*页面背景色*/ 19 | .m-login-bg { 20 | background: url("../images/login/login_bg.png") left center repeat-x; 21 | height: 100%; 22 | } 23 | .m-login { 24 | width: 390px; 25 | position: absolute; 26 | left: 50%; 27 | top: 50%; 28 | margin-left: -195px; 29 | margin-top: -205px; 30 | } 31 | .m-login h3 { 32 | color: #fff; 33 | text-align: center; 34 | height: 60px; 35 | font-size: 28px; 36 | } 37 | .m-login .copyright { 38 | text-align: center; 39 | color: #999; 40 | padding-top: 10px; 41 | } 42 | .m-login-warp { 43 | background: #fff; 44 | -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); 45 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); 46 | -webkit-border-radius: 6px; 47 | border-radius: 6px; 48 | padding: 25px; 49 | } 50 | .m-login-warp .layui-input { 51 | height: 40px; 52 | line-height: 40px\9; 53 | margin-bottom: 5px; 54 | -webkit-transition-property: none; 55 | transition-property: none; 56 | background: #ececec; 57 | border: 1px solid #ececec; 58 | } 59 | .m-login-warp .m-login-btn .layui-inline { 60 | width: 49%; 61 | margin: 0; 62 | } 63 | .m-login-warp .m-login-btn .layui-inline button { 64 | width: 100%; 65 | } 66 | .m-login-warp .verifyImg { 67 | width: 130px; 68 | height: 42px; 69 | } 70 | @media screen and (max-width: 450px) { 71 | .m-login { 72 | width: 300px; 73 | position: absolute; 74 | left: 50%; 75 | top: 50%; 76 | margin-left: -150px; 77 | margin-top: -240px; 78 | } 79 | .layui-form-item .layui-inline { 80 | display: block; 81 | margin-right: 0; 82 | margin-bottom: 20px; 83 | clear: both; 84 | } 85 | .m-login-warp .m-login-btn .layui-inline { 86 | width: 100%; 87 | margin: 0 0 10px; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/l-line-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/l-line-white.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/l-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/l-line.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/login/login_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/login/login_bg.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/login/login_line.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/login/login_line.jpg -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/login/yzm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/login/yzm.jpg -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/images/logo.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/data-center-admin/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /data-center-admin/src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /data-center-admin/src/test/java/com/yjq/data/test/BeetlTest.java: -------------------------------------------------------------------------------- 1 | //package com.yjq.data.test; 2 | // 3 | //import com.yjq.data.admin.AdminBootstrap; 4 | //import org.beetl.core.Configuration; 5 | //import org.beetl.core.GroupTemplate; 6 | //import org.beetl.core.Template; 7 | //import org.beetl.core.resource.StringTemplateResourceLoader; 8 | //import org.junit.Test; 9 | //import org.junit.runner.RunWith; 10 | //import org.springframework.boot.test.context.SpringBootTest; 11 | //import org.springframework.test.context.junit4.SpringRunner; 12 | // 13 | //import java.io.IOException; 14 | //import java.util.HashMap; 15 | //import java.util.Map; 16 | //import java.util.Properties; 17 | // 18 | ///** 19 | // * @author netyjq@gmail.com 20 | // * @date 2019-05-15 21 | // */ 22 | ////@SpringBootTest(classes = AdminBootstrap.class) 23 | ////@RunWith(SpringRunner.class) 24 | //public class BeetlTest { 25 | // 26 | // 27 | // public static void main(String args[]) { 28 | // //new一个模板资源加载器 29 | // StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader(); 30 | // /* 使用Beetl默认的配置。 31 | // * Beetl可以使用配置文件的方式去配置,但由于此处是直接上手的例子, 32 | // * 我们不去管配置的问题,只需要基本的默认配置就可以了。 33 | // */ 34 | // Configuration config = null; 35 | // try { 36 | // config = Configuration.defaultConfiguration(); 37 | //// Properties properties = new Properties(); 38 | //// properties.put("DELIMITER_STATEMENT_START", "<#"); 39 | //// properties.put("DELIMITER_STATEMENT_END", ""); 40 | //// config.setPs(properties); 41 | // } catch (IOException e) { 42 | // e.printStackTrace(); 43 | // } 44 | // //Beetl的核心GroupTemplate 45 | // GroupTemplate groupTemplate = new GroupTemplate(resourceLoader, config); 46 | // //我们自定义的模板,其中${title}就Beetl默认的占位符 47 | // String testTemplate="select * from app_info where 1=1 <%if(${name}!=null && ${name} != '') {%> and name = #{name} <%}%>"; 48 | // Template template = groupTemplate.getTemplate(testTemplate); 49 | // Map map = new HashMap<>(); 50 | // map.put("name", "统一接入"); 51 | // //渲染字符串 52 | // template.binding(map); 53 | // String str = template.render(); 54 | // System.out.println(str); 55 | // } 56 | // 57 | //} 58 | -------------------------------------------------------------------------------- /data-center-admin/src/test/java/com/yjq/data/test/FreemarkerTest.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.test; 2 | 3 | import com.yjq.data.admin.config.MyFreemarkerConfig; 4 | import freemarker.cache.StringTemplateLoader; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-16 12 | */ 13 | public class FreemarkerTest { 14 | 15 | public static void main(String args[]) { 16 | MyFreemarkerConfig cfg = new MyFreemarkerConfig(freemarker.template.Configuration.VERSION_2_3_0); 17 | cfg.setDefaultEncoding("UTF-8"); 18 | cfg.setLogTemplateExceptions(false); 19 | cfg.setStringTemplateLoader(new StringTemplateLoader()); 20 | String templateStr = "select * from app_info where 1=1 <#if name?? && name != ''>and name = ${r'#{'}name}"; 21 | templateStr = "select * from app_info where 1=1 <#if name?? && name != ''>and name = <#noparse>#{name}"; 22 | Map map = new HashMap<>(); 23 | map.put("name", "name"); 24 | String result = cfg.render("11", templateStr, map); 25 | System.out.println(result); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /data-center-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | data-center 7 | com.yjq 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | jar 12 | 13 | 14 | data-center-client 15 | 16 | 17 | org.apache.maven.plugins 18 | maven-compiler-plugin 19 | 20 | 8 21 | 8 22 | 23 | 24 | 25 | 26 | 27 | data-center-client 28 | 29 | 30 | 31 | com.github.pagehelper 32 | pagehelper 33 | 5.1.8 34 | 35 | 36 | 37 | org.freemarker 38 | freemarker 39 | 2.3.28 40 | 41 | 42 | com.fasterxml.jackson.core 43 | jackson-databind 44 | 45 | 46 | 47 | com.alibaba 48 | fastjson 49 | 50 | 51 | 52 | org.projectlombok 53 | lombok 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-web 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/core/DataQueryErrorEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.core; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-06 6 | */ 7 | public enum DataQueryErrorEnum { 8 | 9 | /** 10 | * 参数校验不通过 11 | */ 12 | REQUEST_PARAMETER_INVALID("参数校验不通过。"), 13 | 14 | /** 15 | * 无法查询到SQL模板 16 | */ 17 | SQL_TEMPLATE_NOT_FOUND("无法查询到SQL模板。"), 18 | 19 | /** 20 | * 调用错误,接口需要分页 21 | */ 22 | SHOULD_BE_PAGING("方法调用错误,接口需要分页。"), 23 | 24 | /** 25 | * 调用发生异常 26 | */ 27 | EXECUTING_ERROR("服务出错了,请联系服务提供者。"), 28 | 29 | 30 | /** 31 | * sql模板解析异常 32 | */ 33 | TEMPLATE_RENDER_ERROR("SQL模板解析异常: 请仔细检查你配置的SQL模板。"), 34 | 35 | /** 36 | * 反序列化失败 37 | */ 38 | DESERIALIZATION_ERROR("数据转换pojo失败,请检查sql执行结果,以及pojo字段。"), 39 | 40 | /** 41 | * SQL执行出错 42 | */ 43 | SQL_EXECUTE_ERROR("SQL执行异常: 可能是sql编写错误或者SQL模板解析后的SQL语法出现错误,请仔细核对入参和sql模板。"); 44 | 45 | 46 | 47 | private String desc; 48 | 49 | DataQueryErrorEnum(String desc) { 50 | this.desc = desc; 51 | } 52 | 53 | public String getDesc() { 54 | return desc; 55 | } 56 | 57 | public void setDesc(String desc) { 58 | this.desc = desc; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/core/DataQueryException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.core; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * @author netyjq@gmail.com 7 | * @date 2019-05-06 8 | */ 9 | public class DataQueryException extends RuntimeException { 10 | 11 | private String code; 12 | 13 | private String message; 14 | 15 | public DataQueryException(String code, String message) { 16 | this.code = code; 17 | this.message = message; 18 | } 19 | 20 | public DataQueryException(DataQueryErrorEnum errorEnum, String message) { 21 | this.code = errorEnum.name(); 22 | this.message = errorEnum.getDesc(); 23 | if (Objects.nonNull(message)) { 24 | this.message = errorEnum.getDesc() + message; 25 | } 26 | } 27 | 28 | public DataQueryException(DataQueryErrorEnum errorEnum, Exception e) { 29 | this.code = errorEnum.name(); 30 | this.message = errorEnum.getDesc(); 31 | if (Objects.nonNull(e) && Objects.nonNull(e.getMessage())) { 32 | this.message = errorEnum.getDesc() + e.getMessage(); 33 | } 34 | } 35 | 36 | public String getCode() { 37 | return code; 38 | } 39 | 40 | public void setCode(String code) { 41 | this.code = code; 42 | } 43 | 44 | @Override 45 | public String getMessage() { 46 | return message; 47 | } 48 | 49 | public void setMessage(String message) { 50 | this.message = message; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/core/Page.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.core; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * @author yejiaqian 10 | * @date Created in 2020/3/9 13:59
11 | */ 12 | @Data 13 | public class Page implements Serializable { 14 | 15 | /** 16 | * 总数 17 | */ 18 | private int total; 19 | 20 | /** 21 | * 当页面码 22 | */ 23 | private int pageNo; 24 | 25 | /** 26 | * 每页大小 27 | */ 28 | private int pageSize; 29 | 30 | /** 31 | * 数据 32 | */ 33 | private List tList; 34 | 35 | public Page(int total, int pageNo, int pageSize, List tList) { 36 | this.total = total; 37 | this.pageNo = pageNo; 38 | this.pageSize = pageSize; 39 | this.tList = tList; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/core/ResponseMessage.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.core; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author netyjq@gmail.com 7 | * @date 2019-04-28 8 | */ 9 | public class ResponseMessage implements Serializable { 10 | 11 | private E object; 12 | 13 | private String errorMessage; 14 | 15 | private Boolean success; 16 | 17 | public Object getObject() { 18 | return object; 19 | } 20 | 21 | public ResponseMessage(E object, String errorMessage, Boolean success) { 22 | this.object = object; 23 | this.errorMessage = errorMessage; 24 | this.success = success; 25 | } 26 | 27 | public ResponseMessage() { 28 | } 29 | 30 | public ResponseMessage success(E object) { 31 | this.success = true; 32 | this.object = object; 33 | return this; 34 | } 35 | 36 | public ResponseMessage error(String errorMessage) { 37 | this.success = false; 38 | this.errorMessage = errorMessage; 39 | return this; 40 | } 41 | 42 | public void setObject(E object) { 43 | this.object = object; 44 | } 45 | 46 | public String getErrorMessage() { 47 | return errorMessage; 48 | } 49 | 50 | public void setErrorMessage(String errorMessage) { 51 | this.errorMessage = errorMessage; 52 | } 53 | 54 | public Boolean getSuccess() { 55 | return success; 56 | } 57 | 58 | public void setSuccess(Boolean success) { 59 | this.success = success; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/invoke/DataQueryInvoker.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.invoke; 2 | 3 | import com.yjq.data.client.api.core.DataQueryException; 4 | import com.yjq.data.client.api.core.Page; 5 | import com.yjq.data.client.api.query.PageQuery; 6 | import com.yjq.data.client.api.query.SimpleQuery; 7 | 8 | import java.util.LinkedHashMap; 9 | import java.util.List; 10 | 11 | /** 12 | * @author netyjq@gmail.com 13 | * @date 2019/4/22 14 | */ 15 | public interface DataQueryInvoker { 16 | 17 | /** 18 | * 查询单个 19 | * @param query 入参 20 | * @return LinkedHashMap 21 | */ 22 | LinkedHashMap queryForObject(SimpleQuery query) throws DataQueryException; 23 | 24 | /** 25 | * 批量查询 26 | * @param query query 27 | * @return List result list 28 | */ 29 | List> queryForList(SimpleQuery query) throws DataQueryException; 30 | 31 | /** 32 | * 分页查询 33 | * @param pageQuery PageRequest 34 | * @return Page 35 | */ 36 | Page> queryForPage(PageQuery pageQuery) throws DataQueryException; 37 | 38 | /** 39 | * 查询数量 40 | * @param simpleQuery SimpleQuery 41 | * @return long 42 | */ 43 | long queryCount(SimpleQuery simpleQuery) throws DataQueryException; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/manage/DataQueryManage.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.manage; 2 | 3 | import com.yjq.data.client.api.core.DataQueryException; 4 | import com.yjq.data.client.api.core.Page; 5 | import com.yjq.data.client.api.core.ResponseMessage; 6 | import com.yjq.data.client.api.query.PageQuery; 7 | import com.yjq.data.client.api.query.SimpleQuery; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author yejiaqian 13 | * @date Created in 2020/3/9 14:19
14 | */ 15 | public interface DataQueryManage { 16 | 17 | /** 18 | * 查询数据列表 19 | * @param simpleQuery parameters 20 | * @param tClass T 21 | * @return ResponseMessage> 22 | * @throws DataQueryException DataQueryException 23 | */ 24 | ResponseMessage> queryForList(SimpleQuery simpleQuery, Class tClass) throws DataQueryException; 25 | 26 | /** 27 | * 查询单条数据 28 | * @param simpleQuery parameters 29 | * @param tClass t 30 | * @return ResponseMessage 31 | * @throws DataQueryException DataQueryException 32 | */ 33 | ResponseMessage queryForObject(SimpleQuery simpleQuery, Class tClass) throws DataQueryException; 34 | 35 | /** 36 | * 分页查询 37 | * @param pageQuery parameters 38 | * @param tClass t 39 | * @return ResponseMessage> 40 | * @throws DataQueryException DataQueryException 41 | */ 42 | ResponseMessage> queryForPage(PageQuery pageQuery, Class tClass) throws DataQueryException; 43 | 44 | /** 45 | * 查询数量 46 | * @param simpleQuery parameters 47 | * @return ResponseMessage 48 | * @throws DataQueryException DataQueryException 49 | */ 50 | ResponseMessage queryForCount(SimpleQuery simpleQuery) throws DataQueryException; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/query/AbstractQuery.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.query; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.UUID; 7 | 8 | /** 9 | * @author netyjq@gmail.com 10 | * @date 2019/4/22 11 | */ 12 | public abstract class AbstractQuery implements Serializable { 13 | 14 | /** 15 | * application id 16 | */ 17 | private Integer appId; 18 | 19 | /** 20 | * id of SqlTemplate 21 | */ 22 | private String sqlId; 23 | 24 | /** 25 | * parameters 26 | */ 27 | private Map filters; 28 | 29 | /** 30 | * 请求id 31 | */ 32 | private String requestId; 33 | 34 | 35 | /** 36 | * validation 37 | * @return return true if parameters can't through validation, otherwise return false 38 | */ 39 | public abstract boolean invalid(); 40 | 41 | public AbstractQuery(Integer appId, String sqlId, Map filters) { 42 | this.appId = appId; 43 | this.sqlId = sqlId; 44 | this.filters = filters; 45 | this.requestId = UUID.randomUUID().toString(); 46 | } 47 | 48 | public AbstractQuery() { 49 | } 50 | 51 | public Integer getAppId() { 52 | return appId; 53 | } 54 | 55 | public void setAppId(Integer appId) { 56 | this.appId = appId; 57 | } 58 | 59 | public String getSqlId() { 60 | return sqlId; 61 | } 62 | 63 | public void setSqlId(String sqlId) { 64 | this.sqlId = sqlId; 65 | } 66 | 67 | public Map getFilters() { 68 | if (filters == null) { 69 | this.filters = new HashMap(); 70 | } 71 | return filters; 72 | } 73 | 74 | public void setFilters(Map filters) { 75 | this.filters = filters; 76 | } 77 | 78 | public String getRequestId() { 79 | return requestId; 80 | } 81 | 82 | public void setRequestId(String requestId) { 83 | this.requestId = requestId; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/query/PageQuery.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.query; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import java.util.Collections; 7 | import java.util.Map; 8 | 9 | /** 10 | * 分页query 11 | * @author netyjq@gmail.com 12 | * @date 2019/4/22 13 | */ 14 | @Data 15 | public class PageQuery extends AbstractQuery { 16 | 17 | /** 18 | * 页码 19 | */ 20 | private int pageNum; 21 | 22 | /** 23 | * size 24 | */ 25 | private int pageSize; 26 | 27 | public PageQuery(Integer appId, String sqlId, Map filters, int pageNum, int pageSize) { 28 | super(appId, sqlId, filters); 29 | this.pageSize = pageSize; 30 | this.pageNum = pageNum; 31 | } 32 | 33 | public PageQuery(Integer appId, String sqlId, int pageNum, int pageSize) { 34 | super(appId, sqlId, Collections.emptyMap()); 35 | this.pageSize = pageSize; 36 | this.pageNum = pageNum; 37 | } 38 | 39 | @Override 40 | public boolean invalid() { 41 | if (super.getAppId() == null || super.getSqlId() == null || pageNum < 1 || pageSize < 1) { 42 | return true; 43 | } 44 | return false; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /data-center-client/src/main/java/com/yjq/data/client/api/query/SimpleQuery.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.client.api.query; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * @author netyjq@gmail.com 9 | * @date 2019/4/24 10 | */ 11 | @Data 12 | public class SimpleQuery extends AbstractQuery { 13 | 14 | public SimpleQuery(Integer appId, String sqlId, Map filters) { 15 | super(appId, sqlId, filters); 16 | } 17 | 18 | @Override 19 | public boolean invalid() { 20 | if (super.getAppId() == null || super.getSqlId() == null) { 21 | return true; 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/ServiceBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.web.support.SpringBootServletInitializer; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 10 | import org.springframework.context.annotation.ImportResource; 11 | import org.springframework.scheduling.annotation.EnableScheduling; 12 | 13 | /** 14 | * SpringBoot 启动类 15 | * @date 2017/6/7 16 | * @author netyjq@gmail.com 17 | */ 18 | @SpringBootApplication 19 | @MapperScan("com.yjq.mapper") 20 | @ComponentScan("com.yjq") 21 | @EnableScheduling 22 | @EnableAspectJAutoProxy 23 | @ImportResource("classpath:spring-dubbo.xml") 24 | public class ServiceBootstrap extends SpringBootServletInitializer { 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(ServiceBootstrap.class, args); 28 | } 29 | 30 | @Override 31 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 32 | return application.sources(ServiceBootstrap.class); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/alarm/AlarmMessageSender.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.alarm; 2 | 3 | /** 4 | * 邮件发送器 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-07 7 | */ 8 | public interface AlarmMessageSender { 9 | 10 | /** 11 | * 发送邮件 12 | * @param alarmChecker 告警检查器 13 | */ 14 | void send(AlarmChecker alarmChecker); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/AlarmRuleEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * 告警规则 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-05 7 | */ 8 | public enum AlarmRuleEnum { 9 | 10 | /** 11 | * 慢查询数量 12 | */ 13 | SLOW_COUNT(1, "慢查询数量"), 14 | 15 | /** 16 | * 错误数量 17 | */ 18 | ERROR_COUNT(2, "错误数量"); 19 | 20 | public static AlarmRuleEnum getByRuleCode(int ruleCode) { 21 | for (AlarmRuleEnum alarmRuleEnum : AlarmRuleEnum.values()) { 22 | if (alarmRuleEnum.getRuleCode() == ruleCode) { 23 | return alarmRuleEnum; 24 | } 25 | } 26 | return SLOW_COUNT; 27 | } 28 | 29 | private int ruleCode; 30 | 31 | private String desc; 32 | 33 | AlarmRuleEnum(int ruleCode, String desc) { 34 | this.ruleCode = ruleCode; 35 | this.desc = desc; 36 | } 37 | 38 | public int getRuleCode() { 39 | return ruleCode; 40 | } 41 | 42 | public void setRuleCode(int ruleCode) { 43 | this.ruleCode = ruleCode; 44 | } 45 | 46 | public String getDesc() { 47 | return desc; 48 | } 49 | 50 | public void setDesc(String desc) { 51 | this.desc = desc; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/Constant.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * 静态常量 5 | * @author netyjq@gmail.com 6 | * @date 2019-05-05 7 | */ 8 | public class Constant { 9 | 10 | /** 11 | * 告警历史表 分表数量 12 | */ 13 | public static final int ALARM_HISTORY_TABLE_SPLIT_SIZE = 5; 14 | 15 | public static final String ALARM_EMAIL_SUBJECT = "数据中心告警"; 16 | 17 | /** 18 | * 默认5秒钟为慢查询 19 | */ 20 | public static final int DEFAULT_TIMEOUT = 5000; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/PaginationEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * 分页 5 | * @author netyjq@gmail.com 6 | * @date 2019-04-29 7 | */ 8 | public enum PaginationEnum { 9 | 10 | /** 11 | * 分页 12 | */ 13 | YES(0), 14 | 15 | /** 16 | * 不分页 17 | */ 18 | NO(-1); 19 | 20 | private int code; 21 | 22 | PaginationEnum(int code) { 23 | this.code = code; 24 | } 25 | 26 | public static PaginationEnum getByCode(int code) { 27 | for (PaginationEnum paginationEnum : PaginationEnum.values()) { 28 | if (paginationEnum.code == code) { 29 | return paginationEnum; 30 | } 31 | } 32 | return PaginationEnum.YES; 33 | } 34 | 35 | public int getCode() { 36 | return code; 37 | } 38 | 39 | public void setCode(int code) { 40 | this.code = code; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/ParamMappingException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-16 6 | */ 7 | public class ParamMappingException extends RuntimeException { 8 | 9 | private String message; 10 | 11 | public ParamMappingException(String message) { 12 | this.message = message; 13 | } 14 | 15 | @Override 16 | public String getMessage() { 17 | return message; 18 | } 19 | 20 | public void setMessage(String message) { 21 | this.message = message; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/ProgressEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-07 6 | */ 7 | public enum ProgressEnum { 8 | 9 | /** 10 | * 已处理 11 | */ 12 | PROCESSED(1), 13 | 14 | /** 15 | * 未处理 16 | */ 17 | UN_PROCESSED(-1); 18 | 19 | private int code; 20 | 21 | ProgressEnum(int code) { 22 | this.code = code; 23 | } 24 | 25 | public int getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(int code) { 30 | this.code = code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/SqlException.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-20 6 | */ 7 | public class SqlException extends RuntimeException { 8 | 9 | private String message; 10 | 11 | public SqlException(String message) { 12 | this.message = message; 13 | } 14 | 15 | @Override 16 | public String getMessage() { 17 | return message; 18 | } 19 | 20 | public void setMessage(String message) { 21 | this.message = message; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/SqltextReg.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * @author netyjq@gmail.com 7 | * @date 2019-05-18 8 | */ 9 | public class SqltextReg { 10 | 11 | public final static String DOLLAR_SYMBOL_PATTERN_STR = "^#{[A-Za-z0-9]+}$"; 12 | 13 | public final static String HASH_SYMBOL_PATTERN_STR = "^${[A-Za-z0-9]+}$"; 14 | 15 | public final static Pattern DOLLAR_SYMBOL_PATTERN = Pattern.compile(DOLLAR_SYMBOL_PATTERN_STR); 16 | 17 | public final static Pattern HASH_SYMBOL_PATTERN = Pattern.compile(HASH_SYMBOL_PATTERN_STR); 18 | 19 | public static void matchDollarSymbol(String sqltext) { 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/common/SuccessStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.common; 2 | 3 | /** 4 | * @author netyjq@gmail.com 5 | * @date 2019-05-07 6 | */ 7 | public enum SuccessStatusEnum { 8 | 9 | /** 10 | * 成功 11 | */ 12 | SUCCEED(0), 13 | 14 | /** 15 | * 失败 16 | */ 17 | FAILED(-1); 18 | 19 | private int code; 20 | 21 | SuccessStatusEnum(int code) { 22 | this.code = code; 23 | } 24 | 25 | public int getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(int code) { 30 | this.code = code; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/config/MyFreemarkerConfig.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.config; 2 | 3 | import freemarker.cache.StringTemplateLoader; 4 | import freemarker.template.Configuration; 5 | import freemarker.template.Template; 6 | import freemarker.template.TemplateException; 7 | import freemarker.template.Version; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.io.IOException; 12 | import java.io.StringWriter; 13 | import java.io.Writer; 14 | import java.util.Map; 15 | 16 | /** 17 | * @author netyjq@gmail.com 18 | * @date 2019/4/24 19 | */ 20 | public class MyFreemarkerConfig extends Configuration { 21 | 22 | private StringTemplateLoader stringTemplateLoader; 23 | 24 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 25 | 26 | public MyFreemarkerConfig(Version incompatibleImprovements) { 27 | super(incompatibleImprovements); 28 | } 29 | 30 | 31 | /** 32 | * 渲染解析sql 33 | * @param templateId 模板id --> sqlId 34 | * @param templateText 模板内容 --> sqlText 35 | * @param model 模型 --> param 36 | * @return return the sql that can be executed by mybatis 37 | */ 38 | public String render(String templateId, String templateText, Map model) throws IOException, TemplateException { 39 | Writer out = new StringWriter(); 40 | stringTemplateLoader.putTemplate(templateId, templateText); 41 | this.setTemplateLoader(stringTemplateLoader); 42 | Template template = this.getTemplate(templateId); 43 | template.process(model, out); 44 | String sql = out.toString(); 45 | return sql; 46 | } 47 | 48 | public StringTemplateLoader getStringTemplateLoader() { 49 | return stringTemplateLoader; 50 | } 51 | 52 | public void setStringTemplateLoader(StringTemplateLoader stringTemplateLoader) { 53 | this.stringTemplateLoader = stringTemplateLoader; 54 | this.setTemplateLoader(stringTemplateLoader); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IAlarmConfigMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.AlarmConfig; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-07 12 | */ 13 | @Mapper 14 | public interface IAlarmConfigMapper { 15 | 16 | /** 17 | * 查询告警配置 18 | * @param filters 入参 19 | * @return 20 | */ 21 | List selectList(Map filters); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IAlarmHistoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.AlarmHistory; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-05-07 9 | */ 10 | @Mapper 11 | public interface IAlarmHistoryMapper { 12 | 13 | /** 14 | * 新增 15 | * @param alarmHistory 告警记录 16 | */ 17 | void insertOne(AlarmHistory alarmHistory); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IApiInvokeRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.ApiInvokeRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-06 12 | */ 13 | @Mapper 14 | public interface IApiInvokeRecordMapper { 15 | 16 | /** 17 | * 新增流水记录 18 | * @param apiInvokeRecord ApiInvokeRecord 19 | */ 20 | void insertOne(ApiInvokeRecord apiInvokeRecord); 21 | 22 | /** 23 | * 查询流水 24 | * @param filters 过滤条件 25 | * @return List 26 | */ 27 | List selectList(Map filters); 28 | 29 | /** 30 | * 单个更新 31 | * @param apiInvokeRecord 32 | */ 33 | void updateOne(ApiInvokeRecord apiInvokeRecord); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IDynamicSqlMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019/4/23 12 | */ 13 | @Mapper 14 | public interface IDynamicSqlMapper { 15 | 16 | /** 17 | * 查询列表 18 | * @param filters 过滤条件 19 | * @return List 20 | */ 21 | List> selectList(Map filters); 22 | 23 | /** 24 | * 查询数量 25 | * @param filters 过滤条件 26 | * @return 数量 27 | */ 28 | long selectCount(Map filters); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/ISqlTemplateMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.SqlTemplate; 4 | import org.apache.ibatis.annotations.*; 5 | 6 | /** 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-28 9 | */ 10 | @Mapper 11 | public interface ISqlTemplateMapper { 12 | 13 | /** 14 | * 查询 sql模板 15 | * @param sqlTemplateId sql模板id 16 | * @param appId 应用id 17 | * @return SqlTemplate 18 | */ 19 | SqlTemplate selectOne(@Param("sqlTemplateId") String sqlTemplateId, @Param("appId") Integer appId); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IUserGroupMappingMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.UserGroupMapping; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-05-05 12 | */ 13 | @Mapper 14 | public interface IUserGroupMappingMapper { 15 | 16 | /** 17 | * 根据组id查询 18 | * @param userGroupId 组id 19 | * @return List 20 | */ 21 | List selectListByGroupId(@Param("userGroupId") Integer userGroupId); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/mapper/IUserInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.mapper; 2 | 3 | import com.yjq.data.service.model.UserInfo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author netyjq@gmail.com 11 | * @date 2019-04-28 12 | */ 13 | @Mapper 14 | public interface IUserInfoMapper { 15 | 16 | /** 17 | * 根据用户id查询用户电子邮件地址 18 | * @param userIdListStr 用户列表 19 | * @return List 20 | */ 21 | List selectEmail(@Param("userIdListStr") String userIdListStr); 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/AlarmConfig.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 告警配置 7 | * @author netyjq@gmail.com 8 | * @date 2019-04-26 9 | */ 10 | @Data 11 | public class AlarmConfig { 12 | 13 | private Integer id; 14 | 15 | /** 16 | * 应用id 17 | */ 18 | private Integer appId; 19 | 20 | /** 21 | * 应用名称 22 | */ 23 | private String appName; 24 | 25 | /** 26 | * 创建人id 27 | */ 28 | private Integer createId; 29 | 30 | /** 31 | * 创建人姓名 32 | */ 33 | private String createName; 34 | 35 | /** 36 | * 更新人id 37 | */ 38 | private Integer updateId; 39 | 40 | /** 41 | * 更新人姓名 42 | */ 43 | private String updateName; 44 | 45 | /** 46 | * 阈值 47 | */ 48 | private Integer threshold; 49 | 50 | /** 51 | * 告警规则 SLOW_COUNT(1), ERROR_COUNT(2); 52 | */ 53 | private Integer rule; 54 | 55 | /** 56 | * 用户组id 57 | */ 58 | private Integer userGroupId; 59 | 60 | /** 61 | * 用户组名称 62 | */ 63 | private String userGroupName; 64 | 65 | 66 | public AlarmConfig(Integer appId, String appName, Integer createId, String createName, Integer updateId, 67 | String updateName, Integer threshold, Integer rule, Integer userGroupId) { 68 | this.appId = appId; 69 | this.appName = appName; 70 | this.createId = createId; 71 | this.createName = createName; 72 | this.updateId = updateId; 73 | this.updateName = updateName; 74 | this.threshold = threshold; 75 | this.rule = rule; 76 | this.userGroupId = userGroupId; 77 | } 78 | 79 | public AlarmConfig() { 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/AlarmHistory.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import com.yjq.data.service.common.Constant; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 告警历史 10 | * 生成方式:通过轮询 api_invoke_record表 以及结合 alarm_config表 来生成告警记录添加到 alarm_history表 11 | * 分表规则:根据appId进行取模运算得到操作表 12 | * @author netyjq@gmail.com 13 | * @date 2019-04-26 14 | */ 15 | @Data 16 | public class AlarmHistory { 17 | 18 | private Integer id; 19 | 20 | /** 21 | * 应用id 22 | */ 23 | private Integer appId; 24 | 25 | /** 26 | * 应用名称 27 | */ 28 | private String appName; 29 | 30 | /** 31 | * 阈值 32 | */ 33 | private Integer threshold; 34 | 35 | /** 36 | * 告警规则 1.慢查询 2.错误 37 | */ 38 | private Integer alarmRule; 39 | 40 | /** 41 | * 实际数值 42 | */ 43 | private Integer actualNum; 44 | 45 | /** 46 | * 告警内容 47 | */ 48 | private String alarmMessage; 49 | 50 | /** 51 | * 创建时间 52 | */ 53 | private Date createTime; 54 | 55 | /** 56 | * 用户id 57 | */ 58 | private Integer receiverId; 59 | 60 | /** 61 | * 用户名称 62 | */ 63 | private String receiverName; 64 | 65 | /** 66 | * 表号 67 | */ 68 | private Integer tableSuffix; 69 | 70 | public AlarmHistory(Integer appId, String appName, Integer threshold, Integer alarmRule, Integer actualNum, 71 | String alarmMessage, Integer receiverId, String receiverName) { 72 | this.appId = appId; 73 | this.tableSuffix = appId % Constant.ALARM_HISTORY_TABLE_SPLIT_SIZE; 74 | this.appName = appName; 75 | this.threshold = threshold; 76 | this.alarmRule = alarmRule; 77 | this.actualNum = actualNum; 78 | this.alarmMessage = alarmMessage; 79 | this.createTime = new Date(); 80 | this.receiverId = receiverId; 81 | this.receiverName = receiverName; 82 | } 83 | 84 | public void setAppId(Integer appId) { 85 | this.appId = appId; 86 | this.setTableSuffix(appId % Constant.ALARM_HISTORY_TABLE_SPLIT_SIZE); 87 | } 88 | } 89 | 90 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/ApiInvokeRecord.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import com.yjq.data.service.common.Constant; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 接口调用记录 10 | * 告警触发的规则就是定时轮训调用记录,判断是否符合告警的配置 11 | * 轮询完成后会设置标志位字段processed为-1,并记录处理时间 12 | * 13 | * @author netyjq@gmail.com 14 | * @date 2019-05-06 15 | */ 16 | @Data 17 | public class ApiInvokeRecord { 18 | 19 | private Integer id; 20 | 21 | /** 22 | * 应用id 23 | */ 24 | private Integer appId; 25 | 26 | /** 27 | * 应用名称 28 | */ 29 | private String appName; 30 | 31 | /** 32 | * sql模板id 33 | */ 34 | private String sqlId; 35 | 36 | /** 37 | * sql模板 38 | */ 39 | private String sqltext; 40 | 41 | /** 42 | * 请求入参 43 | */ 44 | private String requestParam; 45 | 46 | /** 47 | * 接收到请求的时的系统时间 48 | */ 49 | private Date requestTime; 50 | 51 | /** 52 | * 请求响应时系统时间 53 | */ 54 | private Date responseTime; 55 | 56 | /** 57 | * 消耗的时间 58 | */ 59 | private Long cost; 60 | 61 | /** 62 | * 是否调用成功 0 成功 -1 失败 63 | */ 64 | private Integer success; 65 | 66 | /** 67 | * 是否已经轮询处理过了 0未处理 -1已经处理 68 | */ 69 | private Integer processed; 70 | 71 | /** 72 | * 轮询标记的时间 73 | */ 74 | private Date processedTime; 75 | 76 | /** 77 | * 错误详情 执行出错时记录 78 | */ 79 | private String errorDetail; 80 | 81 | /** 82 | * 表下标 只做查询用 83 | */ 84 | private Integer tableSuffix; 85 | 86 | public void setAppId(Integer appId) { 87 | this.appId = appId; 88 | this.tableSuffix = appId % Constant.ALARM_HISTORY_TABLE_SPLIT_SIZE; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/SqlTemplate.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * sql模板 9 | * @author netyjq@gmail.com 10 | * @date 2019/4/24 11 | */ 12 | @Data 13 | public class SqlTemplate { 14 | 15 | private String id; 16 | 17 | /** 18 | * sql模板 19 | */ 20 | private String sqltext; 21 | 22 | /** 23 | * 描述 24 | */ 25 | private String description; 26 | 27 | /** 28 | * 应用id 29 | */ 30 | private Integer appId; 31 | 32 | /** 33 | * 应用名称 34 | */ 35 | private String appName; 36 | 37 | /** 38 | * 状态0 正常 -1 禁用 39 | */ 40 | private Integer enableStatus; 41 | 42 | /** 43 | * 是否分页 0分页 -1不分页 44 | */ 45 | private Integer paging; 46 | 47 | /** 48 | * 出参映射 like: {"app_id":"appId","enable_status":enableStatus} 49 | */ 50 | private String parameterMapping; 51 | 52 | /** 53 | * 创建时间 54 | */ 55 | private Date createTime; 56 | 57 | /** 58 | * 创建人 equals User#getAccount 59 | */ 60 | private String createName; 61 | 62 | /** 63 | * 更新时间 64 | */ 65 | private Date updateTime; 66 | 67 | /** 68 | * 更新人 69 | */ 70 | private String updateName; 71 | 72 | public SqlTemplate(String sqltext, String description, Integer appId, String appName, Integer enableStatus, 73 | Integer paging, String parameterMapping, Date createTime, String createName) { 74 | this.sqltext = sqltext; 75 | this.description = description; 76 | this.appId = appId; 77 | this.appName = appName; 78 | this.enableStatus = enableStatus; 79 | this.paging = paging; 80 | this.parameterMapping = parameterMapping; 81 | this.createTime = createTime; 82 | this.createName = createName; 83 | } 84 | 85 | public SqlTemplate() { 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/UserGroupMapping.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 用户、组之间的映射关系 7 | * @author netyjq@gmail.com 8 | * @date 2019-05-05 9 | */ 10 | @Data 11 | public class UserGroupMapping { 12 | 13 | private Integer id; 14 | 15 | /** 16 | * 用户id 17 | */ 18 | private Integer userId; 19 | 20 | /** 21 | * 用户组id 22 | */ 23 | private Integer userGroupId; 24 | 25 | public UserGroupMapping(Integer userId, Integer userGroupId) { 26 | this.userId = userId; 27 | this.userGroupId = userGroupId; 28 | } 29 | 30 | public UserGroupMapping() { 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /data-center-service/src/main/java/com/yjq/data/service/model/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.yjq.data.service.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 用户信息 9 | * @author netyjq@gmail.com 10 | * @date 2019-04-26 11 | */ 12 | @Data 13 | public class UserInfo { 14 | 15 | private Integer id; 16 | 17 | /** 18 | * 姓名 邮箱前缀 like yejq 19 | */ 20 | private String name; 21 | 22 | /** 23 | * 邮箱地址 24 | */ 25 | private String email; 26 | 27 | /** 28 | * 最后一次登录时间 29 | */ 30 | private Date lastLogin; 31 | 32 | /** 33 | * 用户组id 34 | */ 35 | private Integer userGroupId; 36 | 37 | /** 38 | * 角色权限 0 普通用户 1 管理员用户 39 | */ 40 | private Integer roleType; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/META-INFO/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.include.mapper=/mapper-[\\w-\\.]+jar 2 | restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar -------------------------------------------------------------------------------- /data-center-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=logs 3 | 4 | ## datasource config 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 6 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 7 | spring.datasource.username=root 8 | spring.datasource.password=123456 9 | spring.datasource.sql-script-encoding=utf-8 10 | 11 | ## dubbo config 12 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 13 | spring.dubbo.version=1.0.0.dev 14 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=/opt/data-center-service/logs 3 | 4 | ## datasource config 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 6 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 7 | spring.datasource.username=root 8 | spring.datasource.password=123456 9 | spring.datasource.sql-script-encoding=utf-8 10 | 11 | ## dubbo config 12 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 13 | spring.dubbo.version=1.0.0 -------------------------------------------------------------------------------- /data-center-service/src/main/resources/application-sit.properties: -------------------------------------------------------------------------------- 1 | # set log path 2 | logging.path=/opt/data-center-service/logs 3 | 4 | ## datasource config 5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 6 | spring.datasource.url=jdbc:mysql://127.0.01:3306/data_center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 7 | spring.datasource.username=root 8 | spring.datasource.password=123456 9 | spring.datasource.sql-script-encoding=utf-8 10 | 11 | ## dubbo config 12 | spring.dubbo.registry=zookeeper://127.0.0.1:2181 13 | spring.dubbo.version=1.0.0.sit -------------------------------------------------------------------------------- /data-center-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=data-center-dev 2 | 3 | # active profile 4 | spring.profiles.active=@activatedProperties@ 5 | 6 | # tomcat port 7 | server.port=8080 8 | 9 | ## encoding 10 | spring.http.encoding.charset=UTF-8 11 | spring.http.encoding.force=true 12 | spring.http.encoding.enabled=true 13 | server.tomcat.uri-encoding=UTF-8 14 | 15 | ## mybatis config 16 | mybatis.typeAliasesPackage=com.yjq.data.service.model 17 | mybatis.mapperLocations=classpath:mapper/*.xml 18 | 19 | #pagehelper 20 | pagehelper.helperDialect=postgresql 21 | pagehelper.reasonable=true 22 | pagehelper.supportMethodsArguments=true 23 | pagehelper.params=count=countSql 24 | 25 | 26 | ## log path 27 | logging.config=classpath:config/logging-config.xml 28 | 29 | ## alarm mail config 30 | alarm.mail.address=alarm@xx.com 31 | alarm.mail.password=123123 32 | alarm.mail.server=mail.qq.com 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/alarm-config-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/alarm-history-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/api-invoke-record-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | insert into api_invoke_record_${tableSuffix} (app_id, app_name, sql_id, sqltext, request_time, request_param, 26 | response_time, cost, success, processed, processed_time, error_detail) values (#{appId}, #{appName}, 27 | #{sqlId}, #{sqltext}, #{requestTime}, #{requestParam}, #{responseTime}, #{cost}, #{success}, #{processed}, 28 | #{processedTime}, #{errorDetail}) 29 | 30 | 31 | 34 | 35 | 36 | update api_invoke_record_${tableSuffix} set processed = #{processed}, processed_time = #{processedTime} where id = #{id} 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/dynamic-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/sqltemplate-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/user-group-mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/mapper/user-info-sqlmap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /data-center-service/src/main/resources/spring-dubbo.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /script/design.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/script/design.jpg -------------------------------------------------------------------------------- /script/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/script/index.png -------------------------------------------------------------------------------- /script/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/script/login.png -------------------------------------------------------------------------------- /script/table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netyjq/data-center/6f5b6b0be9c65aeea6c43a43fc377fa7f5ba858a/script/table.jpg --------------------------------------------------------------------------------