From 27acef1d0ea8f71636673a897d7d730de63bf31d Mon Sep 17 00:00:00 2001 From: "1351515658@qq.com" <1351515658@qq.com> Date: Mon, 10 Feb 2025 14:49:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(=E6=89=93=E5=8C=85=E5=8F=91=E5=B8=83)?= =?UTF-8?q?=EF=BC=9A=20=E5=BC=95=E5=85=A5actuator=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=EF=BC=8C=E6=89=93=E5=8C=85=E6=94=AF=E6=8C=81?= =?UTF-8?q?jar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 1ef94bb..de0e66d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,8 +10,8 @@ cn.com goview_admin 0.0.1-SNAPSHOT - war - oss + jar + goview goview后台系统 UTF-8 @@ -130,12 +130,16 @@ 1.34.0 + + + org.springframework.boot + spring-boot-starter-actuator + - - + goview @@ -151,6 +155,17 @@ org.springframework.boot spring-boot-maven-plugin + + true + cn.com.GogoApplication + + + + + repackage + + + -- Gitee From bcd6bd54cb931aaa7091a644207f1bc779b480c1 Mon Sep 17 00:00:00 2001 From: "1351515658@qq.com" <1351515658@qq.com> Date: Mon, 10 Feb 2025 15:31:49 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(=E5=AD=98=E5=82=A8)=EF=BC=9A=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=AD=98=E5=82=A8=E4=BD=BF=E7=94=A8sqlite?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=97=B6=E6=94=AF=E6=8C=81=E5=88=87=E6=8D=A2?= =?UTF-8?q?mysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README_mysql.md | 16 +++++++++ mysql/init.sql | 48 +++++++++++++++++++++++++ pom.xml | 6 ++++ src/main/resources/application-dev.yml | 28 +++++++++++++-- src/main/resources/application-test.yml | 38 ++++++++++++++++++++ src/main/resources/application.yml | 28 +++++++-------- 6 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 README_mysql.md create mode 100644 mysql/init.sql create mode 100644 src/main/resources/application-test.yml diff --git a/README_mysql.md b/README_mysql.md new file mode 100644 index 0000000..c7f8822 --- /dev/null +++ b/README_mysql.md @@ -0,0 +1,16 @@ +## mysql数据库配置 +1. 数据库文件为mysql》init.sql 导入Mysql +2. 配置数据源 application-dev.yml》把默认sqlite配置改为mysql +3. 配置mybatis-plus application.yml》db-type改为mysql + + + + + + +## 修改配置文件图片存放地址(3个值必须对,oss与fileurl 路径一样写法不一样别搞错了 有file:) + +1. v2>oss值 +2. v2>fileurl值 +3. v2>httpurl值 +4. httpurl为图片上传的访问地址 \ No newline at end of file diff --git a/mysql/init.sql b/mysql/init.sql new file mode 100644 index 0000000..9c91def --- /dev/null +++ b/mysql/init.sql @@ -0,0 +1,48 @@ + +CREATE TABLE t_goview_project ( + id varchar(50) NOT NULL, + project_name varchar(255), + state int, + create_time varchar(50), + create_user_id varchar(50), + is_delete int, + index_image varchar(255), + remarks varchar(255), + PRIMARY KEY (id) +) COMMENT='低代码-项目'; + +CREATE TABLE t_goview_project_data ( + id varchar(50) NOT NULL, + project_id varchar(50), + create_time varchar(50), + create_user_id varchar(50), + content text, + PRIMARY KEY (id) +) COMMENT='低代码-项目数据配置'; + +CREATE TABLE t_sys_file ( + id varchar(50) NOT NULL, + file_name varchar(255), + file_size int, + file_suffix varchar(255), + create_time varchar(255) DEFAULT '', + md5 varchar(50), + virtual_key varchar(255), + relative_path varchar(255), + absolute_path varchar(255), + PRIMARY KEY (id) +) COMMENT='低代码-文件记录'; + +CREATE TABLE t_sys_user ( + id varchar(50) NOT NULL, + username varchar(255), + password varchar(255), + nickname varchar(255), + dep_id int, + pos_id varchar(255), + PRIMARY KEY (id) +)COMMENT='低代码-账号'; + +INSERT INTO `t_sys_user` (`id`, `username`, `password`, `nickname`, `dep_id`, `pos_id`) VALUES ('1', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '管理员', 2, '410792368778907648'); +INSERT INTO `t_sys_user` (`id`, `username`, `password`, `nickname`, `dep_id`, `pos_id`) VALUES ('433236479427350528', 'fuce', 'e10adc3949ba59abbe56e057f20f883e', '付册', 2, '410792443127140352'); +INSERT INTO `t_sys_user` (`id`, `username`, `password`, `nickname`, `dep_id`, `pos_id`) VALUES ('665776667645579264', '999', 'e10adc3949ba59abbe56e057f20f883e', '9999', 1, '410792368778907648'); diff --git a/pom.xml b/pom.xml index de0e66d..6ec7eda 100644 --- a/pom.xml +++ b/pom.xml @@ -103,6 +103,12 @@ 3.21.0.1 + + + + + + org.projectlombok lombok-maven-plugin diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 93307a7..06fa897 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,12 +1,20 @@ -#dev环境 mysql7.0 +# dev环境 mysql +#spring: +# datasource: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://dev_ip:3306/goview?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false +# username: dev_mysql_username +# password: dev_mysql_password + +# 默认存储sqlite spring: datasource: driver-class-name: org.sqlite.JDBC url: jdbc:sqlite:D:\\eclipse-workspace\v2-goview-bate\sqllite\goview.db #linux服务器 #url: jdbc:sqlite://home/cqfy/project/OSSDATABASE/oss.db - username: - password: + username: + password: ### 连接池配置 druid: initial-size: 10 @@ -14,3 +22,17 @@ spring: min-idle: 30 max-wait: 40 validation-query: SELECT 1 + +v2: + #虚拟路径映射路径 2个文件路径一一对应 第一个为主存储,其他为配置相关 + xnljmap: + #win服务器 本地 注意!! 记住这个结尾有一个/ + oss: file:D:/upload/ + #linux服务器 + #oss: file:/home/webapps/oss/ + #虚拟路径映射路径 end + #本地存放地址 注意!! 记住这个结尾没有/ + fileurl: D:/upload + #http://127.0.0.1:8080/oss/{yy}/2022-12-22/c83a77ae134a540c30daa6a0666fa945.md + httpurl: http://127.0.0.1:8083/ + defaultFormat: .png \ No newline at end of file diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..e42293e --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,38 @@ +# test环境 mysql +#spring: +# datasource: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://test_ip:3306/goview?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false +# username: test_mysql_username +# password: test_mysql_password + +# 默认存储sqlite +spring: + datasource: + driver-class-name: org.sqlite.JDBC + url: jdbc:sqlite:D:\\eclipse-workspace\v2-goview-bate\sqllite\goview.db + #linux服务器 + #url: jdbc:sqlite://home/cqfy/project/OSSDATABASE/oss.db + username: + password: + ### 连接池配置 + druid: + initial-size: 10 + max-active: 20 + min-idle: 10 + max-wait: 40 + validation-query: SELECT 1 + +v2: + #虚拟路径映射路径 2个文件路径一一对应 第一个为主存储,其他为配置相关 + xnljmap: + #win服务器 本地 注意!! 记住这个结尾有一个/ + #oss: file:D:/upload/ + #linux服务器 + oss: file:/home/goview/oss/ + #虚拟路径映射路径 end + #本地存放地址 注意!! 记住这个结尾没有/ + fileurl: /home/goview/oss + #http://127.0.0.1:8080/oss/{yy}/2022-12-22/c83a77ae134a540c30daa6a0666fa945.md + httpurl: http://192.168.0.69:8083/ + defaultFormat: .png \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0f9da35..377de4e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,16 +1,4 @@ -v2: - #虚拟路径映射路径 2个文件路径一一对应 第一个为主存储,其他为配置相关 - xnljmap: - #win服务器 本地 注意!! 记住这个结尾有一个/ - oss: file:D:/upload/ - #linux服务器 - #oss: file:/home/webapps/oss/ - #虚拟路径映射路径 end - #本地存放地址 注意!! 记住这个结尾没有/ - fileurl: D:/upload - #http://127.0.0.1:8080/oss/{yy}/2022-12-22/c83a77ae134a540c30daa6a0666fa945.md - httpurl: http://127.0.0.1:8083/ - defaultFormat: .png + #tomcat config server : port : 8083 @@ -107,4 +95,16 @@ sa-token: # token风格 token-style: uuid # 是否输出操作日志 - is-log: false \ No newline at end of file + is-log: false + +management: + endpoints: + web: + exposure: + include: "*" # 暴露所有端点,生产环境建议只暴露需要的端点 + base-path: /actuator # 端点基础路径 + endpoint: + health: + show-details: always # 显示详细的健康信息 + shutdown: + enabled: true # 启用关闭应用的端点(可选) \ No newline at end of file -- Gitee From 8deb341377dbe2f877f6c79fbd5143f2213dfb5f Mon Sep 17 00:00:00 2001 From: "1351515658@qq.com" <1351515658@qq.com> Date: Mon, 10 Feb 2025 15:34:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3)=EF=BC=9A=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9Esql=E5=92=8Chttp=E5=90=8E=E7=AB=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/com/v2/common/domain/AjaxResult.java | 4 ++ .../v2/controller/GoViewDataController.java | 66 +++++++++++++++++++ .../vo/GoViewDataGetBySqlReqVO.java | 15 +++++ .../v2/controller/vo/GoViewDataRespVO.java | 25 +++++++ .../cn/com/v2/service/GoViewDataService.java | 21 ++++++ .../service/impl/GoViewDataServiceImpl.java | 57 ++++++++++++++++ 6 files changed, 188 insertions(+) create mode 100644 src/main/java/cn/com/v2/controller/GoViewDataController.java create mode 100644 src/main/java/cn/com/v2/controller/vo/GoViewDataGetBySqlReqVO.java create mode 100644 src/main/java/cn/com/v2/controller/vo/GoViewDataRespVO.java create mode 100644 src/main/java/cn/com/v2/service/GoViewDataService.java create mode 100644 src/main/java/cn/com/v2/service/impl/GoViewDataServiceImpl.java diff --git a/src/main/java/cn/com/v2/common/domain/AjaxResult.java b/src/main/java/cn/com/v2/common/domain/AjaxResult.java index f7e7fb3..0ed648a 100644 --- a/src/main/java/cn/com/v2/common/domain/AjaxResult.java +++ b/src/main/java/cn/com/v2/common/domain/AjaxResult.java @@ -86,6 +86,10 @@ public class AjaxResult extends HashMap json.put("data", value); return json; } + + public static AjaxResult successData(Object value){ + return successData(200,value); + } /** diff --git a/src/main/java/cn/com/v2/controller/GoViewDataController.java b/src/main/java/cn/com/v2/controller/GoViewDataController.java new file mode 100644 index 0000000..f66d471 --- /dev/null +++ b/src/main/java/cn/com/v2/controller/GoViewDataController.java @@ -0,0 +1,66 @@ +package cn.com.v2.controller; + +import cn.com.v2.common.domain.AjaxResult; +import cn.com.v2.controller.vo.GoViewDataGetBySqlReqVO; +import cn.com.v2.controller.vo.GoViewDataRespVO; +import cn.com.v2.service.GoViewDataService; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.RandomUtil; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.Map; + + +/** + * 管理后台 - GoView 数据 + */ +@RestController +@RequestMapping("/report/go-view/data") +public class GoViewDataController { + + @Resource + private GoViewDataService goViewDataService; + + /** + * 使用 SQL 查询数据 + * @param reqVO + * @return + */ + @RequestMapping("/report/go-view/dataget-by-sql") + public AjaxResult getDataBySQL(@RequestBody GoViewDataGetBySqlReqVO reqVO) { + return AjaxResult.successData(goViewDataService.getDataBySQL(reqVO.getSql())); + } + + /** + * 使用 HTTP 查询数据 demo + * @param params + * @param body + * @return + */ + @RequestMapping("/get-by-http") + public AjaxResult getDataByHttp( + @RequestParam(required = false) Map params, + @RequestBody(required = false) String body) { // params、body 按照需要去接收,这里仅仅是示例 + GoViewDataRespVO respVO = new GoViewDataRespVO(); + // 1. 数据维度 + respVO.setDimensions(Arrays.asList("日期", "PV", "UV")); // PV 是每天访问次数;UV 是每天访问人数 + // 2. 明细数据列表 + // 目前通过随机的方式生成。一般来说,这里你可以写逻辑来实现数据的返回 + respVO.setSource(new LinkedList<>()); + for (int i = 1; i <= 12; i++) { + String date = "2021-" + (i < 10 ? "0" + i : i); + Integer pv = RandomUtil.randomInt(1000, 10000); + Integer uv = RandomUtil.randomInt(100, 1000); + respVO.getSource().add(MapUtil.builder().put("日期", date) + .put("PV", pv).put("UV", uv).build()); + } + return AjaxResult.successData(respVO); + } + +} diff --git a/src/main/java/cn/com/v2/controller/vo/GoViewDataGetBySqlReqVO.java b/src/main/java/cn/com/v2/controller/vo/GoViewDataGetBySqlReqVO.java new file mode 100644 index 0000000..13a3c59 --- /dev/null +++ b/src/main/java/cn/com/v2/controller/vo/GoViewDataGetBySqlReqVO.java @@ -0,0 +1,15 @@ +package cn.com.v2.controller.vo; + +import lombok.Data; + +/** + * 管理后台 - GoView 使用 SQL 查询数据 Request VO + */ +@Data +public class GoViewDataGetBySqlReqVO { + /** + * SQL 语句 + */ + private String sql; + +} diff --git a/src/main/java/cn/com/v2/controller/vo/GoViewDataRespVO.java b/src/main/java/cn/com/v2/controller/vo/GoViewDataRespVO.java new file mode 100644 index 0000000..7ba012e --- /dev/null +++ b/src/main/java/cn/com/v2/controller/vo/GoViewDataRespVO.java @@ -0,0 +1,25 @@ +package cn.com.v2.controller.vo; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 管理后台 - GoView 数据 Response VO + */ +@Data +public class GoViewDataRespVO { + /** + * 数据维度 + * 例子:['product', 'data1', 'data2'] + */ + private List dimensions; + + /** + * 数据明细列表 + * + */ + private List> source; + +} diff --git a/src/main/java/cn/com/v2/service/GoViewDataService.java b/src/main/java/cn/com/v2/service/GoViewDataService.java new file mode 100644 index 0000000..308737b --- /dev/null +++ b/src/main/java/cn/com/v2/service/GoViewDataService.java @@ -0,0 +1,21 @@ +package cn.com.v2.service; + + +import cn.com.v2.controller.vo.GoViewDataRespVO; + +/** + * GoView 数据 Service 接口 + * + * @author 芋道源码 + */ +public interface GoViewDataService { + + /** + * 使用 SQL 查询数据 + * + * @param sql SQL 语句 + * @return 数据 + */ + GoViewDataRespVO getDataBySQL(String sql); + +} diff --git a/src/main/java/cn/com/v2/service/impl/GoViewDataServiceImpl.java b/src/main/java/cn/com/v2/service/impl/GoViewDataServiceImpl.java new file mode 100644 index 0000000..0f06328 --- /dev/null +++ b/src/main/java/cn/com/v2/service/impl/GoViewDataServiceImpl.java @@ -0,0 +1,57 @@ +package cn.com.v2.service.impl; + +import cn.com.v2.controller.vo.GoViewDataRespVO; +import cn.com.v2.service.GoViewDataService; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.rowset.SqlRowSet; +import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +/** + * GoView 数据 Service 实现类 + * + * 补充说明: + * 1. 目前默认使用 jdbcTemplate 查询项目配置的数据源。如果你想查询其它数据源,可以新建对应数据源的 jdbcTemplate 来实现。 + * 2. 默认数据源是 MySQL 关系数据源,可能数据量比较大的情况下,会比较慢,可以考虑后续使用 Click House 等等。 + * + * @author 芋道源码 + */ +@Service +@Validated +public class GoViewDataServiceImpl implements GoViewDataService { + + @Resource + private JdbcTemplate jdbcTemplate; + + @Override + public GoViewDataRespVO getDataBySQL(String sql) { + // 1. 执行查询 + SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(sql); + + // 2. 构建返回结果 + GoViewDataRespVO respVO = new GoViewDataRespVO(); + // 2.1 解析元数据 + SqlRowSetMetaData metaData = sqlRowSet.getMetaData(); + String[] columnNames = metaData.getColumnNames(); + respVO.setDimensions(Arrays.asList(columnNames)); + // 2.2 解析数据明细 + respVO.setSource(new LinkedList<>()); // 由于数据量不确认,使用 LinkedList 虽然内存占用大一点,但是不存在扩容复制的问题 + while (sqlRowSet.next()) { + Map data = new HashMap<>(columnNames.length); + for (String columnName : columnNames) { + data.put(columnName, sqlRowSet.getObject(columnName)); + } + respVO.getSource().add(data); + } + return respVO; + } + +} -- Gitee