开发环境搭建

开发环境搭建文档:golang开发环境搭建

GO后端部署

下载框架

git clone -b os-v3.2 https://github.com/tiger1103/gfast.git

git clone -b os-v3.2 https://gitee.com/tiger1103/gfast.git

安装依赖

go mod downloadgo mod tidy

项目配置文件

项目数据库文件 resource/data/gfast-v32.sql 创建数据库导入后修改配置

manifest/config/config.yaml.bak 复制改为manifest/config/config.yaml 修改必要配置如下:

数据库连接

# Database.
database:
  logger:
    level:   "all"
    stdout:  true
    Path: "resource/log/sql"

  default:
    link:   "mysql:gfast3:gfast333@tcp(localhost:3306)/gfast-v32?charset=utf8mb4&parseTime=true&loc=Local"
    debug:  true
    charset: "utf8mb4" #数据库编码
    dryRun: false #空跑
    maxIdle: 10 #连接池最大闲置的连接数
    maxOpen: 10 #连接池最大打开的连接数
    maxLifetime: "30s" #(单位秒)连接对象可重复使用的时间长度

配置参考:数据库使用配置

web服务器配置

server:
  address:     ":8808"
  serverRoot: "resource/public"
  dumpRouterMap: false
  routeOverWrite: true
  openapiPath: "/api.json"
  swaggerPath: "/swagger"
  NameToUriType: 3
  maxHeaderBytes: "20KB"
  clientMaxBodySize: "50MB"
  # Logging配置
  logPath: "resource/log/server"                 # 日志文件存储目录路径,建议使用绝对路径。默认为空,表示关闭
  logStdout: true               # 日志是否输出到终端。默认为true
  errorStack: true               # 当Server捕获到异常时是否记录堆栈信息到日志中。默认为true
  errorLogEnabled: true               # 是否记录异常日志信息到日志中。默认为true
  errorLogPattern: "error-{Ymd}.log"  # 异常错误日志文件格式。默认为"error-{Ymd}.log"
  accessLogEnabled: true              # 是否记录访问日志。默认为false
  accessLogPattern: "access-{Ymd}.log" # 访问日志文件格式。默认为"access-{Ymd}.log"

ServerRoot 用来设置静态资源目录,默认情况下是没有任何主目录的设置,只有设置了主目录,才支持对应主目录下的静态文件的访问。
ClientMaxBodySize 发送请求最大长度 如果需要上传大文件可以适当改大。

配置参考: web服务配置

gfToken配置

gfToken:
  cacheKey: "gfToken:"
  timeOut: 10800
  maxRefresh: 5400
  multiLogin: true
  encryptKey: "49c54195e750b04e74a8429b17896586"
  cacheModel: "dist"  #缓存模式 memory OR redis OR dist
  distPath: "./resource/data/distTokenDb" #使用磁盘缓存时配置数据缓存的目录
  excludePaths:
    - "/api/v1/system/login"

其中cacheMode 是gToken存储模式,memory为直接存储在内存中,redis为使用redis存储,dist为磁盘缓存 ,使用redis模式需要服务器安装并配置好redis服务。
注意:如果存储在内存中则每次服务重启都会清空token数据,也就是用户登录数据会丢失,需要重新登录。
token缓存前缀可用于区别不同系统或模块token缓存,会生成一个待前缀的key,如下图所示:

后台相关配置

system:
  notCheckAuthAdminIds: [1,2,31]  #无需验证后台权限的用户id
  dataDir: "./resource/data"
  cache:
    model: "dist"  #缓存模式 memory OR redis OR dist
    distPath: "./resource/data/distCacheDb" #使用磁盘缓存时配置数据缓存的目录
    prefix: "gFastV3Cache:" #缓存前缀

缓存前缀可用于区别不同系统或模块缓存,会生成一个待前缀的key,这样只要属于该系统的缓存便会带有次前缀用于区分,如下图所示:

redis配置


# Redis 配置示例
redis:
  # 单实例配置
  default:
    address: 127.0.0.1:6379
    db: 1
    idleTimeout: "60s" #连接最大空闲时间,使用时间字符串例如30s/1m/1d
    maxConnLifetime: "90s" #连接最长存活时间,使用时间字符串例如30s/1m/1d
    waitTimeout: "60s" #等待连接池连接的超时时间,使用时间字符串例如30s/1m/1d
    dialTimeout: "30s" #TCP连接的超时时间,使用时间字符串例如30s/1m/1d
    readTimeout: "30s" #TCP的Read操作超时时间,使用时间字符串例如30s/1m/1d
    writeTimeout: "30s" #TCP的Write操作超时时间,使用时间字符串例如30s/1m/1d
    maxActive: 100

配置参考:redis配置

导入数据到数据库

数据库文件位于:resource/data/gfast-v32.sql,将其导入对应的mysql数据库即可。

前端准备工作

node支持版本 [v16.x ~ v20.x)

下载前端项目

git clone -b os-v3.2 https://github.com/tiger1103/gfast-ui.git

git clone -b os-v3.2 https://gitee.com/tiger1103/gfast-ui.git

安装依赖

npm install --registry=https://registry.npmmirror.com

运行项目

npm run dev

打包发布

npm run build

前端基于vue-next-admin 开发,文档地址:https://lyt-top.gitee.io/vue-next-admin-doc-preview/

注意:如果后台菜单不全、或缺少接口,请清理下缓存

作者:管理员  创建时间:2023-01-06 14:48
最后编辑:管理员  更新时间:2024-03-25 18:02