From 50587c53cb2340c1bdffaf96b6fc9a256567a9db Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 28 Dec 2022 15:13:13 +0800 Subject: [PATCH] https://github.com/cskefu/cskefu/issues/779 add design folder and store schema info Signed-off-by: Hai Liang Wang --- design/schema/.gitignore | 37 + design/schema/README.md | 15 + design/schema/app/generator.php | 123 ++++ design/schema/assets/standalone.html | 88 +++ design/schema/bin/gen-mysql-table-dicts.sh | 66 ++ design/schema/sample.env | 8 + docs/index.html | 16 + docs/mysql-dicts.html | 819 +++++++++++++++++++++ 8 files changed, 1172 insertions(+) create mode 100644 design/schema/.gitignore create mode 100644 design/schema/README.md create mode 100644 design/schema/app/generator.php create mode 100644 design/schema/assets/standalone.html create mode 100644 design/schema/bin/gen-mysql-table-dicts.sh create mode 100644 design/schema/sample.env create mode 100644 docs/index.html create mode 100644 docs/mysql-dicts.html diff --git a/design/schema/.gitignore b/design/schema/.gitignore new file mode 100644 index 00000000..d35f24c5 --- /dev/null +++ b/design/schema/.gitignore @@ -0,0 +1,37 @@ +.vscode +*.swp +*.swo +*.sublime-* +*.pyc +jmeter.log +__pycache__ +tmp/ +package-lock.json +node_modules/ +sftp-config.json +.DS_Store +*.iml +*.ipr +*.iws +*.idea +~$*.xls* +~$*.ppt* +~$*.doc* +nohup.out + +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +build +build-* +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +.env +.fid +_build diff --git a/design/schema/README.md b/design/schema/README.md new file mode 100644 index 00000000..41a876b6 --- /dev/null +++ b/design/schema/README.md @@ -0,0 +1,15 @@ +# 数据字典 + +生成春松客服数据库数据字典。 + +## Prerequisite + +* Php +* pandoc + +## Generate + +``` +cp sample.env .env +./bin/gen-mysql-table-dicts.sh +``` \ No newline at end of file diff --git a/design/schema/app/generator.php b/design/schema/app/generator.php new file mode 100644 index 00000000..8f85bc00 --- /dev/null +++ b/design/schema/app/generator.php @@ -0,0 +1,123 @@ + $v){ + $sql = 'SELECT * FROM '; + $sql .= 'INFORMATION_SCHEMA.TABLES '; + $sql .= 'WHERE '; + $sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '".DB_NAME."'"; + $table_result = mysqli_query($conn, $sql); + while($t = mysqli_fetch_array($table_result)) { + $tables [$k] ['TABLE_COMMENT'] = $t ['TABLE_COMMENT']; + } + + $sql = 'SELECT * FROM '; + $sql .= 'INFORMATION_SCHEMA.COLUMNS '; + $sql .= 'WHERE '; + $sql .= "table_name = '{$v['TABLE_NAME']}' AND table_schema = '".DB_NAME."'"; + + $fields = array(); + $field_result = mysqli_query($conn, $sql); + while($t = mysqli_fetch_array($field_result)) { + $fields [] = $t; + } + $tables [$k] ['COLUMN'] = $fields; +} +mysqli_close($conn); + +$content = ''; +// 循环所有表 +foreach($tables as $k => $v){ + $content .= '

'. $v['TABLE_NAME'] . ' 

'; + $content .= ''; + $content .= ''; + $content .= ' + + '; + $content .= ''; + + foreach($v ['COLUMN'] as $f){ + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + } + $content .= '
' . ' ' . $v ['TABLE_COMMENT'] . '
字段名数据类型默认值允许非空自动递增备注
' . $f ['COLUMN_NAME'] . '' . $f ['COLUMN_TYPE'] . ' ' . $f ['COLUMN_DEFAULT'] . ' ' . $f ['IS_NULLABLE'] . '' . ($f ['EXTRA'] == 'auto_increment' ? '是' : ' ') . ' ' . $f ['COLUMN_COMMENT'] . '

'; +} + +// 输出 +$date = date('Y-m-d'); +$html = << + + +$title + + + +

$title(生成日期: $date)

+

版本:$version,SQL:下载链接,Models PDF:下载链接

+$content + +
+

- 春松客服, https://www.cskefu.com -

+ + +EOT; +file_put_contents('index.html', $html); +echo 'success!'; +?> \ No newline at end of file diff --git a/design/schema/assets/standalone.html b/design/schema/assets/standalone.html new file mode 100644 index 00000000..1349cd7c --- /dev/null +++ b/design/schema/assets/standalone.html @@ -0,0 +1,88 @@ + + + + + + + $if(title)$$title$$endif$ + + + +$if(template_css)$ + +$else$ + +$endif$ + + + + + + + + + $for(author-meta)$ + + $endfor$ + $if(date-meta)$ + + $endif$ + $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ + + $if(quotes)$ + + $endif$ + $if(highlighting-css)$ + + $endif$ + $for(css)$ + + $endfor$ + $if(math)$ + $math$ + $endif$ + $for(header-includes)$ + $header-includes$ + $endfor$ + + + + +
+ + $if(title)$ +
+
+

$title$

+ $if(date)$ +

$date$

+ $endif$ + $for(author)$ +

$author$

+ $endfor$ +
+
+ $endif$ + +
+
+
+ +
+
+ +
+$body$ +
+
+
+ + diff --git a/design/schema/bin/gen-mysql-table-dicts.sh b/design/schema/bin/gen-mysql-table-dicts.sh new file mode 100644 index 00000000..ae2fcb7f --- /dev/null +++ b/design/schema/bin/gen-mysql-table-dicts.sh @@ -0,0 +1,66 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +cwdDir=$PWD +export PYTHONUNBUFFERED=1 +export PATH=/opt/miniconda3/envs/venv-py3/bin:$PATH +export TS=$(date +%Y%m%d%H%M%S) +export DATE=`date "+%Y%m%d"` +export DATE_WITH_TIME=`date "+%Y%m%d-%H%M%S"` #add %3N as we want millisecond too +php=/c/devel/php/php.exe + +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $baseDir/.. + +if [ ! -f .env ]; then + echo "Copy sample.env to .env, modify it at first." + exit 1 +fi + +source .env + +# generate index.html +rm -rf tmp +mkdir tmp +cd tmp + +$php ../app/generator.php -H$DB_HOST \ + -P$DB_PORT \ + -d$DATABASE \ + -u$DB_USER \ + -p$DB_PASS \ + -v$PRODUCT_VERSION \ + -s$DOWNLOAD_SQL \ + -m$DOWNLOAD_MODEL_PDF + +# generate beautiful html +rm -rf docs +mkdir docs +cd docs + +pandoc ../index.html \ + -o index.html \ + -f html \ + --template ../../assets/standalone.html \ + --toc --toc-depth=2 + +cp index.html $baseDir/../../../docs/mysql-dicts.html + +echo "Generated doc index.html in" `pwd` + +# compress files +cd .. +DATABASE_DICTS_ZIP=$DATABASE.dicts.$TS.zip +if [ -f $DATABASE_DICTS_ZIP ]; then + rm -rf $DATABASE_DICTS_ZIP +fi + +zip $DATABASE_DICTS_ZIP -r docs +echo "Compress with zip file" `pwd`/$DATABASE_DICTS_ZIP \ No newline at end of file diff --git a/design/schema/sample.env b/design/schema/sample.env new file mode 100644 index 00000000..3a3e604c --- /dev/null +++ b/design/schema/sample.env @@ -0,0 +1,8 @@ +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_USER=root +DB_PASS=123456 +DATABASE=cskefu_v8_design +PRODUCT_VERSION=v8 +DOWNLOAD_SQL=https://github.com/cskefu/cskefu +DOWNLOAD_MODEL_PDF=https://github.com/cskefu/cskefu \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 00000000..f7cd3242 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,16 @@ + + + + CSKeFu / 春松客服:上线开源客服系统 + + + +

本站点仅用来托管以下内容

+

数据字典

+ 参考链接:mysql-dicts.html + +

官网

+ 更多内容访问官方网站:https://www.cskefu.com + + + \ No newline at end of file diff --git a/docs/mysql-dicts.html b/docs/mysql-dicts.html new file mode 100644 index 00000000..03e42722 --- /dev/null +++ b/docs/mysql-dicts.html @@ -0,0 +1,819 @@ + + + + + + + 春松客服-数据字典 + + + + + + + + + + + + + 春松客服-数据字典 + + + + + + +
+ +
+
+

春松客服-数据字典

+
+
+ +
+ + +
+

春松客服-数据字典(生成日期: +2022-12-28)

+

版本:v8,SQL:下载链接,Models PDF:下载链接

+

cs_group_users 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Users in Group
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
groupidvarchar(45)  NO  Group Id
useridvarchar(45)  NO  User Id
createtimedatetime CURRENT_TIMESTAMP NO  Create time
updatetimedatetime CURRENT_TIMESTAMP NO  Update time
+

cs_groups 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Groups
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
namevarchar(200)  NO  Group name
descriptiontext  YES  Group Description
createtimevarchar(45) CURRENT_TIMESTAMP NO  Create time
updatetimevarchar(45) CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NO  Update time
deletedtinyint(1) 0 YES  
creatorvarchar(45)  NO  
+

cs_permission_groups 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
groupidvarchar(45)  NO  Group Id
resourceoperationidvarchar(45)  NO  Resource Operation Id
enabledtinyint(1)  YES  1
createtimedatetime CURRENT_TIMESTAMP NO  
updatetimedatetime CURRENT_TIMESTAMP NO  
+

cs_permission_users 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
useridvarchar(45)  NO  
resourcepatternidvarchar(45)  NO  
enabledtinyint(1)  YES  
createtimedatetime CURRENT_TIMESTAMP YES  
updatetimedatetime CURRENT_TIMESTAMP YES  
+

cs_resource_operations 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
namevarchar(30)  NO  Describe the operation with short chars, e.g. read, +create, update, delete, admin
descriptionvarchar(1000)  NO  A tooltip to describe the operation in details
resourceidvarchar(45)  NO  Resource Id
patternvarchar(500)  NO  URL Path Pattern, e.g. /chat/*, /workorder/*
methodvarchar(255)  NO  HTTP Method: Get, Post, Put, Delete, etc.
pluginidint(11)  YES  Plugin provide this operation
pluginversionvarchar(255)  YES  Plugin version of pluginid
createtimedatetime CURRENT_TIMESTAMP NO  
updatetimedatetime CURRENT_TIMESTAMP NO  
+

cs_resources 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
spacekeyvarchar(300)  NO  
namevarchar(30)  NO  Short name of this resource, e.g. workorder.
descriptiontext  NO  Describe the resource in detail
+

cs_spaces 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Spaces
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
spacenamevarchar(300)  NO  
spacekeyvarchar(300)  NO  
creatorvarchar(45)  NO  
descriptiontext  NO  
createtimedatetime CURRENT_TIMESTAMP NO  
updatetimedatetime CURRENT_TIMESTAMP NO  
+

cs_users 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Users
字段名数据类型默认值允许非空自动递增备注
idvarchar(45)  NO  
lastnamevarchar(200)  YES  
usernamevarchar(200)  NO  
firstnamevarchar(100)  YES  
realnamevarchar(200)  YES  
englishnamevarchar(200)  YES  
phonenumbervarchar(45)  YES  
phonecountrycodevarchar(45)  YES  
phoneverifiedtinyint(1) 0 YES  
birthdayvarchar(45)  YES  
countryvarchar(45)  YES  
provincevarchar(45)  YES  
cityvarchar(45)  YES  
streetvarchar(500)  YES  
avatarurlvarchar(500)  YES  
sexvarchar(45)  YES  
birthyearint(11)  YES  
primarylanguagevarchar(45)  YES  Primary Language, locale code, zh_CN, zh_TW, en_US, +etc.
biotext  YES  
emailvarchar(200)  NO  
emailverifiedtinyint(1) 0 YES  
passwordvarchar(200)  YES  
identitytypevarchar(45)  YES  Identiry File Type - ID card, passport, etc.
identitynumbervarchar(100)  YES  Identity File Sn.
identityverifiedtinyint(1) 0 YES  Identity File Verified or not
identityverifydatedatetime  YES  
blockedtinyint(1) 0 YES  
deletedtinyint(1)  YES  
createtimedatetime CURRENT_TIMESTAMP YES  
updatetimedatetime CURRENT_TIMESTAMP YES  
+

- 春松客服, https://www.cskefu.com +-

+
+
+
+ +