1 Star 0 Fork 11

yanglbsjz / zcms

forked from gpress / gpress 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

gpress

介绍

云原生高性能内容平台,基于Hertz + Go template + Bleve全文检索实现,100M内存即可完美运行

功能说明:

  • 后台就一种用户,登录就是管理员,菜单路由写死,不需要权限分配
  • 记录登录失败的次数,密码连续错误5次屏蔽账号10分钟,防止暴力登录
  • 全文检索产生的文件,用户上传的文件,站点的模板文件放到外部目录
  • 后台提供网站导航菜单管理,广告位管理,底部footer条管理,新闻资讯管理和表单提交管理. 模板暂不提供在线编辑功能,开发人员编辑好上传到指定目录.
  • 因为使用nosql(全文检索),所以文章的属性字段可以随意添加,code用于检索,中文name用于显示.

软件架构

使用 Hertz + Go template + Bleve全文检索,不使用数据库
使用 Go 1.16 的新特性 Go embed,打包静态资源文件

不使用struct对象,全部使用map保存数据,可以随时增加属性字段.记录所有字段的名称,类型,中文名,code

模型的字段属性也是map,应用的文章回把模型的map属性全部取出,和自己的map覆盖合并.

数据结构

所有的数据结构都使用Map实现,不再使用struct.因使用Bleve做NoSQL数据库,所以map可以任意添加字段.
所有不需要分词的字符串,Mapping.Analyzer = keyword.Name 指定为keyword分词器.这样就可以类似数据库 name=value 作为精确的查询条件了.
值使用逗号(,)隔开,使用 commaAnalyzerName 分词器,实现类似sql in 的效果.

在IndexField表里设置IndexCode='Module',记录所有的Module.
然后在IndexField中插入每个module的字段,每个module实例的ModuleCode都是不同的,使用Module_+后缀的方式命名,只是记录,并不创建index

ID默认使用时间戳(23位)+随机数(9位),全局唯一

索引和字段(索引名:IndexField)

记录所有索引字段code和中文说明.
理论上所有的索引字段都可以放到这个表里,因为都是Map,就不需要再单独指定索引的字段了,可以动态创建Index(目前建议这样做)
这个可能是唯一的Struct......

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
IndexCode string 索引代码 类似表名 User,SiteInfo,PageTemplate,NavMenu,Module,Content
IndexName string 索引名称 类似表名中文说明
BusinessID string 业务ID 处理业务记录临时增加的字段,意外情况
FieldCode string 字段代码 -
FieldName string 字段中文名称 -
FieldType int 字段类型 - 数字(1),日期(2),文本框(3),文本域(4),富文本(5),下拉框(6),单选(7),多选(8),上传图片(9),上传附件(10),轮播图(11),音频(12),视频(13)
FieldFormat string 数据格式,用于日期或者数字 -
DefaultValue string 默认值 -
AnalyzerName string 分词器名称 - 为 '' 不设置
CreateTime time.Time 创建时间 - 2006-01-02 15:04:05
UpdateTime time.Time 更新时间 - 2006-01-02 15:04:05
CreateUser string 创建人 - 初始化 system
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)

用户(索引名:User)

后台只有一个用户,账号admin 密码默认admin 可以自己修改.

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
Account string 登录名称 默认admin
PassWord string 密码 -
UserName string 中文名称 -

站点信息(SiteInfo)

站点的信息,例如 title,logo,keywords,description等

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
Title string 站点名称 -
KeyWords string 关键字 -
Description string 站点描述 -
theme string 默认主题 默认使用default
themePC string PC主题 先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
themeWAP string 手机主题 先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
themeWEIXIN string 微信主题 先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
Logo string logo -
Favicon string Favicon -

页面模板(索引名:PageTemplate)

后台只有一个用户,账号admin 密码默认admin 可以自己修改.

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
TemplateName string 模板名称 -
TemplatePath string 模板路径 -
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)

导航菜单(索引名:NavMenu)

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
MenuName string 菜单名称 -
MenuName string 菜单名称 -
HrefURL string 跳转路径 -
HrefTarget string 跳转方式 _self,_blank,_parent,_top
PID string 父菜单ID 父菜单ID
ModuleIndexCode string Module的索引名称 导航菜单下的文章默认使用的模型字段
ComCode string 逗号隔开的全路径 逗号隔开的全路径
TemplateID string 模板Id 当前导航页的模板
ChildTemplateID string 子页面模板Id 子页面默认使用的模板,子页面如果不设置,默认使用这个模板
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)

模型(索引名:Module)

文章模型,只是用来声明字段,具体信息会有Content索引全部继承
暂时不使用了,这里只做参考.
在IndexField表里设置IndexCode='Module',记录所有的Module.
然后在IndexField中插入每个module的字段,每个module实例的ModuleCode都是不同的,使用Module_+后缀的方式命名,只是记录,并不创建index

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
ModuleIndexCode string 模型Code -
ModuleName string 模型名称 -
CreateTime time.Time 创建时间 - 2006-01-02 15:04:05
UpdateTime time.Time 更新时间 - 2006-01-02 15:04:05
CreateUser string 创建人 - 初始化 system
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)

模型数据(索引名:Module_default)

在IndexField表里设置IndexCode='Module',记录所有的Module.
然后在IndexField中插入每个module的字段,每个module实例的ModuleCode都是不同的,使用Module_+后缀的方式命名,只是记录,并不创建index

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
Title string 文章标题 -
KeyWords string 关键字 使用 commaAnalyzerName 分词器,实现类似sql in 的效果.
Description string 站点描述 -
PageURL string 自身页面路径 -
Subtitle string 副标题 -
Content string 文章内容
CreateTime time.Time 创建时间 - 2006-01-02 15:04:05
UpdateTime time.Time 更新时间 - 2006-01-02 15:04:05
CreateUser string 创建人 - 初始化 system
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)

文章内容(索引名:Content)

文章内容表,默认使用 Module_default 的模型字段

codeName 类型 中文名称 是否分词 备注
ID string 主键 -
ModuleIndexCode string 模型的Code 文章使用的模型字段
Title string 文章标题 -
KeyWords string 关键字 使用 commaAnalyzerName 分词器,实现类似sql in 的效果.
Description string 站点描述 -
PageURL string 自身页面路径 -
Subtitle string 副标题 -
NavMenuId string 导航ID,逗号(,)隔开 使用 commaAnalyzerName 分词器,实现类似sql in 的效果.
NavMenuName string 导航名称 -
TemplateID string 模板Id 模板
Content string 文章内容
CreateTime time.Time 创建时间 - 2006-01-02 15:04:05
UpdateTime time.Time 更新时间 - 2006-01-02 15:04:05
CreateUser string 创建人 - 初始化 system
SortNo int 排序 - 正序
Active int 是否有效 - 无效(0),正常显示(1),界面不显示(3)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

云原生高性能CMS,基于gin + golang template + Bleve全文检索实现,100M内存即可完美运行 展开 收起
Go
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/yanglbsjz/zcms.git
git@gitee.com:yanglbsjz/zcms.git
yanglbsjz
zcms
zcms
master

搜索帮助