Monday, November 30, 2020

LuckysheetServer – Google Sheets-like realtime collaborative spreadsheet

Luckysheet Server

English| 简体中文

Introduction

💻Luckysheet official Java version backend.

Demo

Deploy

Requirements

jdk >= 1.8

postgre >= 10 (Support jsonb version)

redis >= 3

nginx >= 1.12

maven >= 3.6

IntelliJ IDEA >= 12 (not necessary)

Database initialization

Create database

CREATE DATABASE luckysheetdb

Create sequence

DROP SEQUENCE IF EXISTS "public"."luckysheet_id_seq";
CREATE SEQUENCE "public"."luckysheet_id_seq"
INCREMENT 1
MINVALUE  1
MAXVALUE 9999999999999
START 1
CACHE 10;

Create table

DROP TABLE IF EXISTS "public"."luckysheet";
CREATE TABLE "luckysheet" (
  "id" int8 NOT NULL,
  "block_id" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "index" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "list_id" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "status" int2 NOT NULL,
  "json_data" jsonb,
  "order" int2,
  "is_delete" int2
);
CREATE INDEX "block_id" ON "public"."luckysheet" USING btree (
  "block_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "list_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "index" ON "public"."luckysheet" USING btree (
  "index" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "list_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "is_delete" ON "public"."luckysheet" USING btree (
  "is_delete" "pg_catalog"."int2_ops" ASC NULLS LAST
);
CREATE INDEX "list_id" ON "public"."luckysheet" USING btree (
  "list_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "order" ON "public"."luckysheet" USING btree (
  "list_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "order" "pg_catalog"."int2_ops" ASC NULLS LAST
);
CREATE INDEX "status" ON "public"."luckysheet" USING btree (
  "list_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "status" "pg_catalog"."int2_ops" ASC NULLS LAST
);
ALTER TABLE "public"."luckysheet" ADD CONSTRAINT "luckysheet_pkey" PRIMARY KEY ("id");

Insert initialization statement

INSERT INTO "public"."luckysheet" VALUES (nextval('luckysheet_id_seq'), 'fblock', '1', '1079500#-8803#7c45f52b7d01486d88bc53cb17dcd2c3', 1, '{"row":84,"name":"Sheet1","chart":[],"color":"","index":"1","order":0,"column":60,"config":{},"status":0,"celldata":[],"ch_width":4748,"rowsplit":[],"rh_height":1790,"scrollTop":0,"scrollLeft":0,"visibledatarow":[],"visibledatacolumn":[],"jfgird_select_save":[],"jfgrid_selection_range":{}}', 0, 0);
INSERT INTO "public"."luckysheet" VALUES (nextval('luckysheet_id_seq'), 'fblock', '2', '1079500#-8803#7c45f52b7d01486d88bc53cb17dcd2c3', 0, '{"row":84,"name":"Sheet2","chart":[],"color":"","index":"2","order":1,"column":60,"config":{},"status":0,"celldata":[],"ch_width":4748,"rowsplit":[],"rh_height":1790,"scrollTop":0,"scrollLeft":0,"visibledatarow":[],"visibledatacolumn":[],"jfgird_select_save":[],"jfgrid_selection_range":{}}', 1, 0);
INSERT INTO "public"."luckysheet" VALUES (nextval('luckysheet_id_seq'), 'fblock', '3', '1079500#-8803#7c45f52b7d01486d88bc53cb17dcd2c3', 0, '{"row":84,"name":"Sheet3","chart":[],"color":"","index":"3","order":2,"column":60,"config":{},"status":0,"celldata":[],"ch_width":4748,"rowsplit":[],"rh_height":1790,"scrollTop":0,"scrollLeft":0,"visibledatarow":[],"visibledatacolumn":[],"jfgird_select_save":[],"jfgrid_selection_range":{}}', 2, 0);

nginx configuration

http block configuration

#websocket configuration
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream ws_dataluckysheet {
      server [Project ip]: [port];
}    

server block configuration

#websocket configuration
location /luckysheet/websocket/luckysheet {
    proxy_pass http://ws_dataluckysheet/luckysheet/websocket/luckysheet;

    proxy_set_header Host $host;
    proxy_set_header X-real-ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    #websocket
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}       

#Dynamic resource configuration
location /luckysheet/ {
    proxy_pass http://ws_dataluckysheet;
}

#Static resource configuration
location /luckysheet/demo/ {
    root /[Resource path]/;
    index  index.html index.htm;
}

Project usage

application.yml Project configuration

server:
  port: [Project port]
  servlet:
    context-path: /[Project path]
redis.channel: [redis channel name]
row_size: [The number of rows in the table, default 500]
col_size: [Number of columns in the table, default 500]
pgSetUp: [Whether to enable pgsql as storage data (0 for yes, 1 for no), currently can only be set to 0]

application-dev.yml Database configuration

spring:
  redis:
    host: [ip address]
    port: [port]
    password: [password]
    
db:
  postgre:
    druid:
      url: jdbc:postgresql://[ip address]: [port]/luckysheetdb?useSSL=false
      driverClassName: org.postgresql.Driver
      username: [username]
      password: [password]    

logback-spring.xml Log configuration

 <property name="log.path" value="[Log output directory]"/>

project instruction

Luckysheet module main class description

com.xc.luckysheet.WebApplication Project startup

com.xc.luckysheet.controller

JfGridFileController Table data loading class
TestController  postgre redis Test class 

com.xc.luckysheet.entity

SheetOperationEnum Table operation type
JfGridConfigModel Table block object
LuckySheetGridModel Tabular database objects
PgGridDataModel Table database object

com.xc.luckysheet.postgre

PostgresGridFileDao postgre database operation
PostgresGridFileGetService Record operation
PostgresJfGridUpdateService Update processing

com.xc.luckysheet.redisserver

RedisLock redis lock
RedisMessageListener Pipeline monitoring class
RedisMessagePublish Pipeline release class

com.xc.luckysheet.service

ConfigerService Configuration class
ScheduleService Initialize the timing database

com.xc.luckysheet.utils

GzipHandle Information compression
Pako_GzipUtils WebSocket information compression

com.xc.luckysheet.websocket

IpAndPortUtil Get the IP and port of the current service
MyWebSocketHandler Socket processor (including methods for sending information, receiving information, and information errors.)
MyWebSocketInterceptor Socket connection (handshake) and disconnection
WebSocketConfig Register WebSocket, Set the address of WebSocket
WSUserModel WebSocket object

Main class description of common module

com.xc.common.config.datasource.DataSourceConfig Data source configuration class
com.xc.common.config.redis.RedisConfig redis configuration class

Links

Authors and acknowledgment

Team

License

Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 License are reserved by the Original Author.



from Hacker News https://ift.tt/3o88WTq

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.