Moving files and adding auth

This commit is contained in:
Lukas Bachschwell 2018-11-07 11:10:51 +01:00
parent 728ac72dff
commit 1c16b54802
19 changed files with 1175 additions and 309 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# main binary
multitenantStack
# IDEs
.vscode
# Go vendoring
vendor/*

View File

@ -1,6 +1,6 @@
# MutlitenantStack
This is a project to demonstrate multi tenancy usage in beego using postgres and seperated databases
This is a project to demonstrate multi tenancy usage in beego using postgres and separated databases
The api was scaffolded using:
@ -9,3 +9,8 @@ The api was scaffolded using:
then `bee run -downdoc=true``
To regenerate docs simply run `bee generate docs`
## TODO
- company controller, create databases and so on
- Update not found to json

15
bee.json Normal file
View File

@ -0,0 +1,15 @@
{
"version": 0,
"go_install": false,
"scripts": {
"test": "go test -v tests/*.go",
"convey": "goconvey tests/"
},
"cmd_args": [],
"envs": [],
"database": {
"driver": "postgres",
"conn": "postgres://postgres:postgre@127.0.0.1:5435/system?sslmode=disable"
},
"enable_reload": true
}

127
controllers/auth.go Normal file
View File

@ -0,0 +1,127 @@
package controllers
import (
auth "multitenantStack/services/authentication"
"time"
jwt "github.com/dgrijalva/jwt-go"
)
// AuthController operations for Auth
type AuthController struct {
BaseController
}
// URLMapping ...
func (c *AuthController) URLMapping() {
// This block is used to drastically speed up the annotation -> lookup process
c.Mapping("Login", c.Login)
c.Mapping("GetOne", c.GetOne)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
}
// Login Get a JWT token for the user
// @Title Create
// @Description create Auth
// @Param body body models.Auth true "body for Auth content"
// @Success 201 {object} models.Auth
// @Failure 403 body is empty
// @router /login [post]
func (c *AuthController) Login() {
type AuthResponse struct {
Status int
Jwt string
}
if c.Ctx.Input.Method() != "POST" {
c.ServeJsonError("Method not allowed")
return
}
//TODO: did the user send us a token? then just validate and tell him he is logged in
email := c.GetString("email")
password := c.GetString("password")
//TODO: check against main database, get company id and veryfy password
companyName := ""
companyUserId := 5
//TODO: if found query the company database to get roleid, and name
name := "Lukas"
roleId := 5
tokenString := ""
if email == "admin@admin.at" && password == "my password" {
// The jwtClaims are our trusted clientside session
tokenString = auth.CreateToken(jwt.MapClaims{
"email": email,
"companyName": companyName,
"companyUserId": companyUserId,
"name": name,
"roleId": roleId,
"expires": time.Now().Unix() + 3600,
})
} else {
c.ServeJsonError("Invalid user/password")
return
}
json := AuthResponse{200, tokenString}
c.Data["json"] = &json
c.ServeJSON()
}
// GetOne ...
// @Title GetOne
// @Description get Auth by id
// @Param id path string true "The key for staticblock"
// @Success 200 {object} models.Auth
// @Failure 403 :id is empty
// @router /:id [get]
func (c *AuthController) GetOne() {
}
// GetAll ...
// @Title GetAll
// @Description get Auth
// @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..."
// @Param fields query string false "Fields returned. e.g. col1,col2 ..."
// @Param sortby query string false "Sorted-by fields. e.g. col1,col2 ..."
// @Param order query string false "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ..."
// @Param limit query string false "Limit the size of result set. Must be an integer"
// @Param offset query string false "Start position of result set. Must be an integer"
// @Success 200 {object} models.Auth
// @Failure 403
// @router / [get]
func (c *AuthController) GetAll() {
}
// Put ...
// @Title Put
// @Description update the Auth
// @Param id path string true "The id you want to update"
// @Param body body models.Auth true "body for Auth content"
// @Success 200 {object} models.Auth
// @Failure 403 :id is not int
// @router /:id [put]
func (c *AuthController) Put() {
}
// Delete ...
// @Title Delete
// @Description delete the Auth
// @Param id path string true "The id you want to delete"
// @Success 200 {string} delete success!
// @Failure 403 id is empty
// @router /:id [delete]
func (c *AuthController) Delete() {
}

30
controllers/base.go Normal file
View File

@ -0,0 +1,30 @@
package controllers
import (
"github.com/astaxie/beego"
)
type JsonBasicResponse struct {
Status int
Message string
}
const JSON_ERROR int = 500
const JSON_SUCCESS int = 200
// BaseController operations for BaseController
type BaseController struct {
beego.Controller
}
func (this *BaseController) ServeJsonError(message string) {
json := JsonBasicResponse{JSON_ERROR, message}
this.Data["json"] = &json
this.ServeJSON()
}
func (this *BaseController) ServeJsonSuccess(message string) {
json := JsonBasicResponse{JSON_SUCCESS, message}
this.Data["json"] = &json
this.ServeJSON()
}

36
controllers/baseAPI.go Normal file
View File

@ -0,0 +1,36 @@
package controllers
import (
//"fmt"
"github.com/juusechec/jwt-beego"
)
// BaseController operations for APIs
type BaseAPIController struct {
BaseController
}
func (this *BaseAPIController) Prepare() {
if this.Ctx.Input.Method() != "POST" {
this.ServeJsonError("Method not allowed")
}
//Lo que quieras hacer en todos los controladores
// O puede ser leído de una cabecera HEADER!!
tokenString := this.Ctx.Request.Header.Get("X-JWTtoken")
et := jwtbeego.EasyToken{}
valid, issuer, _ := et.ValidateToken(tokenString)
if !valid {
this.Ctx.Output.SetStatus(401)
this.ServeJsonError("Invalid Token")
}
userSession := this.GetSession("username")
if userSession == nil || userSession != issuer {
this.Ctx.Output.SetStatus(401)
this.ServeJsonError("Invalid Session")
}
return
}

1
lastupdate.tmp Executable file
View File

@ -0,0 +1 @@
{"/Users/LB/go/src/multitenantStack/controllers":1541579833440000000}

View File

@ -0,0 +1,210 @@
package routers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"
)
func init() {
beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"],
beego.ControllerComments{
Method: "GetOne",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"],
beego.ControllerComments{
Method: "Put",
Router: `/:id`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:AuthController"],
beego.ControllerComments{
Method: "Login",
Router: `/login`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"],
beego.ControllerComments{
Method: "Post",
Router: `/`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"],
beego.ControllerComments{
Method: "GetOne",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"],
beego.ControllerComments{
Method: "Put",
Router: `/:id`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyDataController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"],
beego.ControllerComments{
Method: "Post",
Router: `/`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"],
beego.ControllerComments{
Method: "GetOne",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"],
beego.ControllerComments{
Method: "Put",
Router: `/:id`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:CompanyUserController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"],
beego.ControllerComments{
Method: "Post",
Router: `/`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"],
beego.ControllerComments{
Method: "GetOne",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"],
beego.ControllerComments{
Method: "Put",
Router: `/:id`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:ContactController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:PostController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:PostController"],
beego.ControllerComments{
Method: "Post",
Router: `/`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:PostController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:PostController"],
beego.ControllerComments{
Method: "GetAll",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:PostController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:PostController"],
beego.ControllerComments{
Method: "GetOne",
Router: `/:id`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:PostController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:PostController"],
beego.ControllerComments{
Method: "Put",
Router: `/:id`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["multitenantStack/controllers:PostController"] = append(beego.GlobalControllerRouter["multitenantStack/controllers:PostController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:id`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Params: nil})
}

View File

@ -22,7 +22,7 @@ func init() {
),
),
beego.NSNamespace("/company_data",
beego.NSNamespace("/companydata",
beego.NSInclude(
&controllers.CompanyDataController{},
),
@ -34,11 +34,17 @@ func init() {
),
),
beego.NSNamespace("/company_user",
beego.NSNamespace("/user",
beego.NSInclude(
&controllers.CompanyUserController{},
),
),
beego.NSNamespace("/auth",
beego.NSInclude(
&controllers.AuthController{},
),
),
)
beego.AddNamespace(ns)
}

View File

@ -0,0 +1,56 @@
package services
import (
"crypto/rand"
"fmt"
jwt "github.com/dgrijalva/jwt-go"
)
var hmacSecret []byte
func GenerateSecret() []byte {
b := make([]byte, 32)
rand.Read(b)
return b
}
func InitAuthService() {
hmacSecret = GenerateSecret()
// TODO: This needs to be replaced with reading rsa keys, there needs to be a automatic generation of these if they do not exist
}
func Validate(Token string) (bool, jwt.Token) {
token, err := jwt.Parse(Token, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
}
return hmacSecret, nil
})
if err == nil && token.Valid {
fmt.Println("Token is valid")
return true, *token
}
fmt.Println("Token Validation failed")
return false, *token
}
func CreateToken(Claims jwt.MapClaims) string {
// Create a new token object, specifying signing method and the claims
// you would like it to contain.
token := jwt.NewWithClaims(jwt.SigningMethodHS256, Claims)
// Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString(hmacSecret)
if err != nil {
fmt.Println(err.Error())
}
return tokenString
}

View File

@ -0,0 +1,64 @@
package services
import (
"database/sql"
"fmt"
"os"
"github.com/astaxie/beego/orm"
)
var dbs map[string]*sql.DB
// InitCompanyService Init companydb service and open system db connection
func InitCompanyService() {
fmt.Println("Hello from init") // test if init gets called from each orm
dbs := make(map[string]*sql.DB)
orm.RegisterDataBase("default", "postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre sslmode=disable")
systemDB, err := sql.Open("postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company5 sslmode=disable")
if err != nil {
fmt.Println("Fatal: could not connect to db, exiting... Error:", err)
os.Exit(1)
}
dbs["system"] = systemDB
}
// GetDatabase Get orm and user information
func GetDatabase(token string) {
// validate token
// retrieve correct user/database
// check if open first
// try to open second
// return error otherwise
// return db with orm or error
}
// CreateDatabase Create a database by copying the template
func CreateDatabase(token string) {
/*
db, err = sql.Open("postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company5 sslmode=disable")
if err != nil {
log.Fatal(err)
}
or, err := orm.NewOrmWithDB("postgres", "temp", db)
*/
}
// DeleteDatabase Delete an entire database, this is very very dangerous :-)
func DeleteDatabase(token string) {
/*
db.Close()
fmt.Println("Closed company5")
//}
res, err := o.Raw("DROP DATABASE company5;").Exec()
if err == nil {
num, _ := res.RowsAffected()
fmt.Println("mysql row affected number: ", num)
}
*/
}

View File

@ -15,10 +15,188 @@
},
"basePath": "/v1",
"paths": {
"/company_data/": {
"/auth/": {
"get": {
"tags": [
"company_data"
"auth"
],
"description": "get Auth",
"operationId": "AuthController.GetAll",
"parameters": [
{
"in": "query",
"name": "query",
"description": "Filter. e.g. col1:v1,col2:v2 ...",
"type": "string"
},
{
"in": "query",
"name": "fields",
"description": "Fields returned. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "sortby",
"description": "Sorted-by fields. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "order",
"description": "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ...",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "Limit the size of result set. Must be an integer",
"type": "string"
},
{
"in": "query",
"name": "offset",
"description": "Start position of result set. Must be an integer",
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/.Auth"
}
},
"403": {
"description": ""
}
}
}
},
"/auth/login": {
"post": {
"tags": [
"auth"
],
"description": "create Auth",
"operationId": "AuthController.Create",
"parameters": [
{
"in": "body",
"name": "body",
"description": "body for Auth content",
"required": true,
"schema": {
"$ref": "#/definitions/.Auth"
}
}
],
"responses": {
"201": {
"description": "",
"schema": {
"$ref": "#/definitions/.Auth"
}
},
"403": {
"description": "body is empty"
}
}
}
},
"/auth/{id}": {
"get": {
"tags": [
"auth"
],
"description": "get Auth by id",
"operationId": "AuthController.GetOne",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The key for staticblock",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/.Auth"
}
},
"403": {
"description": ":id is empty"
}
}
},
"put": {
"tags": [
"auth"
],
"description": "update the Auth",
"operationId": "AuthController.Put",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to update",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "body for Auth content",
"required": true,
"schema": {
"$ref": "#/definitions/.Auth"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/.Auth"
}
},
"403": {
"description": ":id is not int"
}
}
},
"delete": {
"tags": [
"auth"
],
"description": "delete the Auth",
"operationId": "AuthController.Delete",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to delete",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{string} delete success!"
},
"403": {
"description": "id is empty"
}
}
}
},
"/companydata/": {
"get": {
"tags": [
"companydata"
],
"description": "get CompanyData",
"operationId": "CompanyDataController.Get All",
@ -74,7 +252,7 @@
},
"post": {
"tags": [
"company_data"
"companydata"
],
"description": "create CompanyData",
"operationId": "CompanyDataController.Post",
@ -99,10 +277,10 @@
}
}
},
"/company_data/{id}": {
"/companydata/{id}": {
"get": {
"tags": [
"company_data"
"companydata"
],
"description": "get CompanyData by id",
"operationId": "CompanyDataController.Get One",
@ -129,7 +307,7 @@
},
"put": {
"tags": [
"company_data"
"companydata"
],
"description": "update the CompanyData",
"operationId": "CompanyDataController.Put",
@ -165,7 +343,7 @@
},
"delete": {
"tags": [
"company_data"
"companydata"
],
"description": "delete the CompanyData",
"operationId": "CompanyDataController.Delete",
@ -188,179 +366,6 @@
}
}
},
"/company_user/": {
"get": {
"tags": [
"company_user"
],
"description": "get CompanyUser",
"operationId": "CompanyUserController.Get All",
"parameters": [
{
"in": "query",
"name": "query",
"description": "Filter. e.g. col1:v1,col2:v2 ...",
"type": "string"
},
{
"in": "query",
"name": "fields",
"description": "Fields returned. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "sortby",
"description": "Sorted-by fields. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "order",
"description": "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ...",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "Limit the size of result set. Must be an integer",
"type": "string"
},
{
"in": "query",
"name": "offset",
"description": "Start position of result set. Must be an integer",
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ""
}
}
},
"post": {
"tags": [
"company_user"
],
"description": "create CompanyUser",
"operationId": "CompanyUserController.Post",
"parameters": [
{
"in": "body",
"name": "body",
"description": "body for CompanyUser content",
"required": true,
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
}
],
"responses": {
"201": {
"description": "{int} models.CompanyUser"
},
"403": {
"description": "body is empty"
}
}
}
},
"/company_user/{id}": {
"get": {
"tags": [
"company_user"
],
"description": "get CompanyUser by id",
"operationId": "CompanyUserController.Get One",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The key for staticblock",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ":id is empty"
}
}
},
"put": {
"tags": [
"company_user"
],
"description": "update the CompanyUser",
"operationId": "CompanyUserController.Put",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to update",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "body for CompanyUser content",
"required": true,
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ":id is not int"
}
}
},
"delete": {
"tags": [
"company_user"
],
"description": "delete the CompanyUser",
"operationId": "CompanyUserController.Delete",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to delete",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{string} delete success!"
},
"403": {
"description": "id is empty"
}
}
}
},
"/contact/": {
"get": {
"tags": [
@ -706,9 +711,185 @@
}
}
}
},
"/user/": {
"get": {
"tags": [
"user"
],
"description": "get CompanyUser",
"operationId": "CompanyUserController.Get All",
"parameters": [
{
"in": "query",
"name": "query",
"description": "Filter. e.g. col1:v1,col2:v2 ...",
"type": "string"
},
{
"in": "query",
"name": "fields",
"description": "Fields returned. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "sortby",
"description": "Sorted-by fields. e.g. col1,col2 ...",
"type": "string"
},
{
"in": "query",
"name": "order",
"description": "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ...",
"type": "string"
},
{
"in": "query",
"name": "limit",
"description": "Limit the size of result set. Must be an integer",
"type": "string"
},
{
"in": "query",
"name": "offset",
"description": "Start position of result set. Must be an integer",
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ""
}
}
},
"post": {
"tags": [
"user"
],
"description": "create CompanyUser",
"operationId": "CompanyUserController.Post",
"parameters": [
{
"in": "body",
"name": "body",
"description": "body for CompanyUser content",
"required": true,
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
}
],
"responses": {
"201": {
"description": "{int} models.CompanyUser"
},
"403": {
"description": "body is empty"
}
}
}
},
"/user/{id}": {
"get": {
"tags": [
"user"
],
"description": "get CompanyUser by id",
"operationId": "CompanyUserController.Get One",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The key for staticblock",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ":id is empty"
}
}
},
"put": {
"tags": [
"user"
],
"description": "update the CompanyUser",
"operationId": "CompanyUserController.Put",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to update",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "body for CompanyUser content",
"required": true,
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.CompanyUser"
}
},
"403": {
"description": ":id is not int"
}
}
},
"delete": {
"tags": [
"user"
],
"description": "delete the CompanyUser",
"operationId": "CompanyUserController.Delete",
"parameters": [
{
"in": "path",
"name": "id",
"description": "The id you want to delete",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{string} delete success!"
},
"403": {
"description": "id is empty"
}
}
}
}
},
"definitions": {
".Auth": {
"type": "object"
},
"models.CompanyData": {
"title": "CompanyData",
"type": "object",
@ -835,7 +1016,7 @@
"description": "ContactController operations for Contact\n"
},
{
"name": "company_data",
"name": "companydata",
"description": "CompanyDataController operations for CompanyData\n"
},
{
@ -843,8 +1024,12 @@
"description": "PostController operations for Post\n"
},
{
"name": "company_user",
"name": "user",
"description": "CompanyUserController operations for CompanyUser\n"
},
{
"name": "auth",
"description": "AuthController operations for Auth\n"
}
]
}

View File

@ -11,10 +11,128 @@ info:
url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /v1
paths:
/company_data/:
/auth/:
get:
tags:
- company_data
- auth
description: get Auth
operationId: AuthController.GetAll
parameters:
- in: query
name: query
description: Filter. e.g. col1:v1,col2:v2 ...
type: string
- in: query
name: fields
description: Fields returned. e.g. col1,col2 ...
type: string
- in: query
name: sortby
description: Sorted-by fields. e.g. col1,col2 ...
type: string
- in: query
name: order
description: Order corresponding to each sortby field, if single value, apply
to all sortby fields. e.g. desc,asc ...
type: string
- in: query
name: limit
description: Limit the size of result set. Must be an integer
type: string
- in: query
name: offset
description: Start position of result set. Must be an integer
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/.Auth'
"403":
description: ""
/auth/{id}:
get:
tags:
- auth
description: get Auth by id
operationId: AuthController.GetOne
parameters:
- in: path
name: id
description: The key for staticblock
required: true
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/.Auth'
"403":
description: :id is empty
put:
tags:
- auth
description: update the Auth
operationId: AuthController.Put
parameters:
- in: path
name: id
description: The id you want to update
required: true
type: string
- in: body
name: body
description: body for Auth content
required: true
schema:
$ref: '#/definitions/.Auth'
responses:
"200":
description: ""
schema:
$ref: '#/definitions/.Auth'
"403":
description: :id is not int
delete:
tags:
- auth
description: delete the Auth
operationId: AuthController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{string} delete success!'
"403":
description: id is empty
/auth/login:
post:
tags:
- auth
description: create Auth
operationId: AuthController.Create
parameters:
- in: body
name: body
description: body for Auth content
required: true
schema:
$ref: '#/definitions/.Auth'
responses:
"201":
description: ""
schema:
$ref: '#/definitions/.Auth'
"403":
description: body is empty
/companydata/:
get:
tags:
- companydata
description: get CompanyData
operationId: CompanyDataController.Get All
parameters:
@ -52,7 +170,7 @@ paths:
description: ""
post:
tags:
- company_data
- companydata
description: create CompanyData
operationId: CompanyDataController.Post
parameters:
@ -67,10 +185,10 @@ paths:
description: '{int} models.CompanyData'
"403":
description: body is empty
/company_data/{id}:
/companydata/{id}:
get:
tags:
- company_data
- companydata
description: get CompanyData by id
operationId: CompanyDataController.Get One
parameters:
@ -88,7 +206,7 @@ paths:
description: :id is empty
put:
tags:
- company_data
- companydata
description: update the CompanyData
operationId: CompanyDataController.Put
parameters:
@ -112,7 +230,7 @@ paths:
description: :id is not int
delete:
tags:
- company_data
- companydata
description: delete the CompanyData
operationId: CompanyDataController.Delete
parameters:
@ -126,121 +244,6 @@ paths:
description: '{string} delete success!'
"403":
description: id is empty
/company_user/:
get:
tags:
- company_user
description: get CompanyUser
operationId: CompanyUserController.Get All
parameters:
- in: query
name: query
description: Filter. e.g. col1:v1,col2:v2 ...
type: string
- in: query
name: fields
description: Fields returned. e.g. col1,col2 ...
type: string
- in: query
name: sortby
description: Sorted-by fields. e.g. col1,col2 ...
type: string
- in: query
name: order
description: Order corresponding to each sortby field, if single value, apply
to all sortby fields. e.g. desc,asc ...
type: string
- in: query
name: limit
description: Limit the size of result set. Must be an integer
type: string
- in: query
name: offset
description: Start position of result set. Must be an integer
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: ""
post:
tags:
- company_user
description: create CompanyUser
operationId: CompanyUserController.Post
parameters:
- in: body
name: body
description: body for CompanyUser content
required: true
schema:
$ref: '#/definitions/models.CompanyUser'
responses:
"201":
description: '{int} models.CompanyUser'
"403":
description: body is empty
/company_user/{id}:
get:
tags:
- company_user
description: get CompanyUser by id
operationId: CompanyUserController.Get One
parameters:
- in: path
name: id
description: The key for staticblock
required: true
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: :id is empty
put:
tags:
- company_user
description: update the CompanyUser
operationId: CompanyUserController.Put
parameters:
- in: path
name: id
description: The id you want to update
required: true
type: string
- in: body
name: body
description: body for CompanyUser content
required: true
schema:
$ref: '#/definitions/models.CompanyUser'
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: :id is not int
delete:
tags:
- company_user
description: delete the CompanyUser
operationId: CompanyUserController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{string} delete success!'
"403":
description: id is empty
/contact/:
get:
tags:
@ -471,7 +474,124 @@ paths:
description: '{string} delete success!'
"403":
description: id is empty
/user/:
get:
tags:
- user
description: get CompanyUser
operationId: CompanyUserController.Get All
parameters:
- in: query
name: query
description: Filter. e.g. col1:v1,col2:v2 ...
type: string
- in: query
name: fields
description: Fields returned. e.g. col1,col2 ...
type: string
- in: query
name: sortby
description: Sorted-by fields. e.g. col1,col2 ...
type: string
- in: query
name: order
description: Order corresponding to each sortby field, if single value, apply
to all sortby fields. e.g. desc,asc ...
type: string
- in: query
name: limit
description: Limit the size of result set. Must be an integer
type: string
- in: query
name: offset
description: Start position of result set. Must be an integer
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: ""
post:
tags:
- user
description: create CompanyUser
operationId: CompanyUserController.Post
parameters:
- in: body
name: body
description: body for CompanyUser content
required: true
schema:
$ref: '#/definitions/models.CompanyUser'
responses:
"201":
description: '{int} models.CompanyUser'
"403":
description: body is empty
/user/{id}:
get:
tags:
- user
description: get CompanyUser by id
operationId: CompanyUserController.Get One
parameters:
- in: path
name: id
description: The key for staticblock
required: true
type: string
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: :id is empty
put:
tags:
- user
description: update the CompanyUser
operationId: CompanyUserController.Put
parameters:
- in: path
name: id
description: The id you want to update
required: true
type: string
- in: body
name: body
description: body for CompanyUser content
required: true
schema:
$ref: '#/definitions/models.CompanyUser'
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.CompanyUser'
"403":
description: :id is not int
delete:
tags:
- user
description: delete the CompanyUser
operationId: CompanyUserController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{string} delete success!'
"403":
description: id is empty
definitions:
.Auth:
type: object
models.CompanyData:
title: CompanyData
type: object
@ -560,12 +680,15 @@ tags:
- name: contact
description: |
ContactController operations for Contact
- name: company_data
- name: companydata
description: |
CompanyDataController operations for CompanyData
- name: post
description: |
PostController operations for Post
- name: company_user
- name: user
description: |
CompanyUserController operations for CompanyUser
- name: auth
description: |
AuthController operations for Auth