Initial commit
This commit is contained in:
commit
c0cb826917
63 changed files with 2069 additions and 0 deletions
28
.go-arch-lint.yml
Normal file
28
.go-arch-lint.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
version: 3
|
||||||
|
workdir: ./
|
||||||
|
allow:
|
||||||
|
depOnAnyVendor: true
|
||||||
|
|
||||||
|
components:
|
||||||
|
domain: { in: internal/domain/** }
|
||||||
|
application: { in: internal/application/** }
|
||||||
|
infrastructure: { in: internal/infrastructure/** }
|
||||||
|
interface: { in: internal/interface/** }
|
||||||
|
cmd: {in: cmd/**}
|
||||||
|
|
||||||
|
commonComponents:
|
||||||
|
- domain
|
||||||
|
|
||||||
|
deps:
|
||||||
|
infrastructure:
|
||||||
|
mayDependOn:
|
||||||
|
- application
|
||||||
|
interface:
|
||||||
|
mayDependOn:
|
||||||
|
- application
|
||||||
|
- infrastructure
|
||||||
|
cmd:
|
||||||
|
mayDependOn:
|
||||||
|
- application
|
||||||
|
- infrastructure
|
||||||
|
- interface
|
||||||
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
## 58team's blog backend
|
||||||
38
cmd/main.go
Normal file
38
cmd/main.go
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// @title 58team blog backend
|
||||||
|
// @version 1.0
|
||||||
|
// @description 58team blog's backend
|
||||||
|
// @termsOfService http://swagger.io/terms/
|
||||||
|
|
||||||
|
// @contact.name API Support
|
||||||
|
// @contact.url http://www.swagger.io/support
|
||||||
|
// @contact.email support@swagger.io
|
||||||
|
|
||||||
|
// @license.name Apache 2.0
|
||||||
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
// @host localhost:8080
|
||||||
|
// @BasePath /api/v1
|
||||||
|
|
||||||
|
// @securityDefinitions.basic BasicAuth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/docs"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/swaggo/files"
|
||||||
|
"github.com/swaggo/gin-swagger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
router := gin.Default()
|
||||||
|
docs.SwaggerInfo.Title = "58team blog"
|
||||||
|
docs.SwaggerInfo.Description = "This is blog 58team"
|
||||||
|
docs.SwaggerInfo.Version = "1.0"
|
||||||
|
docs.SwaggerInfo.Host = "localhost:8080"
|
||||||
|
docs.SwaggerInfo.BasePath = "/api/v1/"
|
||||||
|
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
||||||
|
|
||||||
|
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||||
|
router.Run(":8080")
|
||||||
|
}
|
||||||
50
docs/docs.go
Normal file
50
docs/docs.go
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||||
|
package docs
|
||||||
|
|
||||||
|
import "github.com/swaggo/swag"
|
||||||
|
|
||||||
|
const docTemplate = `{
|
||||||
|
"schemes": {{ marshal .Schemes }},
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"description": "{{escape .Description}}",
|
||||||
|
"title": "{{.Title}}",
|
||||||
|
"termsOfService": "http://swagger.io/terms/",
|
||||||
|
"contact": {
|
||||||
|
"name": "API Support",
|
||||||
|
"url": "http://www.swagger.io/support",
|
||||||
|
"email": "support@swagger.io"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "Apache 2.0",
|
||||||
|
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
|
},
|
||||||
|
"version": "{{.Version}}"
|
||||||
|
},
|
||||||
|
"host": "{{.Host}}",
|
||||||
|
"basePath": "{{.BasePath}}",
|
||||||
|
"paths": {},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"BasicAuth": {
|
||||||
|
"type": "basic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||||
|
var SwaggerInfo = &swag.Spec{
|
||||||
|
Version: "1.0",
|
||||||
|
Host: "localhost:8080",
|
||||||
|
BasePath: "/api/v1",
|
||||||
|
Schemes: []string{},
|
||||||
|
Title: "58team blog backend",
|
||||||
|
Description: "58team blog's backend",
|
||||||
|
InfoInstanceName: "swagger",
|
||||||
|
SwaggerTemplate: docTemplate,
|
||||||
|
LeftDelim: "{{",
|
||||||
|
RightDelim: "}}",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||||
|
}
|
||||||
26
docs/swagger.json
Normal file
26
docs/swagger.json
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"description": "58team blog's backend",
|
||||||
|
"title": "58team blog backend",
|
||||||
|
"termsOfService": "http://swagger.io/terms/",
|
||||||
|
"contact": {
|
||||||
|
"name": "API Support",
|
||||||
|
"url": "http://www.swagger.io/support",
|
||||||
|
"email": "support@swagger.io"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "Apache 2.0",
|
||||||
|
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
|
},
|
||||||
|
"version": "1.0"
|
||||||
|
},
|
||||||
|
"host": "localhost:8080",
|
||||||
|
"basePath": "/api/v1",
|
||||||
|
"paths": {},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"BasicAuth": {
|
||||||
|
"type": "basic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
docs/swagger.yaml
Normal file
19
docs/swagger.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
basePath: /api/v1
|
||||||
|
host: localhost:8080
|
||||||
|
info:
|
||||||
|
contact:
|
||||||
|
email: support@swagger.io
|
||||||
|
name: API Support
|
||||||
|
url: http://www.swagger.io/support
|
||||||
|
description: 58team blog's backend
|
||||||
|
license:
|
||||||
|
name: Apache 2.0
|
||||||
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
termsOfService: http://swagger.io/terms/
|
||||||
|
title: 58team blog backend
|
||||||
|
version: "1.0"
|
||||||
|
paths: {}
|
||||||
|
securityDefinitions:
|
||||||
|
BasicAuth:
|
||||||
|
type: basic
|
||||||
|
swagger: "2.0"
|
||||||
297
etc/swagger/config.yml
Normal file
297
etc/swagger/config.yml
Normal file
|
|
@ -0,0 +1,297 @@
|
||||||
|
openapi: 3.0.4
|
||||||
|
info:
|
||||||
|
title: 58TeamBlog
|
||||||
|
version: "1.0"
|
||||||
|
servers:
|
||||||
|
- url: https://58team.ru/api/v1/
|
||||||
|
tags:
|
||||||
|
- name: admin
|
||||||
|
description: Routes that can be accessed only from localhost
|
||||||
|
- name: user
|
||||||
|
description: Admin user
|
||||||
|
- name: post
|
||||||
|
description: Blog's post
|
||||||
|
- name: posts
|
||||||
|
description: Glue for posts and users
|
||||||
|
paths:
|
||||||
|
/post:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- admin
|
||||||
|
summary: Update an existing post.
|
||||||
|
description: Update an existing post by Id.
|
||||||
|
operationId: updatePost
|
||||||
|
requestBody:
|
||||||
|
description: Update an existent post
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Post not found
|
||||||
|
'422':
|
||||||
|
description: Validation exception
|
||||||
|
default:
|
||||||
|
description: Unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
security:
|
||||||
|
- blog_auth:
|
||||||
|
- write:post
|
||||||
|
- read:post
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- admin
|
||||||
|
summary: Add a new post to the blog.
|
||||||
|
description: Add a new post to the blog.
|
||||||
|
operationId: addPost
|
||||||
|
requestBody:
|
||||||
|
description: Create a new post in the blog
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/CreatePost'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
'400':
|
||||||
|
description: Invalid input
|
||||||
|
'422':
|
||||||
|
description: Validation exception
|
||||||
|
default:
|
||||||
|
description: Unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
security:
|
||||||
|
- blog_auth:
|
||||||
|
- write:post
|
||||||
|
- read:post
|
||||||
|
/post/user/{name}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- post
|
||||||
|
summary: Finds Posts by user name.
|
||||||
|
description: Finds all posts made by user.
|
||||||
|
operationId: findPostsByName
|
||||||
|
parameters:
|
||||||
|
- name: name
|
||||||
|
in: path
|
||||||
|
description: Get all posts by author
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
'400':
|
||||||
|
description: Invalid status value
|
||||||
|
default:
|
||||||
|
description: Unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
/post/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- post
|
||||||
|
summary: Get post by id.
|
||||||
|
description: Get post by id.
|
||||||
|
operationId: getPostById
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
description: Post id
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
'400':
|
||||||
|
description: Invalid status value
|
||||||
|
default:
|
||||||
|
description: Unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
/posts:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- posts
|
||||||
|
summary: Get first 5 posts.
|
||||||
|
description: Get first 5 posts.
|
||||||
|
operationId: getPosts
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
default:
|
||||||
|
description: Unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
/posts/{offset}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- posts
|
||||||
|
summary: Get 5 posts after %offset% posts.
|
||||||
|
description: Get 5 posts after %offset% posts.
|
||||||
|
operationId: getPostsOffset
|
||||||
|
parameters:
|
||||||
|
- name: offset
|
||||||
|
in: path
|
||||||
|
description: Offset of posts since begin.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
/users:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- admin
|
||||||
|
- users
|
||||||
|
summary: Get all users.
|
||||||
|
description: Get all users.
|
||||||
|
operationId: getUsers
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
security:
|
||||||
|
- blog_auth:
|
||||||
|
- read:user
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
User:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
example: "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
example: UserName
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
format: password
|
||||||
|
example: '$2a$12$bC0iX7kweYs0eGe4RM5oe.TKFfxzvE.s9Hp0v.rY.7BofYMWdqU72'
|
||||||
|
CreatePost:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
example: 'Post title'
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
example: "Short content description."
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
example: "Some content text."
|
||||||
|
Post:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
example: "f47ac10b-58cc-4372-a567-0e02b4f5d479"
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
example: 'Post title'
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
example: "Short content description."
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
example: "Some content text."
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
|
||||||
|
Error:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- code
|
||||||
|
- message
|
||||||
|
|
||||||
|
requestBodies:
|
||||||
|
Post:
|
||||||
|
description: Post object that needs to be added
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Post'
|
||||||
|
|
||||||
|
securitySchemes:
|
||||||
|
blog_auth:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: https://58team.ru/auth
|
||||||
|
scopes:
|
||||||
|
"write:post": modify posts in your account
|
||||||
|
"read:post": read your posts
|
||||||
|
"write:user": modify users
|
||||||
|
"read:user": read users
|
||||||
|
api_key:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key
|
||||||
|
in: header
|
||||||
67
go.mod
Normal file
67
go.mod
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
module 58team_blog
|
||||||
|
|
||||||
|
go 1.25.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||||
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||||
|
github.com/bytedance/sonic v1.14.1 // indirect
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||||
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
|
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||||
|
github.com/creasty/defaults v1.8.0 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||||
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
|
github.com/gin-gonic/gin v1.10.1 // indirect
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||||
|
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||||
|
github.com/go-openapi/spec v0.20.4 // indirect
|
||||||
|
github.com/go-openapi/swag v0.19.15 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||||
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
|
github.com/golang-migrate/migrate v3.5.4+incompatible // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/jmoiron/sqlx v1.4.0 // indirect
|
||||||
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
github.com/lib/pq v1.10.9 // indirect
|
||||||
|
github.com/mailru/easyjson v0.7.6 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
|
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||||
|
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||||
|
github.com/spf13/afero v1.15.0 // indirect
|
||||||
|
github.com/spf13/cast v1.10.0 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
|
github.com/spf13/viper v1.21.0 // indirect
|
||||||
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
|
github.com/swaggo/files v1.0.1 // indirect
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1 // indirect
|
||||||
|
github.com/swaggo/swag v1.16.6 // indirect
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
|
golang.org/x/arch v0.21.0 // indirect
|
||||||
|
golang.org/x/crypto v0.42.0 // indirect
|
||||||
|
golang.org/x/mod v0.27.0 // indirect
|
||||||
|
golang.org/x/net v0.43.0 // indirect
|
||||||
|
golang.org/x/sync v0.17.0 // indirect
|
||||||
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
|
golang.org/x/text v0.29.0 // indirect
|
||||||
|
golang.org/x/tools v0.36.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.36.8 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
gopkg.org/generic v1.0.0 // indirect
|
||||||
|
gopkg.org/swaggerui v1.2.0 // indirect
|
||||||
|
)
|
||||||
192
go.sum
Normal file
192
go.sum
Normal file
|
|
@ -0,0 +1,192 @@
|
||||||
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||||
|
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
|
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||||
|
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||||
|
github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w=
|
||||||
|
github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc=
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||||
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
|
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||||
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||||
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
|
github.com/creasty/defaults v1.8.0 h1:z27FJxCAa0JKt3utc0sCImAEb+spPucmKoOdLHvHYKk=
|
||||||
|
github.com/creasty/defaults v1.8.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
|
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||||
|
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
|
||||||
|
github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M=
|
||||||
|
github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
|
||||||
|
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||||
|
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
|
||||||
|
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||||
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||||
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
|
github.com/golang-migrate/migrate v3.5.4+incompatible h1:R7OzwvCJTCgwapPCiX6DyBiu2czIUMDCB118gFTKTUA=
|
||||||
|
github.com/golang-migrate/migrate v3.5.4+incompatible/go.mod h1:IsVUlFN5puWOmXrqjgGUfIRIbU7mr8oNBE2tyERd9Wk=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||||
|
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
||||||
|
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||||
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||||
|
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||||
|
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||||
|
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||||
|
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||||
|
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||||
|
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||||
|
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||||
|
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||||
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||||
|
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
|
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||||
|
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||||
|
github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
|
||||||
|
github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
|
||||||
|
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||||
|
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
|
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||||
|
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
|
golang.org/x/arch v0.21.0 h1:iTC9o7+wP6cPWpDWkivCvQFGAHDQ59SrSxsLPcnkArw=
|
||||||
|
golang.org/x/arch v0.21.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||||
|
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
|
||||||
|
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||||
|
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||||
|
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
|
||||||
|
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
|
||||||
|
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.org/generic v1.0.0 h1:Fl6XgPtPihYOpKB1N3Dlv++uufZOCtRDZZtC5LdIZSw=
|
||||||
|
gopkg.org/generic v1.0.0/go.mod h1:6Bqr4wuM03sedAI02RtZs/eqrXiOoz8DLfGkln4hYTs=
|
||||||
|
gopkg.org/swaggerui v1.2.0 h1:mJMeF9ZaThmC4xpjyH3/s0b2Wm18VUc4r6TSpiwVD14=
|
||||||
|
gopkg.org/swaggerui v1.2.0/go.mod h1:4t+ObN66rcd4Qc47XGli78H/dyeYUApzz5MohlInApc=
|
||||||
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||||
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||||
5
internal/application/commands/create_image_command.go
Normal file
5
internal/application/commands/create_image_command.go
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
type CreateImageCommand struct {
|
||||||
|
Path string
|
||||||
|
}
|
||||||
10
internal/application/commands/create_post_command.go
Normal file
10
internal/application/commands/create_post_command.go
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type CreatePostCommand struct {
|
||||||
|
UserId uuid.UUID
|
||||||
|
Title string
|
||||||
|
Description string
|
||||||
|
Content string
|
||||||
|
}
|
||||||
8
internal/application/commands/create_posts_command.go
Normal file
8
internal/application/commands/create_posts_command.go
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type CreatePostsCommand struct {
|
||||||
|
PostId uuid.UUID
|
||||||
|
UserId uuid.UUID
|
||||||
|
}
|
||||||
6
internal/application/commands/create_user_command.go
Normal file
6
internal/application/commands/create_user_command.go
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
type CreateUserCommand struct {
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
7
internal/application/commands/delete_image_command.go
Normal file
7
internal/application/commands/delete_image_command.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type DeleteImageCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
7
internal/application/commands/delete_post_command.go
Normal file
7
internal/application/commands/delete_post_command.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type DeletePostCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
7
internal/application/commands/delete_posts_command.go
Normal file
7
internal/application/commands/delete_posts_command.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type DeletePostsCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
7
internal/application/commands/delete_user_command.go
Normal file
7
internal/application/commands/delete_user_command.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type DeleteUserCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
10
internal/application/commands/update_post_command.go
Normal file
10
internal/application/commands/update_post_command.go
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type UpdatePostCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
Title string
|
||||||
|
Description string
|
||||||
|
Content string
|
||||||
|
}
|
||||||
9
internal/application/commands/update_user_command.go
Normal file
9
internal/application/commands/update_user_command.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type UpdateUserCommand struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
8
internal/application/common/image_result.go
Normal file
8
internal/application/common/image_result.go
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type ImageResult struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
Path string
|
||||||
|
}
|
||||||
21
internal/application/common/post_result.go
Normal file
21
internal/application/common/post_result.go
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostResult struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
UserId uuid.UUID
|
||||||
|
Title string
|
||||||
|
Description string
|
||||||
|
Content string
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostResultList struct {
|
||||||
|
Result []*PostResult
|
||||||
|
}
|
||||||
13
internal/application/common/posts_result.go
Normal file
13
internal/application/common/posts_result.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type PostsResult struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
UserId uuid.UUID
|
||||||
|
PostId uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostsResultList struct {
|
||||||
|
Result []*PostsResult
|
||||||
|
}
|
||||||
13
internal/application/common/user_result.go
Normal file
13
internal/application/common/user_result.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type UserResult struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
UserName string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserResultList struct {
|
||||||
|
Result []*UserResult
|
||||||
|
}
|
||||||
13
internal/application/interfaces/images_service.go
Normal file
13
internal/application/interfaces/images_service.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package interfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImagesService interface {
|
||||||
|
Create(commands.CreateImageCommand) (*common.ImageResult, error)
|
||||||
|
FindById(queries.ImageFindByIdQuery) (*queries.ImageFindByIdResult, error)
|
||||||
|
Delete(commands.DeleteImageCommand) error
|
||||||
|
}
|
||||||
16
internal/application/interfaces/post_service.go
Normal file
16
internal/application/interfaces/post_service.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package interfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostService interface {
|
||||||
|
Create(commands.CreatePostCommand) (*common.PostResult, error)
|
||||||
|
FindById(queries.PostFindByIdQuery) (*queries.PostFindByIdResult, error)
|
||||||
|
FindAllByUserName(queries.PostFindAllByUserNameQuery) (*queries.PostFindAllByUserNameResult, error)
|
||||||
|
GetAll() (*queries.PostGetAllResult, error)
|
||||||
|
Update(commands.UpdatePostCommand) (*common.PostResult, error)
|
||||||
|
Delete(commands.DeletePostCommand) error
|
||||||
|
}
|
||||||
16
internal/application/interfaces/posts_service.go
Normal file
16
internal/application/interfaces/posts_service.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package interfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsService interface {
|
||||||
|
Create(commands.CreatePostsCommand) (*common.PostsResult, error)
|
||||||
|
FindByUserId(queries.PostsFindByUserIdQuery) (*queries.PostsFindByUserIdResult, error)
|
||||||
|
FindByPostId(queries.PostsFindByPostIdQuery) (*queries.PostsFindByPostIdResult, error)
|
||||||
|
FindAllByUserId(queries.PostsFindByUserIdQuery) (*queries.PostsFindAllByUserIdResult, error)
|
||||||
|
GetAll() (queries.PostsGetAllResult, error)
|
||||||
|
Delete(commands.DeletePostsCommand) error
|
||||||
|
}
|
||||||
16
internal/application/interfaces/user_service.go
Normal file
16
internal/application/interfaces/user_service.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package interfaces
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserService interface {
|
||||||
|
Create(commands.CreateUserCommand) (*common.UserResult, error)
|
||||||
|
FindById(queries.UserFindByIdQuery) (*queries.UserFindByIdResult, error)
|
||||||
|
FindByName(queries.UserFindByNameQuery) (*queries.UserFindByNameResult, error)
|
||||||
|
GetAll() (*queries.UserGetAllResult, error)
|
||||||
|
Update(commands.UpdateUserCommand) (*common.UserResult, error)
|
||||||
|
Delete(commands.DeleteUserCommand) error
|
||||||
|
}
|
||||||
20
internal/application/mapper/image_result.go
Normal file
20
internal/application/mapper/image_result.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
package mapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateImageResultFromEntity(entity *entities.Images) *common.ImageResult {
|
||||||
|
return &common.ImageResult{
|
||||||
|
Id: entity.Id,
|
||||||
|
Path: entity.Path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateImageFindByIdResultFromEntity(entity *entities.Images) *queries.ImageFindByIdResult {
|
||||||
|
return &queries.ImageFindByIdResult{
|
||||||
|
Result: CreateImageResultFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
47
internal/application/mapper/post_result.go
Normal file
47
internal/application/mapper/post_result.go
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
package mapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreatePostResultFromEntity(entity *entities.Post) *common.PostResult {
|
||||||
|
return &common.PostResult{
|
||||||
|
Id: entity.Id,
|
||||||
|
UserId: entity.UserId,
|
||||||
|
Title: entity.Title,
|
||||||
|
Description: entity.Description,
|
||||||
|
Content: entity.Content,
|
||||||
|
CreatedAt: entity.CreatedAt,
|
||||||
|
UpdatedAt: entity.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostResultListFromEntity(entity_list []*entities.Post) *common.PostResultList {
|
||||||
|
var result common.PostResultList
|
||||||
|
|
||||||
|
for _, e := range entity_list {
|
||||||
|
result.Result = append(result.Result, CreatePostResultFromEntity(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostFindByIdResultFromEntity(entity entities.Post) *queries.PostFindByIdResult {
|
||||||
|
return &queries.PostFindByIdResult{
|
||||||
|
Result: CreatePostResultFromEntity(&entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostFindAllByUserNameResult(entity []*entities.Post) *queries.PostFindAllByUserNameResult {
|
||||||
|
return &queries.PostFindAllByUserNameResult{
|
||||||
|
Result: CreatePostResultListFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostGetAllResult(entity_list []*entities.Post) *queries.PostGetAllResult {
|
||||||
|
return &queries.PostGetAllResult{
|
||||||
|
Result: CreatePostResultListFromEntity(entity_list),
|
||||||
|
}
|
||||||
|
}
|
||||||
48
internal/application/mapper/posts_result.go
Normal file
48
internal/application/mapper/posts_result.go
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package mapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreatePostsResultFromEntity(entity *entities.Posts) *common.PostsResult {
|
||||||
|
return &common.PostsResult{
|
||||||
|
Id: entity.Id,
|
||||||
|
UserId: entity.UserId,
|
||||||
|
PostId: entity.PostId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsResultListFromEntityList(entity_list []*entities.Posts) *common.PostsResultList {
|
||||||
|
var result common.PostsResultList
|
||||||
|
for _, e := range entity_list {
|
||||||
|
result.Result = append(result.Result, CreatePostsResultFromEntity(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsFindByUserIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByUserIdResult {
|
||||||
|
return &queries.PostsFindByUserIdResult{
|
||||||
|
Result: CreatePostsResultFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsFindByPostIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByPostIdResult {
|
||||||
|
return &queries.PostsFindByPostIdResult{
|
||||||
|
Result: CreatePostsResultFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsFindAllByUserIdResultFromEntity(entity_list []*entities.Posts) *queries.PostsFindAllByUserIdResult {
|
||||||
|
return &queries.PostsFindAllByUserIdResult{
|
||||||
|
Result: CreatePostsResultListFromEntityList(entity_list),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsGetAllResultFromEntity(entity_list []*entities.Posts) *queries.PostsGetAllResult {
|
||||||
|
return &queries.PostsGetAllResult{
|
||||||
|
Result: CreatePostsResultListFromEntityList(entity_list),
|
||||||
|
}
|
||||||
|
}
|
||||||
43
internal/application/mapper/user_result.go
Normal file
43
internal/application/mapper/user_result.go
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
package mapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateUserResultFromEntity(entity *entities.User) *common.UserResult {
|
||||||
|
return &common.UserResult{
|
||||||
|
Id: entity.Id,
|
||||||
|
UserName: entity.UserName,
|
||||||
|
Password: entity.Password,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUserResultListFromEntity(entityList []*entities.User) *common.UserResultList {
|
||||||
|
var result common.UserResultList
|
||||||
|
|
||||||
|
for _, e := range entityList {
|
||||||
|
result.Result = append(result.Result, CreateUserResultFromEntity(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUserFindByIdResultFromEntity(entity *entities.User) *queries.UserFindByIdResult {
|
||||||
|
return &queries.UserFindByIdResult{
|
||||||
|
Result: CreateUserResultFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUserFindByNameResultFromEntity(entity *entities.User) *queries.UserFindByNameResult {
|
||||||
|
return &queries.UserFindByNameResult{
|
||||||
|
Result: CreateUserResultFromEntity(entity),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUserGetAllResultFromEntity(entity_list []*entities.User) *queries.UserGetAllResult {
|
||||||
|
return &queries.UserGetAllResult{
|
||||||
|
Result: CreateUserResultListFromEntity(entity_list),
|
||||||
|
}
|
||||||
|
}
|
||||||
15
internal/application/queries/image_find_by_id.go
Normal file
15
internal/application/queries/image_find_by_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImageFindByIdQuery struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageFindByIdResult struct {
|
||||||
|
Result *common.ImageResult
|
||||||
|
}
|
||||||
11
internal/application/queries/post_find_all_by_user_name.go
Normal file
11
internal/application/queries/post_find_all_by_user_name.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import "58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
type PostFindAllByUserNameQuery struct {
|
||||||
|
UserName string
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostFindAllByUserNameResult struct {
|
||||||
|
Result *common.PostResultList
|
||||||
|
}
|
||||||
15
internal/application/queries/post_find_by_id.go
Normal file
15
internal/application/queries/post_find_by_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostFindByIdQuery struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostFindByIdResult struct {
|
||||||
|
Result *common.PostResult
|
||||||
|
}
|
||||||
7
internal/application/queries/post_get_all.go
Normal file
7
internal/application/queries/post_get_all.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import "58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
type PostGetAllResult struct {
|
||||||
|
Result *common.PostResultList
|
||||||
|
}
|
||||||
15
internal/application/queries/posts_find_all_by_user_id.go
Normal file
15
internal/application/queries/posts_find_all_by_user_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsFindAllByUserIdQuery struct {
|
||||||
|
UserId uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostsFindAllByUserIdResult struct {
|
||||||
|
Result *common.PostsResultList
|
||||||
|
}
|
||||||
15
internal/application/queries/posts_find_by_post_id.go
Normal file
15
internal/application/queries/posts_find_by_post_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsFindByPostIdQuery struct {
|
||||||
|
PostId uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostsFindByPostIdResult struct {
|
||||||
|
Result *common.PostsResult
|
||||||
|
}
|
||||||
15
internal/application/queries/posts_find_by_user_id.go
Normal file
15
internal/application/queries/posts_find_by_user_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsFindByUserIdQuery struct {
|
||||||
|
UserId uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostsFindByUserIdResult struct {
|
||||||
|
Result *common.PostsResult
|
||||||
|
}
|
||||||
7
internal/application/queries/posts_get_all.go
Normal file
7
internal/application/queries/posts_get_all.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import "58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
type PostsGetAllResult struct {
|
||||||
|
Result *common.PostsResultList
|
||||||
|
}
|
||||||
15
internal/application/queries/user_find_by_id.go
Normal file
15
internal/application/queries/user_find_by_id.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserFindByIdQuery struct {
|
||||||
|
Id uuid.UUID
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserFindByIdResult struct {
|
||||||
|
Result *common.UserResult
|
||||||
|
}
|
||||||
11
internal/application/queries/user_find_by_name.go
Normal file
11
internal/application/queries/user_find_by_name.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import "58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
type UserFindByNameQuery struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserFindByNameResult struct {
|
||||||
|
Result *common.UserResult
|
||||||
|
}
|
||||||
7
internal/application/queries/user_get_all.go
Normal file
7
internal/application/queries/user_get_all.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import "58team_blog/internal/application/common"
|
||||||
|
|
||||||
|
type UserGetAllResult struct {
|
||||||
|
Result *common.UserResultList
|
||||||
|
}
|
||||||
72
internal/application/services/images_service.go
Normal file
72
internal/application/services/images_service.go
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/mapper"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
"58team_blog/internal/domain/repository"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImagesService struct {
|
||||||
|
repo repository.ImagesRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewImagesService(repo repository.ImagesRepository) ImagesService {
|
||||||
|
return ImagesService{
|
||||||
|
repo: repo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ImagesService) Create(cmd commands.CreateImageCommand) (*common.ImageResult, error) {
|
||||||
|
entity, err := entities.CreateImage(cmd.Path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.repo.Create(&entity); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateImageResultFromEntity(&entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ImagesService) FindById(query queries.ImageFindByIdQuery) (*queries.ImageFindByIdResult, error) {
|
||||||
|
entity, err := s.repo.FindById(query.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateImageFindByIdResultFromEntity(entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ImagesService) Delete(cmd commands.DeleteImageCommand) error {
|
||||||
|
entity, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Image delete error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.repo.Delete(entity.Id); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
130
internal/application/services/post_service.go
Normal file
130
internal/application/services/post_service.go
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/mapper"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
"58team_blog/internal/domain/repository"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostService struct {
|
||||||
|
repo repository.PostRepository
|
||||||
|
postsService PostsService
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostService(repo repository.PostRepository, postsService PostsService) PostService {
|
||||||
|
return PostService{
|
||||||
|
repo: repo,
|
||||||
|
postsService: postsService,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) Create(cmd commands.CreatePostCommand) (*common.PostResult, error) {
|
||||||
|
entity, err := entities.CreatePost(cmd.UserId, cmd.Title, cmd.Description, cmd.Content)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
post, err := s.repo.Create(&entity)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostResultFromEntity(post)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) FindById(query queries.PostFindByIdQuery) (*queries.PostFindByIdResult, error) {
|
||||||
|
post, err := s.repo.FindById(query.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := post.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostFindByIdResultFromEntity(*post)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) FindAllByUserName(query queries.PostFindAllByUserNameQuery) (*queries.PostFindAllByUserNameResult, error) {
|
||||||
|
posts, err := s.repo.FindAllByUserName(query.UserName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range posts {
|
||||||
|
if err := p.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostFindAllByUserNameResult(posts)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) GetAll() (*queries.PostGetAllResult, error) {
|
||||||
|
posts, err := s.repo.GetAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range posts {
|
||||||
|
if err := p.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostGetAllResult(posts)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) Update(cmd commands.UpdatePostCommand) (*common.PostResult, error) {
|
||||||
|
post, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := post.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
post.Title = cmd.Title
|
||||||
|
post.Description = cmd.Description
|
||||||
|
post.Content = cmd.Content
|
||||||
|
post.UpdatedAt = time.Now()
|
||||||
|
|
||||||
|
if err := post.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostResultFromEntity(post)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostService) Delete(cmd commands.DeletePostCommand) error {
|
||||||
|
post, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := post.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.repo.Delete(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
141
internal/application/services/posts_service.go
Normal file
141
internal/application/services/posts_service.go
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/mapper"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
"58team_blog/internal/domain/repository"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsService struct {
|
||||||
|
repo repository.PostsRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePostsService(repo repository.PostsRepository) PostsService {
|
||||||
|
return PostsService{
|
||||||
|
repo: repo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) Create(cmd commands.CreatePostsCommand) (*common.PostsResult, error) {
|
||||||
|
if user, err := s.repo.FindByPostId(cmd.PostId); user != nil {
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("Posts already exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
entity, err := entities.CreatePosts(cmd.UserId, cmd.PostId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostsResultFromEntity(&entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) FindByUserId(query queries.PostsFindByUserIdQuery) (*queries.PostsFindByUserIdResult, error) {
|
||||||
|
entity, err := s.repo.FindByUserId(query.UserId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity == nil {
|
||||||
|
return nil, errors.New("Posts not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostsFindByUserIdResultFromEntity(entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) FindByPostId(query queries.PostsFindByPostIdQuery) (*queries.PostsFindByPostIdResult, error) {
|
||||||
|
entity, err := s.repo.FindByPostId(query.PostId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity == nil {
|
||||||
|
return nil, errors.New("Posts not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostsFindByPostIdResultFromEntity(entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) FindAllByUserId(query queries.PostsFindByUserIdQuery) (*queries.PostsFindAllByUserIdResult, error) {
|
||||||
|
entities, err := s.repo.FindAllByUserId(query.UserId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if entities == nil {
|
||||||
|
return nil, fmt.Errorf("No posts owned by user: %s", query.UserId.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range entities {
|
||||||
|
if err := e.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostsFindAllByUserIdResultFromEntity(entities)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) GetAll() (*queries.PostsGetAllResult, error) {
|
||||||
|
entities, err := s.repo.GetAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range entities {
|
||||||
|
if err := e.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreatePostsGetAllResultFromEntity(entities)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PostsService) Delete(cmd commands.DeletePostsCommand) error {
|
||||||
|
entity, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity == nil {
|
||||||
|
return fmt.Errorf("Posts row not found: %s", cmd.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.repo.Delete(cmd.Id); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
145
internal/application/services/user_service.go
Normal file
145
internal/application/services/user_service.go
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/application/commands"
|
||||||
|
"58team_blog/internal/application/common"
|
||||||
|
"58team_blog/internal/application/mapper"
|
||||||
|
"58team_blog/internal/application/queries"
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
"58team_blog/internal/domain/repository"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserService struct {
|
||||||
|
repo repository.UsersRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserService(repo repository.UsersRepository) UserService {
|
||||||
|
return UserService{
|
||||||
|
repo: repo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) Create(cmd commands.CreateUserCommand) (*common.UserResult, error) {
|
||||||
|
// Check user with given name exists
|
||||||
|
{
|
||||||
|
user, err := s.repo.FindByName(cmd.Username)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if user != nil {
|
||||||
|
return nil, fmt.Errorf("User: %s already exists", user.UserName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new user
|
||||||
|
user, err := entities.CreateUser(cmd.Username, cmd.Password)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := user.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
entity, err := s.repo.Create(&user)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateUserResultFromEntity(entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) FindById(query queries.UserFindByIdQuery) (*queries.UserFindByIdResult, error) {
|
||||||
|
entity, err := s.repo.FindById(query.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateUserFindByIdResultFromEntity(entity)
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) FindByName(query queries.UserFindByNameQuery) (*queries.UserFindByNameResult, error) {
|
||||||
|
entity, err := s.repo.FindByName(query.Name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateUserFindByNameResultFromEntity(entity)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) GetAll() (*queries.UserGetAllResult, error) {
|
||||||
|
entityList, err := s.repo.GetAll()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range entityList {
|
||||||
|
if err := e.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateUserGetAllResultFromEntity(entityList)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) Update(cmd commands.UpdateUserCommand) (*common.UserResult, error) {
|
||||||
|
entity, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Username != entity.UserName {
|
||||||
|
return nil, errors.New("You cannot change user name")
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.Password = cmd.Password
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.repo.Update(entity); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := mapper.CreateUserResultFromEntity(entity)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserService) Delete(cmd commands.DeleteUserCommand) error {
|
||||||
|
entity, err := s.repo.FindById(cmd.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := entity.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.repo.Delete(entity.Id); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
33
internal/domain/entities/images.go
Normal file
33
internal/domain/entities/images.go
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ImagesTable = "images"
|
||||||
|
|
||||||
|
type Images struct {
|
||||||
|
Id uuid.UUID `db:"id"`
|
||||||
|
Path string `db:"path"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateImage(path string) (image Images, err error) {
|
||||||
|
image = Images{
|
||||||
|
Id: uuid.New(),
|
||||||
|
Path: path,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = image.Validate()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Images) Validate() error {
|
||||||
|
if i.Path == "" {
|
||||||
|
return errors.New("Empty image.path")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
68
internal/domain/entities/post.go
Normal file
68
internal/domain/entities/post.go
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const PostTable = "post"
|
||||||
|
|
||||||
|
type Post struct {
|
||||||
|
Id uuid.UUID `db:"id"`
|
||||||
|
UserId uuid.UUID `db:"user_id"`
|
||||||
|
Title string `db:"title"`
|
||||||
|
Description string `db:"description"`
|
||||||
|
Content string `db:"content"`
|
||||||
|
CreatedAt time.Time `db:"createdAt"`
|
||||||
|
UpdatedAt time.Time `db:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePost(userId uuid.UUID, title string, description string, content string) (post Post, err error) {
|
||||||
|
post = Post{
|
||||||
|
Id: uuid.New(),
|
||||||
|
UserId: userId,
|
||||||
|
Title: title,
|
||||||
|
Description: description,
|
||||||
|
Content: content,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
err = post.Validate()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Post) Validate() error {
|
||||||
|
if err := uuid.Validate(p.Id.String()); err != nil {
|
||||||
|
return errors.New("Empty post.id")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := uuid.Validate(p.UserId.String()); err != nil {
|
||||||
|
return errors.New("Empty post.userId")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Title == "" {
|
||||||
|
return errors.New("Empty post.title")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Description == "" {
|
||||||
|
return errors.New("Empty post.description")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Content == "" {
|
||||||
|
return errors.New("Empty post.content path")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.CreatedAt.IsZero() {
|
||||||
|
return errors.New("Empty post.createdAt")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.UpdatedAt.IsZero() {
|
||||||
|
return errors.New("Empty post.updatedAt")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
43
internal/domain/entities/posts.go
Normal file
43
internal/domain/entities/posts.go
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const PostsTable = "posts"
|
||||||
|
|
||||||
|
type Posts struct {
|
||||||
|
Id uuid.UUID `db:"id"`
|
||||||
|
UserId uuid.UUID `db:"user_id"`
|
||||||
|
PostId uuid.UUID `db:"post_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePosts(userId uuid.UUID, postId uuid.UUID) (posts Posts, err error) {
|
||||||
|
posts = Posts{
|
||||||
|
Id: uuid.New(),
|
||||||
|
UserId: userId,
|
||||||
|
PostId: postId,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = posts.Validate()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Posts) Validate() error {
|
||||||
|
if err := uuid.Validate(p.Id.String()); err != nil {
|
||||||
|
return errors.New("Invalid posts.id")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := uuid.Validate(p.UserId.String()); err != nil {
|
||||||
|
return errors.New("Invalid posts.userId")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := uuid.Validate(p.PostId.String()); err != nil {
|
||||||
|
return errors.New("Invalid posts.postId")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
42
internal/domain/entities/user.go
Normal file
42
internal/domain/entities/user.go
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package entities
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const UserTable = "users"
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Id uuid.UUID `db:"id"`
|
||||||
|
UserName string `db:"username"`
|
||||||
|
Password string `db:"password"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUser(userName string, password string) (user User, err error) {
|
||||||
|
user = User{
|
||||||
|
Id: uuid.New(),
|
||||||
|
UserName: userName,
|
||||||
|
Password: password,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = user.Validate()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) Validate() error {
|
||||||
|
if err := uuid.Validate(u.Id.String()); err != nil {
|
||||||
|
return errors.New("Invalid user.id")
|
||||||
|
}
|
||||||
|
if u.UserName == "" {
|
||||||
|
return errors.New("Empty user.name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if u.Password == "" {
|
||||||
|
return errors.New("Empty user.password")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
13
internal/domain/repository/images_repo.go
Normal file
13
internal/domain/repository/images_repo.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImagesRepository interface {
|
||||||
|
Create(*entities.Images) error
|
||||||
|
FindById(uuid.UUID) (*entities.Images, error)
|
||||||
|
Delete(uuid.UUID) error
|
||||||
|
}
|
||||||
16
internal/domain/repository/post_repo.go
Normal file
16
internal/domain/repository/post_repo.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostRepository interface {
|
||||||
|
Create(*entities.Post) (*entities.Post, error)
|
||||||
|
FindById(uuid.UUID) (*entities.Post, error)
|
||||||
|
FindAllByUserName(string) ([]*entities.Post, error)
|
||||||
|
GetAll() ([]*entities.Post, error)
|
||||||
|
Update(*entities.Post) error
|
||||||
|
Delete(uuid.UUID) error
|
||||||
|
}
|
||||||
17
internal/domain/repository/posts_repo.go
Normal file
17
internal/domain/repository/posts_repo.go
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostsRepository interface {
|
||||||
|
Create(*entities.Posts) (*entities.Posts, error)
|
||||||
|
FindById(uuid.UUID) (*entities.Posts, error)
|
||||||
|
FindByPostId(uuid.UUID) (*entities.Posts, error)
|
||||||
|
FindByUserId(uuid.UUID) (*entities.Posts, error)
|
||||||
|
FindAllByUserId(uuid.UUID) ([]*entities.Posts, error)
|
||||||
|
GetAll() ([]*entities.Posts, error)
|
||||||
|
Delete(uuid.UUID) error
|
||||||
|
}
|
||||||
16
internal/domain/repository/user_repo.go
Normal file
16
internal/domain/repository/user_repo.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"58team_blog/internal/domain/entities"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UsersRepository interface {
|
||||||
|
Create(*entities.User) (*entities.User, error)
|
||||||
|
FindById(uuid.UUID) (*entities.User, error)
|
||||||
|
FindByName(string) (*entities.User, error)
|
||||||
|
GetAll() ([]*entities.User, error)
|
||||||
|
Update(*entities.User) error
|
||||||
|
Delete(uuid.UUID) error
|
||||||
|
}
|
||||||
41
internal/infrastructure/config.go
Normal file
41
internal/infrastructure/config.go
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
package infrastructure
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/creasty/defaults"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
DBUser string `mapstructure:"db-user" default:"userpg"`
|
||||||
|
DBName string `mapstructure:"db-name" default:"58blog"`
|
||||||
|
DBPass string `mapstructure:"db-password" default:"1205"`
|
||||||
|
DBHost string `mapstructure:"db-host" default:"localhost"`
|
||||||
|
DBPort string `mapstructure:"db-port" default:"5432"`
|
||||||
|
AdminName string `mapstructure:"admin_name" default:"muts"`
|
||||||
|
AdminPassword string `mapstructure:"admin_pass" default:"1205"`
|
||||||
|
ImagesPath string `mapstructure:"images_path" default:"./images/"`
|
||||||
|
PostsPath string `mapstructure:"posts_path" default:"./posts/"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadConfig() (config Config, err error) {
|
||||||
|
config = Config{}
|
||||||
|
if err = defaults.Set(config); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
|
viper.AddConfigPath(".")
|
||||||
|
viper.AddConfigPath("/etc/58team_blog/")
|
||||||
|
viper.AddConfigPath("/58team_blog/cfgs/")
|
||||||
|
|
||||||
|
if err = viper.ReadInConfig(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = viper.Unmarshal(&config); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
19
internal/infrastructure/db.go
Normal file
19
internal/infrastructure/db.go
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
package infrastructure
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Database struct {
|
||||||
|
connection *sqlx.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func DatabaseInit(config Config) (db Database, err error) {
|
||||||
|
db = Database{}
|
||||||
|
db_setup := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s", config.DBUser, config.DBPass, config.DBHost, config.DBPort, config.DBName)
|
||||||
|
db.connection, err = sqlx.Connect("postgres", db_setup)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
20
internal/infrastructure/infrastructure.go
Normal file
20
internal/infrastructure/infrastructure.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
package infrastructure
|
||||||
|
|
||||||
|
type Infrastructure struct {
|
||||||
|
Config Config
|
||||||
|
Db Database
|
||||||
|
}
|
||||||
|
|
||||||
|
func InfrastructureInit() (infra Infrastructure, err error) {
|
||||||
|
infra = Infrastructure{}
|
||||||
|
|
||||||
|
if infra.Config, err = LoadConfig(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if infra.Db, err = DatabaseInit(infra.Config); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
1
internal/infrastructure/jaeger.go
Normal file
1
internal/infrastructure/jaeger.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package infrastructure
|
||||||
1
internal/interfaces/api/images_controller.go
Normal file
1
internal/interfaces/api/images_controller.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package api
|
||||||
1
internal/interfaces/api/post_controller.go
Normal file
1
internal/interfaces/api/post_controller.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package api
|
||||||
1
internal/interfaces/api/user_controller.go
Normal file
1
internal/interfaces/api/user_controller.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package api
|
||||||
1
internal/interfaces/route.go
Normal file
1
internal/interfaces/route.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package interfaces
|
||||||
47
migrations/create.sql
Normal file
47
migrations/create.sql
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
CREATE TABLE "users" (
|
||||||
|
"id" TEXT NOT NULL UNIQUE,
|
||||||
|
"username" VARCHAR(255) UNIQUE,
|
||||||
|
"password" VARCHAR(255),
|
||||||
|
PRIMARY KEY("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "post" (
|
||||||
|
"id" TEXT NOT NULL UNIQUE,
|
||||||
|
"title" TEXT,
|
||||||
|
"description" TEXT,
|
||||||
|
"content" TEXT,
|
||||||
|
"createdAt" TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP,
|
||||||
|
PRIMARY KEY("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "posts" (
|
||||||
|
"id" TEXT NOT NULL UNIQUE,
|
||||||
|
"user_id" INTEGER,
|
||||||
|
"post_id" INTEGER,
|
||||||
|
PRIMARY KEY("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "images" (
|
||||||
|
"id" TEXT NOT NULL UNIQUE,
|
||||||
|
"path" TEXT,
|
||||||
|
PRIMARY KEY("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE "users"
|
||||||
|
ADD FOREIGN KEY("id") REFERENCES "posts"("user_id")
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
ALTER TABLE "post"
|
||||||
|
ADD FOREIGN KEY("id") REFERENCES "posts"("post_id")
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue