快速crud开发框架,甚至于一行代码不用敲;自动根据数据库表结构自动生成crud代码;低代码开发框架;至少减少百分90%工作量;可快速把现有系统转成GfEasy版本;后端使用GoFrame开发;后台前端使用 cool-admin-vue;后台使用自适应布局,手机、PC完美使用。

GoFrame: GfEasy

GfEasy Logo

GfEasy So Easy

快速crud开发框架,甚至于一行代码不用敲

自动根据数据库表结构自动生成crud代码

低代码开发框架

至少减少百分90%工作量

可快速把现有系统转成GfEasy版本

后端使用GoFrame开发;后台前端使用 cool-admin-vue

后台使用自适应布局,手机、PC完美使用

img.png

GfEasy-移动.png


地址

后端:

https://github.com/jasonLaw1015/GfEasy

或者

https://gitee.com/jasonlaw1015/GfEasy


后台前端:

https://github.com/jasonLaw1015/GfEasyAdmin

或者

https://gitee.com/jasonlaw1015/GfEasyAdmin

一、快速开始


Go环境安装,请参考

https://goframe.org/pages/viewpage.action?pageId=1114397

后台server:

请使用GoLand编辑器

下载代码&安装依赖

#克隆仓库
git clone https://gitee.com/jasonlaw1015/GfEasy.git
#或者
git clone https://github.com/jasonLaw1015/GfEasy.git

打开mysql=》创建gf-easy库=》 运行db/gf-easy.sql;创建表结构和初始化数据

配置mysql、Redis

打开文件 /config/config.toml

按照你本地环境配置好 img.png

#格式化代码
gofmt ./
#安装更新相关依赖
go mod tidy
# 运行或者你点击GoLang IDE编辑器;
# 运行安装过程完成后,运行以下命令启动服务。您可以在浏览器中预览网站 [http://localhost:8000](http://localhost:8000)
go run main.go

img_8.png


安装gf开发工具

https://goframe.org/pages/viewpage.action?pageId=1115782


生成接口文档

gf swagger --pack

交叉编译

运行已下命令,生成linux环境可执行文件

gf build main.go -n my-app -v 1.0 -a amd64 -s linux -p ./

会得到个my-app可执行文件


也可以配置gfcli.build

在cofig.toml上配置

[gfcli]
    [gfcli.build]
        name     = "GenCode-GfEasy"
        arch     = "all"
        system   = "all"
        mod      = "none"
        cgo      = 0
        pack     = "template"
        version  = "v1.0.0"
        output   = "./bin"
        extra    = ""

再运行

gf build

会生成所有平台的可执行文件,到./bin

img100.png

注: 一般选择amd64。你可以运行go env 查看到你本机是哪个,自己选择那个

darwin=>mac

linux=>linux

windows=>windows


后台前端Vue

必须安装:

操作系统上安装了 Node.js(> = 12.1.0)、@vue/cli。

我用的是node 是14.17.6


npm install -g @vue/cli
npm install -g yarn

解决 node-sass 网络慢的方法:

yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

然后下载仓库

#克隆仓库
git clone https://gitee.com/jasonlaw1015/GfEasyAdmin.git
#或者
git clone https://github.com/jasonLaw1015/GfEasyAdmin.git

安装依赖

#GfEasyAdmin目录下,运行下面命令安装依赖
yarn
#或者
npm i

安装过程完成后,运行以下命令启动服务。您可以在浏览器中预览网站 http://localhost:8000

yarn dev
yarn dev
#或者
npm run dev

格式化代码 请在vscode安装eslint、vetur插件

yarn lint:eslint

打包构建

#会在dist目录生成,此目录就是生产环境所运行的
yarn build

访问

http://localhost:8000

img_2.png

账号密码:admin/123456


拥有基于角色的权限控制模型RBAC

img.png

img_4.png

代码生成操作【重要】

前提条件,下载代码生成核心部件。

地址:

https://www.yuque.com/docs/share/3e714752-0de1-43e2-96e4-461f4e74fc93?# 《代码生成模块》

下载适合自己系统的版本,然后点击运行即可【这步是生成代码的前提条件,必须运行】

运行结果: 出现以下截图即正确

genCodeLog.png

知识讲解:

GOOS : 目标平台

mac 对应 darwin linux 对应 linux windows 对应 windows

GOARCH :目标平台的体系架构【386,amd64,arm】, 目前市面上的个人电脑一般都是amd64架构的

386 也称 x86 对应 32位操作系统 amd64 也称 x64 对应 64位操作系统 arm 这种架构一般用于嵌入式开发。 比如 Android , IOS , Win mobile , TIZEN 等

界面操作

进入系统-》/核心工具/代码生成工具

img_5.png

然后按步骤123,配置相关参数 步骤1:配置所需要环境参数

注意:

必须在有网地方使用

下图的生成代码目录的是mac端的, windows端要写成\,反斜杠。

如:D:\develop\go\src\gitee.com\jasonLaw1015\GfEasyAdmin\


img.png

步骤2:检测下步骤1的数据是否可行

img_16.png

步骤3:开始生成代码

img_17.png

确认后:

将在GfEasy生成以下文件

app/controller/Admin/DemoGo.go
app/controller/Api/DemoGo.go
app/model/DemoGoModel/DemoGo.go
app/service/DemoGoService/DemoGo.go
router/adminRouter.go
router/apiRouter.go

img_7.png

将在GfEasyAdmin生成,(前端生成代码都会在GfEasyAdmin/src/cool/modules/genCode下)

GfEasyAdmin/src/cool/modules/genCode/dict/demoGo.ts
GfEasyAdmin/src/cool/modules/genCode/service/demoGo.ts
GfEasyAdmin/src/cool/modules/genCode/views/demoGo.vue

img_8.png 并自动生成权限和菜单加入前端路由,下图

img_9.png

注意:

生成的代码会在自动格式化代码。如果不行,那自己yarn lint:eslint、 gofmt; go不会热更新,请自己手动run一下

二、基础知识

举例

比如,建一个demo_go表;

img_10.png

CREATE TABLE `demo_go` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `createTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间',
  `updateTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间',
  `title` varchar(255) NOT NULL COMMENT '标题',
  `subTitle` varchar(255) DEFAULT NULL COMMENT '副标题##IsSearchParams',
  `pic` varchar(255) NOT NULL COMMENT '商品主图',
  `types` tinyint(4) NOT NULL COMMENT '类型#1:上架,2:下架',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态#1:启用,2:禁用',
  `tupian` varchar(300) DEFAULT NULL COMMENT '图片##IsPicColumn',
  `other` tinyint(4) DEFAULT NULL COMMENT '其他状态#1:已激活,2:未激活#IsDictColumn,IsSearchParams',
  `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
  PRIMARY KEY (`id`),
  KEY `IDX_d8d0d86a0adf1001ce12aaac41` (`createTime`),
  KEY `IDX_9fe44721d1e517fa24383db56b` (`updateTime`),
  FULLTEXT KEY `IDX_91f50fa9907d5ac2c864f175bb` (`title`,`subTitle`) /*!50100 WITH PARSER `ngram` */ 
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='示例go';

代码生成器会自动判断字段类型,生成对应的go类型,生成对应的结构体,如下 img.png


go端:

mysql 字段类型 go类型
varchar string
int int
DATETIME *gtime.Time
... ...

vue端:

会判断字段,然后确认其使用哪个前端组件来处理该字段。

如:el-input、el-input-number、el-radio-group、cl-upload-space-preview


2.1、定义表字段规则:


默认规则:

1.设计数据字段,主键字段名必须是id;

2.创建时间和更新时间的字段名,可以自定义。但最好使用createTime.updateTime;

3.默认查询条件字段是: types status name title state

其中name title 用关键字模糊查询

4.图片字段是: pic pics picture img image images

5.字典字段是: types status

注意: 字典字段,必须在comment处写上对应字典键值对,而且必须在第一个#号后面。字段comment处理通过#处理的

如:types tinyint(4) NOT NULL COMMENT '类型#1:上架,2:下架',

1:上架,2:下架 会转化成 下图

img_1.png

在后台UI显示如下图:

img_2.png

6.排序字段: sort orderNum

7.外键名要写全且是小驼峰。如base_a、base_b,a表和b表关联的话。b表中外键字段名必须为baseAId。否则前端ui的select组件不生效


指定规则:

有些数据库设计,有时我不想使用上述提供的字段名。为提高灵活性,特意提供了指定标识, 只要在comment里加入对应标识,系统就会自动帮你处理成你想要的字段。

这些标识要写在第二个#号后面。如:其他状态#1:已激活,2:未激活#IsDictColumn,IsSearchParams

标识 描述 具体
IsSearchParams 主要是list接口的条件使用 img_3.png
IsKeyWordParams 主要是page接口的条件使用,用于模糊查询 img_4.png
IsDictColumn,IsSearchParams IsDictColumn往往是要跟IsSearchParams一起使用。如:其他状态#1:已激活,2:未激活#IsDictColumn,IsSearchParams img_5.png
IsNumberColumn 该字段是数值类型,前端部分会使用el-input-number来处里该字段 img_6.png
IsPicColumn 该字段是图片类型,前端部分会使用cl-upload-space-preview来处里该字段 img_7.png

特别提醒:尽量不要用type来做字段名,否则生成的go代码有可能会出问题。因为type是go语法的关键字。目前我是用types代替。其他go关键字也是如此


2.2、定时任务的使用:

新增定时任务逻辑 在app/task文件夹下,新增方法即可

img_11.png

然后在后台=》任务管理/任务列表

img_22.png

在service就可以看到刚刚写的GoodsTask。

只要在package Task下写方法都可以在这里选择使用


三、采用技术的相关使用文档

GoFrame: https://goframe.org/pages/viewpage.action?pageId=1114203

cool-admin-vue: https://www.cool-js.com/front/vue3-vite.html

ElementPlus: https://element-plus.org/#/zh-CN/component/radio

Similar Resources

Golang & vue web serve

Golang & vue web serve

go_web 本项目源自blog 目前主要功能为个人博客服务

Jan 29, 2022

its a simple backdoor service that im making cuz i think that it could be cool its not finished but this is a cool project

  its a simple backdoor service that im making cuz i think that it could be cool its not finished but this is a cool project

yackdoor its a simple backdoor service that im making cuz i think that it could be cool its not finished but this is a cool project how it looks backd

Aug 18, 2022

go-admin项目地址已经转移https://github.com/go-admin-team/go-admin

go-admin项目地址已经转移https://github.com/go-admin-team/go-admin

English | 简体中文 基于Gin + Vue + Element UI的前后端分离权限管理系统 系统初始化极度简单,只需要配置文件中,修改数据库连接,系统启动后会自动初始化数据库信息以及必须的基础数据 在线文档国际 在线文档国内 前端项目 视频教程 ✨ 特性 遵循 RESTful API 设

Dec 31, 2022

Automated penetration and auxiliary systems, providing XSS, XXE, DNS log, SSRF, RCE, web netcat and other Servers,gin-vue-admin

Automated penetration and auxiliary systems, providing XSS, XXE, DNS log, SSRF, RCE, web netcat and other Servers,gin-vue-admin

Simple DNS log Server,easy to ACME DNS challenge log easy send to elasticsearch https://github.com/hktalent/DNS_Server go4Hacker Automated penetration

Dec 30, 2022

beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等

beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等

beego-vue-admin 后台管理系统 项目简介 beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等 体验

Dec 30, 2022

A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting

A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting

A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting Family project Table of Contents Weapons Contribute Thanks to con

Jan 3, 2023

An open-source GitLab command line tool bringing GitLab's cool features to your command line

An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022

⚔️ Web Hacker's Weapons / A collection of cool tools used by Web hackers. Happy hacking , Happy bug-hunting

⚔️ Web Hacker's Weapons / A collection of cool tools used by Web hackers. Happy hacking , Happy bug-hunting

A collection of cool tools used by Web hackers. Happy hacking , Happy bug-hunting Family project Table of Contents WHW-Tools Weapons Awesome Bookmarkl

Jan 5, 2023

Create cool animations by gradually adding pixels to an interpolated image.

Create cool animations by gradually adding pixels to an interpolated image.

voronoi-interp If you only know a few random pixels of an image, you can fill in the rest using nearest neighbors. This can result in cool animations

Sep 21, 2022

Create a cool glass-like pattern using Voronoi cells

Create a cool glass-like pattern using Voronoi cells

voronoi-glass Have you ever looked through a shower door made of intentionally uneven glass? Everything looks distorted, but maybe also beautiful. Now

Jul 21, 2022

Control external Fan to cool down your raspi cluster

Control external Fan to cool down your raspi cluster

Fan control for Raspberry Pi This is a small project that I build in order to cool down my raspi home cluster The case I use have some external fans t

Dec 11, 2021

A very cool and stable VCP with 0 points of failure

network A VPC written in golang. Assign internal IP addresses to servers where all traffic sent internally is encrypted. OS Building Linux go build .

Nov 8, 2021

Sapfun - Utility that takes control over your video card coolers to keep it cool and steady

What? sapfun - Utility that takes control over your video card coolers to keep i

Feb 18, 2022

Cross-platform beanstalkd queue server admin console.

Cross-platform beanstalkd queue server admin console.

Overview aurora is a web-based Beanstalkd queue server console written in Go and works on macOS, Linux, and Windows machines. The main idea behind usi

Dec 30, 2022

Cross-platform beanstalkd queue server admin console.

Cross-platform beanstalkd queue server admin console.

Overview aurora is a web-based Beanstalkd queue server console written in Go and works on macOS, Linux, and Windows machines. The main idea behind usi

Dec 30, 2022

pgCenter is a command-line admin tool for observing and troubleshooting Postgres.

pgCenter is a command-line admin tool for observing and troubleshooting Postgres.

Command-line admin tool for observing and troubleshooting Postgres.

Dec 29, 2022

A fast tool to mass scan for a vulnerability on Microsoft Exchange Server that allows an attacker bypassing the authentication and impersonating as the admin (CVE-2021-26855).

A fast tool to mass scan for a vulnerability on Microsoft Exchange Server that allows an attacker bypassing the authentication and impersonating as the admin (CVE-2021-26855).

proxylogscan This tool to mass scan for a vulnerability on Microsoft Exchange Server that allows an attacker bypassing the authentication and imperson

Dec 26, 2022

A golang framework helps gopher to build a data visualization and admin panel in ten minutes

A golang framework helps gopher to build a data visualization and admin panel in ten minutes

the missing golang data admin panel builder tool. Documentation | 中文介绍 | DEMO | 中文DEMO | Twitter | Forum Inspired by laravel-admin Preface GoAdmin is

Dec 30, 2022

Distributed web crawler admin platform for spiders management regardless of languages and frameworks. 分布式爬虫管理平台,支持任何语言和框架

Distributed web crawler admin platform for spiders management regardless of languages and frameworks. 分布式爬虫管理平台,支持任何语言和框架

Crawlab 中文 | English Installation | Run | Screenshot | Architecture | Integration | Compare | Community & Sponsorship | CHANGELOG | Disclaimer Golang-

Jan 7, 2023
Automated penetration and auxiliary systems, providing XSS, XXE, DNS log, SSRF, RCE, web netcat and other Servers,gin-vue-admin
Automated penetration and auxiliary systems, providing XSS, XXE, DNS log, SSRF, RCE, web netcat and other Servers,gin-vue-admin

Simple DNS log Server,easy to ACME DNS challenge log easy send to elasticsearch https://github.com/hktalent/DNS_Server go4Hacker Automated penetration

Dec 30, 2022
beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等
beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等

beego-vue-admin 后台管理系统 项目简介 beego-vue-admin基于当前流行技术组合的前后端RBAC管理系统:Go1.15.x+Beego2.x+Jwt+Redis+Mysql8+Vue 的前后端分离系统,权限控制采用 RBAC,支持数据字典与数据权限管理,支持动态路由等 体验

Dec 30, 2022
A golang framework helps gopher to build a data visualization and admin panel in ten minutes
A golang framework helps gopher to build a data visualization and admin panel in ten minutes

the missing golang data admin panel builder tool. Documentation | 中文介绍 | DEMO | 中文DEMO | Twitter | Forum Inspired by laravel-admin Preface GoAdmin is

Dec 30, 2022
GoAdmin is a toolkit to help you build a data visualization admin panel for your golang app.
GoAdmin is a toolkit to help you build a data visualization admin panel for your golang app.

the missing golang data admin panel builder tool. Documentation | 中文文档 | 中文介绍 | DEMO | 中文DEMO | Twitter | Forum Inspired by laravel-admin Preface GoAd

Nov 25, 2021
A dataviz framework help gopher to build a admin panel in ten minutes
A dataviz framework help gopher to build a admin panel in ten minutes

the missing golang data admin panel builder tool. Documentation | 中文文档 | DEMO Inspired by laravel-admin Preface GoAdmin is a toolkit to help you build

Oct 17, 2022
Ares-admin - Kratos Project Template For Golang

Kratos Project Template Install Kratos go get -u github.com/go-kratos/kratos/cmd

Feb 15, 2022
Generate a modern Web project with Go and Angular, React or Vue in seconds 🚀
Generate a modern Web project with Go and Angular, React or Vue in seconds 🚀

Goxygen Generate a Web project with Go and Angular, React or Vue. Goxygen aims at saving your time while setting up a new project. It creates a skelet

Jan 5, 2023
Go backend for the Vue-Go personal digital library application

Motivation Create a backend that connects to a cloud storage, so to store and retrieve my personal books. Barebone application State “DONE” from “NEXT

Dec 23, 2021
A real-time serverless chat application with Go and Vue 3
A real-time serverless chat application with Go and Vue 3

sls-chat-app A real-time serverless chat application with Go and Vue 3. For the

Jul 17, 2022
A ToDoList Demo based on Vue+Gin+Gorm+mysql
A ToDoList Demo based on Vue+Gin+Gorm+mysql

bubble清单 一个基于gin+gorm开发的练手小项目,通过该项目可初识go web开发该有的姿势。 前端页面基于vue和ElementUI开发,对前端不熟悉的童鞋可直接下载templates和static文件夹下的内容使用。 使用指南 下载 [email protected]:mao888/GoWe

Mar 16, 2022