Skip to content

Commit

Permalink
second
Browse files Browse the repository at this point in the history
  • Loading branch information
GpsLypy committed Apr 19, 2022
1 parent 29e02d1 commit e3a069e
Show file tree
Hide file tree
Showing 48 changed files with 3,656 additions and 486 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:latest

ENV GOPROXY https://goproxy.cn,direct
WORKDIR $GOPATH/src/github.com/EDDYCJY/go-gin-example
COPY . $GOPATH/src/github.com/EDDYCJY/go-gin-example
RUN go build .

EXPOSE 80
ENTRYPOINT ["./go-gin-example"]
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: build clean tool lint help

all: build

build:
@go build -v .

tool:
go vet ./...; true
gofmt -w .

lint:
golint ./...

clean:
rm -rf go-gin-example
go clean -i .

help:
@echo "make: compile packages and dependencies"
@echo "make tool: run specified go tool"
@echo "make lint: golint ./..."
@echo "make clean: remove object files and cached files"
54 changes: 39 additions & 15 deletions conf/app.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
#debug or release
RUN_MODE = debug

[app]
PAGE_SIZE = 10
JWT_SECRET = 23347$040412
PageSize = 10
JwtSecret = 233
PrefixUrl = http://127.0.0.1:3376
RuntimeRootPath = runtime/

#ImagePrefixUrl = http://127.0.0.1:80
ImageSavePath = upload/images/
# MB
ImageMaxSize = 5
ImageAllowExts = .jpg,.jpeg,.png

LogSavePath = logs/
LogSaveName = log
LogFileExt = log
TimeFormat = 20060102
#指定导出的 Excel 文件的存储路径
ExportSavePath = export/
QrCodeSavePath = qrcode/
FontSavePath = fonts/

[server]
HTTP_PORT = 80
READ_TIMEOUT = 60
WRITE_TIMEOUT = 60
#debug or release
RunMode = debug
HttpPort = 3376
ReadTimeout = 60
WriteTimeout = 60


[database]
TYPE = mysql
USER = root
PASSWORD = Mysql123..
#127.0.0.1:3306
HOST = 127.0.0.1:3306
NAME = blog
TABLE_PREFIX = blog_
Type = mysql
User = root
Password = Mysql123..
Host = 127.0.0.1:3306
Name = blog
TablePrefix = blog_

[redis]
Host = 127.0.0.1:6379
Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200

37 changes: 37 additions & 0 deletions cron.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

// import (
// "log"
// "time"

// "github.com/robfig/cron"

// "github.com/EDDYCJY/go-gin-example/models"
// )

// func main() {
// log.Println("Starting...")
// //会根据本地时间创建一个新(空白)的 Cron job runner
// //c := cron.New() 应该改为 c := cron.New(cron.WithSeconds()),否则不支持秒级别的定时任务。
// c := cron.New()
// //AddFunc 会向 Cron job runner 添加一个 func ,以按给定的时间表运行
// c.AddFunc("* * * * * *", func() {
// log.Println("Run models.CleanAllTag...")
// models.CleanAllTag()
// })
// c.AddFunc("* * * * * *", func() {
// log.Println("Run models.CleanAllArticle...")
// models.CleanAllArticle()
// })
// //c.Start()
// //在当前执行的程序中启动 Cron 调度程序。其实这里的主体是 goroutine + for + select + timer 的调度控制哦
// c.Start()

// t1 := time.NewTimer(time.Second * 10)
// for {
// select {
// case <-t1.C:
// t1.Reset(time.Second * 10)
// }
// }
// }
118 changes: 118 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/tags": {
"post": {
"produces": [
"application/json"
],
"summary": "新增文章标签",
"parameters": [
{
"type": "string",
"description": "Name",
"name": "name",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "State",
"name": "state",
"in": "query"
},
{
"type": "integer",
"description": "CreatedBy",
"name": "created_by",
"in": "query"
}
],
"responses": {
"200": {
"description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/tags/{id}": {
"put": {
"produces": [
"application/json"
],
"summary": "修改文章标签",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "ID",
"name": "name",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "State",
"name": "state",
"in": "query"
},
{
"type": "string",
"description": "ModifiedBy",
"name": "modified_by",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}",
"schema": {
"type": "string"
}
}
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
90 changes: 90 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"swagger": "2.0",
"info": {
"contact": {}
},
"paths": {
"/api/v1/tags": {
"post": {
"produces": [
"application/json"
],
"summary": "新增文章标签",
"parameters": [
{
"type": "string",
"description": "Name",
"name": "name",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "State",
"name": "state",
"in": "query"
},
{
"type": "integer",
"description": "CreatedBy",
"name": "created_by",
"in": "query"
}
],
"responses": {
"200": {
"description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/tags/{id}": {
"put": {
"produces": [
"application/json"
],
"summary": "修改文章标签",
"parameters": [
{
"type": "integer",
"description": "ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "ID",
"name": "name",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "State",
"name": "state",
"in": "query"
},
{
"type": "string",
"description": "ModifiedBy",
"name": "modified_by",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}",
"schema": {
"type": "string"
}
}
}
}
}
}
}
Loading

0 comments on commit e3a069e

Please sign in to comment.