ui get form new and edit mode

This commit is contained in:
ycc 2023-08-23 21:33:00 +02:00
parent be4545e603
commit 82012d36af
27 changed files with 1992 additions and 124 deletions

15
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "main.go"
}
]
}

View File

@ -6,6 +6,8 @@ Some special tables can be used for defining database access restrictions based
> export GOPRIVATE=forge.redroom.link
before doing go mod tidy.
bee generate routers
Running in debug mode
---------------------
> bee run -downdoc=true -gendoc=true

View File

@ -59,7 +59,7 @@ func (t *TableController) Put() {
} else {
t.Ctx.Output.SetStatus(http.StatusOK)
}
t.Data["json"] = map[string]int{"uid": uid}
t.Data["json"] = map[string]int64{"uid": uid}
t.ServeJSON()
}

210
controllers/ui.go Normal file
View File

@ -0,0 +1,210 @@
package controllers
import (
"encoding/json"
"fmt"
"net/http"
"os"
"strings"
"forge.redroom.link/yves/sqldb"
beego "github.com/beego/beego/v2/server/web"
"github.com/rs/zerolog/log"
)
// Operations about table
type UiController struct {
beego.Controller
}
// @Title form
// @Description create access form
// @Param fid path string true "The fid of the form"
// @Param uid path string true "The uid you want to edit"
// @Success 200 json form
// @Failure 403 body is empty
// @router /:fid/:uid [get]
func (u *UiController) GetEditForm() {
fid := u.Ctx.Input.Query(":fid")
uid := u.Ctx.Input.Query(":uid")
u.buildForm(fid, uid)
}
// @Title form
// @Description create access form
// @Param fid path string true "The fid of the form"
// @Success 200 json form
// @Failure 403 body is empty
// @router /:fid [get]
func (u *UiController) GetEmptyForm() {
fid := u.Ctx.Input.Query(":fid")
u.buildForm(fid, "")
}
func (u *UiController) buildForm(fid string, uid string) {
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
// Get form data
formdesc, err := getFormDesc(db, fid)
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
form := make(map[string]interface{})
form["title"] = formdesc[0]["title"].(string)
form["description"] = formdesc[0]["header"].(string)
formfields, err := getFormFields(db, fid)
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
var fields []interface{}
columnnames := []string{"id"}
for _, f := range formfields {
columnnames = append(columnnames, f["columnname"].(string))
}
// Get table schema
schema, err := db.Table(formdesc[0]["tablename"].(string)).GetSchema()
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
var data []sqldb.AssRow
//Get edited Item data if item id is provided
if uid != "" {
data, err = getData(db, formdesc[0]["tablename"].(string), columnnames, uid)
}
for _, f := range formfields {
if f["columnname"].(string) != "id" {
field := make(map[string]interface{})
field["key"] = f["columnname"].(string)
if uid != "" {
field["value"] = fmt.Sprintf("%v", data[0][f["columnname"].(string)])
}
field["type"] = f["fieldtype"].(string)
field["label"] = f["label"].(string)
dbType := schema.Columns[f["columnname"].(string)][:strings.Index(schema.Columns[f["columnname"].(string)], "|")]
// foreign keys
if f["columnname"].(string)[len(f["columnname"].(string))-3:] == "_id" {
fklist := []map[string]interface{}{}
// Query FK
columns := strings.Split(f["linkcolumns"].(string), ",")
sortkeys := strings.Split(f["linkorder"].(string), ",")
restriction := f["linkrestriction"].(string)
dir := ""
fk, err := db.Table(f["columnname"].(string)[:len(f["columnname"].(string))-3]).GetAssociativeArray(columns, restriction, sortkeys, dir)
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
for _, v := range fk {
item := make(map[string]interface{})
item["value"] = fmt.Sprintf("%v", v["id"])
item["label"] = v["label"]
fklist = append(fklist, item)
}
field["items"] = fklist
}
// other
switch dbType {
case "integer":
case "float", "double":
case "varchar":
}
if uid != "" {
// Force data values to the right type if required
switch field["type"] {
case "Radio":
field["value"] = data[0][f["columnname"].(string)]
// force string for all text fields, whatever data type
default:
field["value"] = fmt.Sprintf("%v", data[0][f["columnname"].(string)])
}
}
fields = append(fields, field)
}
}
form["fields"] = fields
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
} else {
u.Data["json"] = form
}
u.ServeJSON()
}
// @Title Access form data post
// @Description insert access
// @Param uid path string true "The uid you want to edit"
// @Param body body form data "body of jsonform data"
// @Success 200 json
// @Failure 403 body is empty
// @router /:uid [post]
func (u *UiController) PostAccessForm() {
var err error
uid := u.Ctx.Input.Query(":uid")
var formdata map[string]interface{}
json.Unmarshal(u.Ctx.Input.RequestBody, &formdata)
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
accesslist := formdata["fields"].([]interface{})
switcheslist := accesslist[:len(accesslist)-3]
families := []string{}
for _, accessif := range switcheslist {
access := accessif.(map[string]interface{})
basefamily := fmt.Sprint(access["key"].(float64))
if access["value"].(bool) {
_, err = db.QueryAssociativeArray("insert ignore into user_basefamily(user_id, family_id) values(" + uid + "," + basefamily + ")")
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
families = append(families, basefamily)
} else {
// remove off
_, err = db.QueryAssociativeArray("delete from user_basefamily where user_id=" + uid + " and family_id=" + basefamily)
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
}
}
}
if err != nil {
log.Error().Msg(err.Error())
u.Ctx.Output.SetStatus(http.StatusBadRequest)
} else {
u.Data["json"] = "ok"
}
u.ServeJSON()
}
func getFormDesc(db *sqldb.Db, fid string) ([]sqldb.AssRow, error) {
columns := []string{"*"}
restriction := "id=" + fid
sortkeys := []string{}
dir := ""
return db.Table("dbform").GetAssociativeArray(columns, restriction, sortkeys, dir)
}
func getFormFields(db *sqldb.Db, fid string) ([]sqldb.AssRow, error) {
columns := []string{"*"}
restriction := "form_id=" + fid
sortkeys := []string{"columnorder"}
dir := ""
return db.Table("dbformfields").GetAssociativeArray(columns, restriction, sortkeys, dir)
}
func getData(db *sqldb.Db, table string, columns []string, uid string) ([]sqldb.AssRow, error) {
restriction := "id=" + uid
sortkeys := []string{}
dir := ""
return db.Table(table).GetAssociativeArray(columns, restriction, sortkeys, dir)
}

View File

@ -7,13 +7,13 @@ CREATE SEQUENCE sq_dbtableaccess;
CREATE SEQUENCE sq_dbuser;
CREATE SEQUENCE sq_dbuserrole;
CREATE SEQUENCE sq_dbentity;
CREATE SEQUENCE sq_dbform;
CREATE SEQUENCE sq_dbformfields;
CREATE TABLE IF NOT EXISTS public.dbrole
(
id integer NOT NULL DEFAULT nextval('sq_dbrole'),
name character varying,
name character varying(255),
description text,
PRIMARY KEY (id)
);
@ -56,6 +56,32 @@ CREATE TABLE IF NOT EXISTS public.dbentity
);
CREATE TABLE IF NOT EXISTS public.dbform
(
id integer NOT NULL DEFAULT nextval('sq_dbform'),
tablename character varying(255),
formname character varying(255),
title character varying(255),
header character varying(2000),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.dbformfields
(
id integer NOT NULL DEFAULT nextval('sq_dbformfields'),
form_id integer,
columnname character varying(255),
columnorder integer,
fieldtype character varying(255),
label character varying(255),
placeholder character varying(255),
defaultvalue character varying(255),
linkcolumns character varying(255),
linkrestriction character varying(255),
linkorder character varying(255),
required bool,
description text,
PRIMARY KEY (id)
);
END;

View File

@ -5,51 +5,16 @@ BEGIN;
CREATE TABLE IF NOT EXISTS public.axis
(
id integer NOT NULL SERIAL,
id SERIAL,
name character varying(255),
entity_id integer,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.dbrole
(
id integer NOT NULL SERIAL,
name character varying,
description text,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.dbtableaccess
(
id integer NOT NULL SERIAL,
tableaccess character varying(255),
dbrole_id integer,
userrolerestrictions character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.dbuser
(
id integer NOT NULL SERIAL,
login character varying(255) UNIQUE,
password character varying(255),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.dbuserrole
(
id integer NOT NULL SERIAL,
dbuser_id integer,
entity_id integer,
dbrole_id integer,
startdate timestamp without time zone,
enddate timestamp without time zone,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.employee
(
id bigint NOT NULL SERIAL,
id SERIAL,
name character varying(255),
firstname character varying(255),
mail character varying(255),
@ -72,7 +37,7 @@ CREATE TABLE IF NOT EXISTS public.employee
CREATE TABLE IF NOT EXISTS public.entity
(
id integer NOT NULL SERIAL,
id SERIAL,
type character varying(255),
parent_id bigint,
description text,
@ -81,7 +46,7 @@ CREATE TABLE IF NOT EXISTS public.entity
CREATE TABLE IF NOT EXISTS public.project
(
id integer NOT NULL SERIAL,
id SERIAL,
name character varying(255),
entity_id integer,
PRIMARY KEY (id)
@ -93,28 +58,6 @@ ALTER TABLE public.axis
NOT VALID;
ALTER TABLE public.dbtableaccess
ADD FOREIGN KEY (dbrole_id)
REFERENCES public.dbrole (id)
NOT VALID;
ALTER TABLE public.dbuserrole
ADD FOREIGN KEY (dbrole_id)
REFERENCES public.dbrole (id)
NOT VALID;
ALTER TABLE public.dbuserrole
ADD FOREIGN KEY (dbuser_id)
REFERENCES public.dbuser (id)
NOT VALID;
ALTER TABLE public.dbuserrole
ADD FOREIGN KEY (entity_id)
REFERENCES public.entity (id)
NOT VALID;
ALTER TABLE public.employee

21
db/docker-compose.yml Normal file
View File

@ -0,0 +1,21 @@
version: '3.1'
services:
pg:
image: postgres:alpine
restart: always
volumes:
- ./autoload:/docker-entrypoint-initdb.d
environment:
POSTGRES_DB: test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
ports:
- 5432:5432
adminer:
image: adminer
restart: always
ports:
- 8888:8080

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

60
db/swagger/index.html Normal file
View File

@ -0,0 +1,60 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
// End Swagger UI call region
window.ui = ui;
};
</script>
</body>
</html>

View File

@ -0,0 +1,79 @@
<!doctype html>
<html lang="en-US">
<head>
<title>Swagger UI: OAuth2 Redirect</title>
</head>
<body>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
qp = location.search.substring(1);
}
arr = qp.split("&");
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value);
}
) : {};
isValid = qp.state === sentState;
if ((
oauth2.auth.schema.get("flow") === "accessCode" ||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
oauth2.auth.schema.get("flow") === "authorization_code"
) && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
let oauthErrorMsg;
if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
(qp.error_uri ? "More info: "+qp.error_uri : "");
}
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
if (document.readyState !== 'loading') {
run();
} else {
document.addEventListener('DOMContentLoaded', function () {
run();
});
}
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
db/swagger/swagger-ui.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

54
go.mod
View File

@ -2,24 +2,48 @@ module sqldb-ws
go 1.16
require github.com/beego/beego/v2 v2.0.2
require github.com/beego/beego/v2 v2.1.0
require (
forge.redroom.link/yves/sqldb v0.0.0-20220520131204-4e17758e157e
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/lib/pq v1.10.6
github.com/matthewhartstonge/argon2 v0.2.1
forge.redroom.link/yves/sqldb v0.0.0-20230707071522-c362b6bc33d0
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a // indirect
github.com/aws/aws-lambda-go v1.13.3 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/hashicorp/go.net v0.0.1 // indirect
github.com/lib/pq v1.10.9
github.com/lightstep/lightstep-tracer-go v0.18.1 // indirect
github.com/matthewhartstonge/argon2 v0.3.3
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/gox v0.4.0 // indirect
github.com/mitchellh/iochan v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nats-io/jwt v0.3.2 // indirect
github.com/oklog/oklog v0.3.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/opentracing/basictracer-go v1.0.0 // indirect
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5 // indirect
github.com/pact-foundation/pact-go v1.0.4 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/rs/zerolog v1.26.1
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/performancecopilot/speed v3.0.0+incompatible // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/rs/zerolog v1.29.1
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da // indirect
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 // indirect
github.com/smartystreets/goconvey v1.6.4
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/viper v1.11.0
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220519141025-dcacdad47464 // indirect
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99 // indirect
github.com/spf13/viper v1.16.0
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 // indirect
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 // indirect
)

1119
go.sum

File diff suppressed because it is too large Load Diff

154
routers/commentsRouter.go Normal file
View File

@ -0,0 +1,154 @@
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/context/param"
)
func init() {
beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"],
beego.ControllerComments{
Method: "AddUser",
Router: `/adduser`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"],
beego.ControllerComments{
Method: "Login",
Router: `/login`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"],
beego.ControllerComments{
Method: "Logout",
Router: `/logout`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"],
beego.ControllerComments{
Method: "GetTable",
Router: `/`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"],
beego.ControllerComments{
Method: "GetSchema",
Router: `/:table`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "Put",
Router: `/:table`,
AllowHTTPMethods: []string{"put"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "Delete",
Router: `/:table`,
AllowHTTPMethods: []string{"delete"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "GetAllTable",
Router: `/:table`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "TablePost",
Router: `/:table`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "GetAllTableColumn",
Router: `/:table/:columns`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "GetAllTableColumnRestriction",
Router: `/:table/:columns/:restriction`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "GetAllTableColumnRestrictionSortkeys",
Router: `/:table/:columns/:restriction/:sortkeys`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:TableController"],
beego.ControllerComments{
Method: "GetAllTableColumnRestrictionSortkeysDir",
Router: `/:table/:columns/:restriction/:sortkeys/:dir`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
beego.ControllerComments{
Method: "GetEmptyForm",
Router: `/:fid`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
beego.ControllerComments{
Method: "GetEditForm",
Router: `/:fid/:uid`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
beego.ControllerComments{
Method: "PostAccessForm",
Router: `/:uid`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

View File

@ -1,8 +1,8 @@
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @Title SqlDB WS API
// @Description Generic database access API
// @Contact yves.cerezal@irt-saintexupery.com
// @TermsOfServiceUrl https://www.irt-saintexupery.com/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers
@ -42,6 +42,11 @@ func init() {
&controllers.LoginController{},
),
),
beego.NSNamespace("/ui",
beego.NSInclude(
&controllers.UiController{},
),
),
)
beego.AddNamespace(ns)

View File

@ -1,12 +1,12 @@
{
"swagger": "2.0",
"info": {
"title": "beego Test API",
"description": "beego has a very cool tools to autogenerate documents for your API",
"title": "SqlDB WS API",
"description": "Generic database access API\n",
"version": "1.0.0",
"termsOfService": "http://beego.me/",
"termsOfService": "https://www.irt-saintexupery.com/",
"contact": {
"email": "astaxie@gmail.com"
"email": "yves.cerezal@irt-saintexupery.com"
},
"license": {
"name": "Apache 2.0",
@ -20,7 +20,7 @@
"tags": [
"l"
],
"description": "Add user",
"description": "Add user\n\u003cbr\u003e",
"operationId": "LoginController.AddUser",
"parameters": [
{
@ -53,7 +53,7 @@
"tags": [
"l"
],
"description": "User login",
"description": "User login\n\u003cbr\u003e",
"operationId": "LoginController.Login",
"parameters": [
{
@ -84,7 +84,7 @@
"tags": [
"l"
],
"description": "Logs user",
"description": "Logs user\n\u003cbr\u003e",
"operationId": "LoginController.Logout",
"responses": {
"200": {
@ -101,7 +101,7 @@
"tags": [
"s"
],
"description": "get list table",
"description": "get list table\n\u003cbr\u003e",
"operationId": "SchemaController.GetTable",
"responses": {
"200": {
@ -118,7 +118,7 @@
"tags": [
"s"
],
"description": "get table schema",
"description": "get table schema\n\u003cbr\u003e",
"operationId": "SchemaController.GetSchema",
"parameters": [
{
@ -144,7 +144,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.GetAllTable",
"parameters": [
{
@ -168,7 +168,7 @@
"tags": [
"t"
],
"description": "put data in table",
"description": "put data in table\n\u003cbr\u003e",
"operationId": "TableController.Put data in table",
"parameters": [
{
@ -201,7 +201,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.TablePost",
"parameters": [
{
@ -234,7 +234,7 @@
"tags": [
"t"
],
"description": "delete the data in table",
"description": "delete the data in table\n\u003cbr\u003e",
"operationId": "TableController.Delete",
"parameters": [
{
@ -268,7 +268,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.GetAllTableColumn",
"parameters": [
{
@ -301,7 +301,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.GetAllTableColumnRestriction",
"parameters": [
{
@ -341,7 +341,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.GetAllTableColumnRestrictionSortkeys",
"parameters": [
{
@ -381,7 +381,7 @@
"tags": [
"t"
],
"description": "get all Datas",
"description": "get all Datas\n\u003cbr\u003e",
"operationId": "TableController.GetAllTableColumnRestrictionSortkeysDir",
"parameters": [
{
@ -415,6 +415,99 @@
}
}
}
},
"/ui/{fid}": {
"get": {
"tags": [
"ui"
],
"description": "create access form\n\u003cbr\u003e",
"operationId": "UiController.form",
"parameters": [
{
"in": "path",
"name": "fid",
"description": "The fid of the form",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "json form"
},
"403": {
"description": "body is empty"
}
}
}
},
"/ui/{fid}/{uid}": {
"get": {
"tags": [
"ui"
],
"description": "create access form\n\u003cbr\u003e",
"operationId": "UiController.form",
"parameters": [
{
"in": "path",
"name": "fid",
"description": "The fid of the form",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "uid",
"description": "The uid you want to edit",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "json form"
},
"403": {
"description": "body is empty"
}
}
}
},
"/ui/{uid}": {
"post": {
"tags": [
"ui"
],
"description": "insert access\n\u003cbr\u003e",
"operationId": "UiController.Access form data post",
"parameters": [
{
"in": "path",
"name": "uid",
"description": "The uid you want to edit",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "body of jsonform data",
"schema": {
"$ref": "#/definitions/form"
}
}
],
"responses": {
"200": {
"description": "json"
},
"403": {
"description": "body is empty"
}
}
}
}
},
"definitions": {
@ -426,6 +519,10 @@
"title": "TableQuery",
"type": "object"
},
"form": {
"title": "form",
"type": "object"
},
"json": {
"title": "json",
"type": "object"
@ -447,6 +544,10 @@
{
"name": "l",
"description": "Operations about login\n"
},
{
"name": "ui",
"description": "Operations about table\n"
}
]
}

View File

@ -1,11 +1,12 @@
swagger: "2.0"
info:
title: beego Test API
description: beego has a very cool tools to autogenerate documents for your API
title: SqlDB WS API
description: |
Generic database access API
version: 1.0.0
termsOfService: http://beego.me/
termsOfService: https://www.irt-saintexupery.com/
contact:
email: astaxie@gmail.com
email: yves.cerezal@irt-saintexupery.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
@ -15,7 +16,9 @@ paths:
post:
tags:
- l
description: Add user
description: |-
Add user
<br>
operationId: LoginController.AddUser
parameters:
- in: query
@ -37,7 +40,9 @@ paths:
post:
tags:
- l
description: User login
description: |-
User login
<br>
operationId: LoginController.Login
parameters:
- in: body
@ -57,7 +62,9 @@ paths:
post:
tags:
- l
description: Logs user
description: |-
Logs user
<br>
operationId: LoginController.Logout
responses:
"200":
@ -68,7 +75,9 @@ paths:
get:
tags:
- s
description: get list table
description: |-
get list table
<br>
operationId: SchemaController.GetTable
responses:
"200":
@ -79,7 +88,9 @@ paths:
get:
tags:
- s
description: get table schema
description: |-
get table schema
<br>
operationId: SchemaController.GetSchema
parameters:
- in: path
@ -96,7 +107,9 @@ paths:
get:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.GetAllTable
parameters:
- in: path
@ -112,7 +125,9 @@ paths:
put:
tags:
- t
description: put data in table
description: |-
put data in table
<br>
operationId: TableController.Put data in table
parameters:
- in: path
@ -134,7 +149,9 @@ paths:
post:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.TablePost
parameters:
- in: path
@ -156,7 +173,9 @@ paths:
delete:
tags:
- t
description: delete the data in table
description: |-
delete the data in table
<br>
operationId: TableController.Delete
parameters:
- in: path
@ -178,7 +197,9 @@ paths:
get:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.GetAllTableColumn
parameters:
- in: path
@ -200,7 +221,9 @@ paths:
get:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.GetAllTableColumnRestriction
parameters:
- in: path
@ -227,7 +250,9 @@ paths:
get:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.GetAllTableColumnRestrictionSortkeys
parameters:
- in: path
@ -254,7 +279,9 @@ paths:
get:
tags:
- t
description: get all Datas
description: |-
get all Datas
<br>
operationId: TableController.GetAllTableColumnRestrictionSortkeysDir
parameters:
- in: path
@ -277,6 +304,73 @@ paths:
description: '{string} success !'
"403":
description: no table
/ui/{fid}:
get:
tags:
- ui
description: |-
create access form
<br>
operationId: UiController.form
parameters:
- in: path
name: fid
description: The fid of the form
required: true
type: string
responses:
"200":
description: json form
"403":
description: body is empty
/ui/{fid}/{uid}:
get:
tags:
- ui
description: |-
create access form
<br>
operationId: UiController.form
parameters:
- in: path
name: fid
description: The fid of the form
required: true
type: string
- in: path
name: uid
description: The uid you want to edit
required: true
type: string
responses:
"200":
description: json form
"403":
description: body is empty
/ui/{uid}:
post:
tags:
- ui
description: |-
insert access
<br>
operationId: UiController.Access form data post
parameters:
- in: path
name: uid
description: The uid you want to edit
required: true
type: string
- in: body
name: body
description: body of jsonform data
schema:
$ref: '#/definitions/form'
responses:
"200":
description: json
"403":
description: body is empty
definitions:
Credential:
title: Credential
@ -284,6 +378,9 @@ definitions:
TableQuery:
title: TableQuery
type: object
form:
title: form
type: object
json:
title: json
type: object
@ -300,3 +397,6 @@ tags:
- name: l
description: |
Operations about login
- name: ui
description: |
Operations about table