alfa release
This commit is contained in:
@@ -60,7 +60,7 @@ func companyCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err = data.DbCreate(r.Context(), true, tc.UsrID())
|
||||
err = data.DbCreate(r.Context(), tc.ClientID(), true, tc.UsrID())
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
|
||||
44
svc/api/atmpl.go
Normal file
44
svc/api/atmpl.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.makki.io/makki/libgo/cmn"
|
||||
"git.makki.io/makki/libgo/dbu"
|
||||
"git.makki.io/makki/libgo/mhttp"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func tmplPost(w http.ResponseWriter, r *http.Request) {
|
||||
companyID := cmn.StrToInt64(chi.URLParam(r, "companyID"))
|
||||
var body json.RawMessage
|
||||
|
||||
err := cmn.BodyToJsonReq(r, &body)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
sq := "update company set tmpl = $2 where id = $1"
|
||||
_, err = dbu.DB.Exec(r.Context(), sq, companyID, body)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
mhttp.ResponseSuccess(w, true)
|
||||
}
|
||||
|
||||
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"
|
||||
err := dbu.DB.QueryRow(r.Context(), sq, companyID).Scan(&body)
|
||||
if err != nil {
|
||||
mhttp.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
mhttp.ResponseSuccess(w, body)
|
||||
}
|
||||
@@ -71,6 +71,10 @@ func HttpHandler(re enums.TRunEnv) http.Handler {
|
||||
r.Put("/company", companyUpdate)
|
||||
r.Post("/company", companyCreate)
|
||||
r.Delete("/company/{id:[0-9]+}", companyDelete)
|
||||
|
||||
r.Post("/tmpl/{companyID:[0-9]+}", tmplPost)
|
||||
r.Get("/tmpl/{companyID:[0-9]+}", tmplGet)
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user