From cb91e4dfcf1b53a39e23c51803abc3513128c7c4 Mon Sep 17 00:00:00 2001 From: ctengiz Date: Mon, 15 Apr 2024 10:40:28 +0300 Subject: [PATCH] fixes --- db/sqls/company.sql | 60 +++++++++++++++++++++++++++++++++++++++++++++ svc/api/zhandler.go | 18 +++----------- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/db/sqls/company.sql b/db/sqls/company.sql index e69de29..06a8a8f 100644 --- a/db/sqls/company.sql +++ b/db/sqls/company.sql @@ -0,0 +1,60 @@ +-- << Create +insert into company ( clid + , code + , title + , is_active + , notes + , tmpl) +values ( @clid + , @code + , @title + , @is_active + , @notes + , @tmpl) +returning id +-- Create >> + +-- << Read +select clid + , id + , code + , title + , is_active + , notes + , tmpl + +from company +where id = $1 +-- Read >> + +-- << Update +update company +set clid = @clid + , code = @code + , title = @title + , is_active = @is_active + , notes = @notes + , tmpl = @tmpl + +where id = @id +-- Update >> + +-- << Delete +delete +from company +where id = $1 +-- Delete >> + +-- << List +select clid + , id + , code + , title + , is_active + , notes + , tmpl + +from company {{.Where}} +{{.OrderBy}} +{{.Rows}} +-- List >> diff --git a/svc/api/zhandler.go b/svc/api/zhandler.go index 68aa576..0d1d41c 100644 --- a/svc/api/zhandler.go +++ b/svc/api/zhandler.go @@ -62,6 +62,9 @@ func HttpHandler(re enums.TRunEnv) http.Handler { // Handle valid / invalid tokens. r.Use(nauth.CheckTokenValidity) + // sy routes + r.Get("/sy/companies", napi.CompanyList) + // company routes r.Get("/company/{id:[0-9]+}", companyGet) r.Get("/company", companyList) @@ -71,21 +74,6 @@ func HttpHandler(re enums.TRunEnv) http.Handler { }) }) - mux.Route("/sy", func(mr chi.Router) { - // Public Route endpoints - - //protected end points - mr.Group(func(r chi.Router) { - // Seek, verify and validate JWT tokens - r.Use(jwtauth.Verifier(svc.S.JWT)) - - // Handle valid / invalid tokens. - r.Use(nauth.CheckTokenValidity) - - r.Get("/companies", napi.CompanyList) - }) - }) - // Handle Websocket // mux.HandleFunc("/ws", ws.Handle)