# project1 **Repository Path**: helixin/project1 ## Basic Information - **Project Name**: project1 - **Description**: 测试 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-07-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JV-Rover-backend This is a java project,JV-Rover-backend for could server,use java and spring boot,redis,mariadb you have to use gradle to package it to jar.the gradle now we use ```` # Usage the jdk verion ``java SE Developement kit 8u172`` or you can just prepared a JDK8+ it can work. the gradle verion ``gradle 3.0-rc-2`` the tomcat version ``tomcat8`` This project you need to use docker,you can find a ```Dockerfile``` in jv_rover folder. such like below: ``` FROM frolvlad/alpine-oraclejdk8:slim VOLUME /tmp # jv_rover.jar is a app need outside , we can change it if we need. ADD jv_rover.jar app.jar RUN sh -c 'touch /app.jar' ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] EXPOSE 8762 ``` you can use ``docker build -t `` to build a docker image and push it to dockerhub or yourself repository also you can use ``` docker run -d --name jv_rover -p 8080:8762 --restart always [docker image path] ``` checking logs: ``` docker logs --tail 1000 -f jv_rover ``` when you running it you can visit ``swagger2 via http://ip:[8080]/swagger-ui.html`` checking all restful apis and do some endpoint testing. # mysql db this project you can use mysql or mariadb,that's all support the same sql file ``webide.sql`` ,the file you can find it in the root folder.the database design like the images images/webide-further.jpg ![Image text](https://github.com/pi-top/jv-rover-backend/blob/feature/further/images/webide-further.jpg) the sql always change but you can reference it like below: ``` /* Navicat MySQL Data Transfer Source Server : 220 Source Server Version : 50505 Source Host : 192.168.1.220:3306 Source Database : jv_rover_further Target Server Type : MYSQL Target Server Version : 50505 File Encoding : 65001 Date: 2019-05-28 21:47:49 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for device_group -- ---------------------------- DROP TABLE IF EXISTS `device_group`; CREATE TABLE `device_group` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `groupCode` varchar(64) NOT NULL COMMENT '组编码', `deviceCode` varchar(64) DEFAULT NULL COMMENT '设备编码', PRIMARY KEY (`id`,`groupCode`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='设备分组关系'; -- ---------------------------- -- Table structure for device_online -- ---------------------------- DROP TABLE IF EXISTS `device_online`; CREATE TABLE `device_online` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `groupCode` varchar(64) NOT NULL COMMENT '学校编码', `deviceCode` varchar(64) NOT NULL COMMENT '分组编码', `groupName` varchar(32) NOT NULL COMMENT '分组名称', `deviceCodeName` varchar(32) NOT NULL COMMENT '设备代码', `natTraversePortCode` varchar(64) NOT NULL COMMENT '端口编码', `natTraversePort` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '端口号', `token` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'token', `accountCode` varchar(64) CHARACTER SET utf8mb4 DEFAULT '' COMMENT '账户编码来自further', `username` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '用户名', `email` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '用户邮箱', `os` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'os版信息', `ip` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'ip', `sshIP` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT 'sshIP', `state` varchar(16) DEFAULT '' COMMENT '状态:[等待上线 Waiting,上线Online,下线 Offline,使用中 Using]', `type` varchar(16) DEFAULT NULL COMMENT '类型 SSH,WEB', `domain` varchar(128) DEFAULT '' COMMENT '域名', `heartTime` datetime DEFAULT NULL COMMENT '最后一次心跳时间', PRIMARY KEY (`id`,`groupCode`,`deviceCode`,`deviceCodeName`,`groupName`,`natTraversePortCode`) ) ENGINE=InnoDB AUTO_INCREMENT=767 DEFAULT CHARSET=utf8 COMMENT='在线设备'; -- ---------------------------- -- Table structure for device_pool -- ---------------------------- DROP TABLE IF EXISTS `device_pool`; CREATE TABLE `device_pool` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `code` varchar(64) NOT NULL COMMENT '设备编码', `codeName` varchar(32) NOT NULL COMMENT '设备编号', `barcode` varchar(64) NOT NULL COMMENT '条码纸质上显示 来自pps系统', `serialNumber` varchar(32) DEFAULT '' COMMENT '序列号,设备内部的唯一识别码', `createTime` datetime DEFAULT NULL COMMENT '创建时间', `updateTime` datetime DEFAULT NULL COMMENT '更新时间', `state` varchar(16) DEFAULT '' COMMENT '状态[正常 Normal,维修 Repair]', `summary` varchar(128) DEFAULT NULL COMMENT '备注最多128个英文字符或64个汉字', PRIMARY KEY (`id`,`code`,`codeName`,`barcode`) ) ENGINE=InnoDB AUTO_INCREMENT=140 DEFAULT CHARSET=utf8mb4 COMMENT='设备池'; -- ---------------------------- -- Table structure for nat_traverse_port -- ---------------------------- DROP TABLE IF EXISTS `nat_traverse_port`; CREATE TABLE `nat_traverse_port` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `code` varchar(64) NOT NULL COMMENT '编码', `port` varchar(32) DEFAULT NULL COMMENT '端口', `type` varchar(16) DEFAULT NULL COMMENT '类型 SSH,WEB', `state` varchar(16) DEFAULT NULL COMMENT '状态[空闲Free,使用中 Using]', PRIMARY KEY (`id`,`code`) ) ENGINE=InnoDB AUTO_INCREMENT=2210 DEFAULT CHARSET=utf8 COMMENT='内网穿透可用端口'; -- ---------------------------- -- Table structure for setting -- ---------------------------- DROP TABLE IF EXISTS `setting`; CREATE TABLE `setting` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', `k` varchar(64) NOT NULL COMMENT '键', `v` varchar(128) DEFAULT NULL COMMENT '值', `summary` varchar(256) DEFAULT NULL COMMENT '备注 128个汉字', `ver` int(11) DEFAULT 1 COMMENT '版本', PRIMARY KEY (`id`,`k`) ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COMMENT='设置'; -- ---------------------------- -- Table structure for worker_node -- ---------------------------- DROP TABLE IF EXISTS `worker_node`; CREATE TABLE `worker_node` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'auto increment id', `HOST_NAME` varchar(64) NOT NULL COMMENT 'host name', `PORT` varchar(64) NOT NULL COMMENT 'port', `TYPE` int(11) NOT NULL COMMENT 'node type: ACTUAL or CONTAINER', `LAUNCH_DATE` date NOT NULL COMMENT 'launch date', `MODIFIED` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'modified time', `CREATED` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'created time', PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=296 DEFAULT CHARSET=utf8 COMMENT='DB WorkerID Assigner for UID Generator'; ``` ##### prepare mysql database server you can use docker image quick running a mysql or mariadb you can try: ``` docker search mariadb docker pull mariadb docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Pitop@20180814pi-top.Com --name mariadb --restart always -d mariadb ``` checking logs: ``` docker logs --tail 1000 -f mariadb ``` You just need copy it and connect mysql and runing the sql script you will get a database. you can use below commands to build a database for this project ``` create database jv_rover; use jv_rover; source /home/webide.sql; ``` # redis this project depend on ``redis`` so you have to prepare a redis server for it. you can use docker quick running a docker instance like: ``` docker search redis docker pull redis docker run -p 6379:6379 --name redis --restart always -d redis redis-server --appendonly yes ``` when you prepared ``redis,mysql`` you have to change the file ``application.yml`` some options, you can find the file via this path ``jv_rover/src/main/resources/application.yml``. open it you need change the options: #### mysql: ``` url: jdbc:mysql://192.168.1.220:3306/jv_rover_further?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=round&allowMultiQueries=true&serverTimezone=GMT%2B8 username: root password: mysqladmin ``` changing the ``192.168.1.220:3306`` to your real mysql server ip.(the ip cloud use intranet ip or public ip) you must set a username and password ,remember the password should be very strong. #### redis ``` host: 192.168.1.220 port: 6379 password: Redis-Pitop@pi-top.Com:2019:Sandbox ``` changing the ``192.168.1.220`` to your real redis server ip.(the ip cloud use intranet ip or public ip) the default port is 6379 but,suggesting to change it other and set very strong password for redis. # nginx The file ``webide.conf`` is jv_rover frontend with this project published you can use it,that allow you visit webide frontend via browser,the webide.conf content like below: ``` upstream webide-api { ip_hash; server 172.31.200.241:8762; } server { listen 80; server_name webide.pi-top.cn ide.pi-top.com; gzip on; gzip_min_length 5k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 3; gzip_types image/jpeg image/gif image/png image/ico text/plain application/x-javascript text/css text/javascript application/apk application/json; gzip_vary on; gzip_disable "MSIE [1-6]."; charset utf-8; location =/ { root /home/www/webide-ui/; index index.html index.htm; } location ~* ^/(ws) { proxy_pass http://webide-api; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_connect_timeout 4s; proxy_read_timeout 12h; proxy_send_timeout 12s; } location ~* ^/(res|frontendI18n|errorcodeLocal) { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(shtml)$ { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(do)$ { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ \.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|woff|woff2|eot|otf|svg|ttf|psd|jade|less|scss|json|xls|xlsx)$ { root /home/www/webide-ui/; } } ``` Please notice these below,these configure show you,frontend and backend publish to different server and node that's frontend and backend separation,you can publish many frontends and many backends just use this configure file. ``` location =/ { root /home/www/webide-ui/; index index.html index.htm; } location ~* ^/(ws) { proxy_pass http://webide-api; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_connect_timeout 4s; proxy_read_timeout 12h; proxy_send_timeout 12s; } location ~* ^/(res|frontendI18n|errorcodeLocal) { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(shtml)$ { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(do)$ { proxy_pass http://webide-api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ \.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|woff|woff2|eot|otf|svg|ttf|psd|jade|less|scss|json|xls|xlsx)$ { root /home/www/webide-ui/; } ``` The ``[.shtml] [.do]`` that's suffix for http/https api you can change them the real project they need delete all of them we suggest using ``http://domain/xxx/xxx`` ,suffix is ok but not that good then no suffix. # The architecture of jv-rover #### The system modules: ![Image text](https://github.com/pi-top/jv-rover-backend/blob/feature/further/images/system_design.jpg) #### The networking: ![Image text](https://github.com/pi-top/jv-rover-backend/blob/feature/further/images/base_networking.jpg) #### The frameworks architecture: ![Image text](https://github.com/pi-top/jv-rover-backend/blob/feature/further/images/frameworks.jpg) #### The models: ![Image text](https://github.com/pi-top/jv-rover-backend/blob/feature/further/images/models.jpg) # Doc the file ``webide-uml.vpp`` is UML diagram for jv-rover. you can use the software ``Visual Paradigm`` the link is: https://www.visual-paradigm.com the file ``webide.pdm`` database design you can use the software ``powerdesinger`` open it.