comnpany to cm
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"git.makki.io/makki/libgo/cmn"
|
||||
"git.makki.io/makki/libgo/dbu"
|
||||
"git.makki.io/makki/libgo/mhttp"
|
||||
"git.makki.io/makki/libgo/nauth"
|
||||
"git.notitek.com.tr/common/notgo/nauth"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"net/http"
|
||||
)
|
||||
@@ -146,7 +146,7 @@ func companyList(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
rp, err := dbu.NewRepoWithFile(r.Context(), "company", nil)
|
||||
rp, err := dbu.NewRepoWithFile(r.Context(), "cm", nil)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
|
||||
@@ -19,7 +19,7 @@ func tmplPost(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sq := "update company set tmpl = $2 where id = $1"
|
||||
sq := "update cm set tmpl = $2 where id = $1"
|
||||
_, err = dbu.DB.Exec(r.Context(), sq, companyID, body)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
@@ -33,7 +33,7 @@ func tmplGet(w http.ResponseWriter, r *http.Request) {
|
||||
companyID := cmn.StrToInt64(chi.URLParam(r, "companyID"))
|
||||
var body json.RawMessage
|
||||
|
||||
sq := "select tmpl from company where id = $1"
|
||||
sq := "select tmpl from cm where id = $1"
|
||||
err := dbu.DB.QueryRow(r.Context(), sq, companyID).Scan(&body)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package public
|
||||
|
||||
import (
|
||||
"git.makki.io/makki/libgo/mhttp"
|
||||
"git.makki.io/makki/libgo/svc"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func login(w http.ResponseWriter, r *http.Request) {
|
||||
authResp, err := svc.S.Authenticate(r)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
clientResp := authResp.GetEndUserResponse()
|
||||
mhttp.ResponseSuccess(w, clientResp)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package public
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Router() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
// user authentication
|
||||
r.Post("/login", login)
|
||||
return r
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bordro-esleme/api/public"
|
||||
"fmt"
|
||||
"git.makki.io/makki/libgo/napi"
|
||||
"git.makki.io/makki/libgo/nauth"
|
||||
"git.notitek.com.tr/common/notgo/napi"
|
||||
"git.notitek.com.tr/common/notgo/nauth"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -51,8 +50,7 @@ func HttpHandler(re enums.TRunEnv) http.Handler {
|
||||
|
||||
mux.Route("/api", func(mr chi.Router) {
|
||||
// Public Route endpoints
|
||||
mr.Mount("/", public.Router())
|
||||
//mr.Mount("/admin", admin.Router())
|
||||
mr.Post("/login", napi.Login)
|
||||
|
||||
//protected end points
|
||||
mr.Group(func(r chi.Router) {
|
||||
|
||||
Reference in New Issue
Block a user