readme updated

This commit is contained in:
ycc 2022-04-20 15:24:29 +02:00
parent 5e9ad05a9c
commit 5f3238e9f6

View File

@ -18,15 +18,23 @@ type TableController struct {
beego.Controller beego.Controller
} }
// @Title Post type TableQuery struct {
// @Description post data in table Table string `json:"table,omitempty"`
Columns string `json:"columns,omitempty"`
Restriction string `json:"restriction,omitempty"`
Sortkeys string `json:"sortkeys,omitempty"`
Direction string `json:"direction,omitempty"`
}
// @Title Put data in table
// @Description put data in table
// @Param table path string true "Name of the table" // @Param table path string true "Name of the table"
// @Param data body json true "body for data content (Json format)" // @Param data body json true "body for data content (Json format)"
// @Success 200 {string} success // @Success 200 {string} success
// @Failure 403 post issue // @Failure 403 :table put issue
// @router /:table [post] // @router /:table [put]
func (t *TableController) Post() { func (t *TableController) Put() {
// var FilterUserPost = func(ctx *context.Context) { // var FilterUserPost = func(ctx *context.Context) {
// if strings.HasPrefix(ctx, "/") { // if strings.HasPrefix(ctx, "/") {
@ -212,3 +220,25 @@ func (t *TableController) GetAllTableColumnRestrictionSortkeysDir() {
t.ServeJSON() t.ServeJSON()
db.Close() db.Close()
} }
// @Title TablePost
// @Description get all Datas
// @Param table path string true "Name of the table"
// @Param body body TableQuery true "TableQuery"
// @Success 200 {string} success !
// @Failure 403 no table
// @router /:table [post]
func (t *TableController) TablePost() {
table := t.GetString(":table")
var request TableQuery
json.Unmarshal(t.Ctx.Input.RequestBody, &request)
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
data, err := db.Table(table).GetAssociativeArray(strings.Split(request.Columns, ","), request.Restriction, strings.Split(request.Sortkeys, ","), request.Direction)
if err != nil {
log.Error().Msg(err.Error())
}
t.Data["json"] = data
t.ServeJSON()
db.Close()
}