comnpany to cm

This commit is contained in:
ctengiz
2024-06-14 17:19:38 +03:00
parent a28576960e
commit f54c5660ea
15 changed files with 50 additions and 74 deletions

View File

@@ -13,7 +13,7 @@ create table company (
constraint uq_company unique (clid, code)
);
CREATE TRIGGER zl_company before INSERT or UPDATE ON company
CREATE TRIGGER zl_company before INSERT or UPDATE ON cm
FOR EACH ROW EXECUTE FUNCTION zllog();
create table company_usr (
@@ -22,5 +22,5 @@ create table company_usr (
usr_id dmn_usrid,
constraint uq_company_usr unique (company_id, usr_id),
constraint fk_company_usr_company foreign key (company_id)
references company(id) on update cascade on delete cascade
references cm(id) on update cascade on delete cascade
);

View File

@@ -1 +1 @@
alter table company add tmpl jsonb;
alter table cm add tmpl jsonb;

View File

@@ -0,0 +1,12 @@
alter table public.cm
rename to cm;
alter table public.cm
rename column title to name;
alter table public.company_usr
rename to cm_usr;
alter table public.cm_usr
rename column company_id to cm_id;

View File

@@ -1,13 +1,13 @@
-- << Create
insert into company ( clid
insert into cm ( clid
, code
, title
, name
, is_active
, notes
, tmpl)
values ( @clid
, @code
, @title
, @name
, @is_active
, @notes
, @tmpl)
@@ -18,20 +18,19 @@ returning id
select clid
, id
, code
, title
, name
, is_active
, notes
, tmpl
from company
from cm
where id = $1
-- Read >>
-- << Update
update company
set clid = @clid
, code = @code
, title = @title
update cm
set code = @code
, name = @name
, is_active = @is_active
, notes = @notes
, tmpl = @tmpl
@@ -41,7 +40,7 @@ where id = @id
-- << Delete
delete
from company
from cm
where id = $1
-- Delete >>
@@ -49,12 +48,12 @@ where id = $1
select clid
, id
, code
, title
, name
, is_active
, notes
, tmpl
from company {{.Where}}
from cm {{.Where}}
{{.OrderBy}}
{{.Rows}}
-- List >>

View File

@@ -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

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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) {

View File

@@ -5,6 +5,7 @@ import (
"git.makki.io/makki/libgo/dbu"
"git.makki.io/makki/libgo/mlog"
"git.makki.io/makki/libgo/svc"
"git.notitek.com.tr/common/notgo/nauth"
"time"
)
@@ -35,7 +36,7 @@ func main() {
if svc.S.DevMode() {
expire = time.Hour * 48
}
err = s.SubscribeToAuthServer(expire)
err = nauth.SubscribeToAuthServer(s.Ctx, expire)
if err != nil {
mlog.Fatal(err)
}

View File

@@ -9,10 +9,10 @@ import (
)
type Company struct {
Clid int64 `db:"clid" json:"-"`
ClID int64 `db:"clid" json:"-"`
ID int64 `db:"id"`
Code string `db:"code"`
Title null.String `db:"title"`
Name null.String `db:"name"`
IsActive bool `db:"is_active"`
Notes null.String `db:"notes"`
@@ -30,7 +30,7 @@ func New() *Company {
}
func DbRead(ctx context.Context, id int64) (*Company, error) {
rp, err := dbu.NewRepoWithFile(ctx, "company", nil)
rp, err := dbu.NewRepoWithFile(ctx, "cm", nil)
if err != nil {
return nil, err
}
@@ -55,7 +55,7 @@ func DbDelete(ctx context.Context, id int64, log bool, usrID *int64) error {
}
defer tx.Rollback(ctx)
rp, err := dbu.NewRepoWithFile(ctx, "company", tx)
rp, err := dbu.NewRepoWithFile(ctx, "cm", tx)
if err != nil {
return err
}
@@ -66,7 +66,7 @@ func DbDelete(ctx context.Context, id int64, log bool, usrID *int64) error {
if err != nil {
return dbu.ParsedErrSuppressNoRows(err)
}
err = dbu.DB.LogDMLTx("d", "company", oldData.ID, usrID, "", oldData, nil, tx)
err = dbu.DB.LogDMLTx("d", "cm", oldData.ID, usrID, "", oldData, nil, tx)
if err != nil {
slog.Error(err.Error())
}
@@ -81,9 +81,9 @@ func DbDelete(ctx context.Context, id int64, log bool, usrID *int64) error {
}
func (m *Company) DbCreate(ctx context.Context, clID int64, log bool, usrID *int64) error {
m.Clid = clID
m.ClID = clID
rp, err := dbu.NewRepoWithFile(ctx, "company", nil)
rp, err := dbu.NewRepoWithFile(ctx, "cm", nil)
if err != nil {
return err
}
@@ -94,7 +94,7 @@ func (m *Company) DbCreate(ctx context.Context, clID int64, log bool, usrID *int
}
if log {
err = dbu.DB.LogDMLTx("c", "company", m.ID, usrID, "", nil, m, nil)
err = dbu.DB.LogDMLTx("c", "cm", m.ID, usrID, "", nil, m, nil)
if err != nil {
slog.Error(err.Error())
}
@@ -110,7 +110,7 @@ func (m *Company) DbUpdate(ctx context.Context, log bool, usrID *int64) error {
}
defer tx.Rollback(ctx)
rp, err := dbu.NewRepoWithFile(ctx, "company", tx)
rp, err := dbu.NewRepoWithFile(ctx, "cm", tx)
if err != nil {
return err
}
@@ -121,7 +121,7 @@ func (m *Company) DbUpdate(ctx context.Context, log bool, usrID *int64) error {
if err != nil {
return err
}
err = dbu.DB.LogDMLTx("u", "company", oldData.ID, usrID, "", oldData, m, tx)
err = dbu.DB.LogDMLTx("u", "cm", oldData.ID, usrID, "", oldData, m, tx)
if err != nil {
slog.Error(err.Error())
}

View File

@@ -5,14 +5,12 @@ const t = i18n.global.t
class Company extends Model {
ID = null
Code = ''
Title = ''
Name = ''
IsActive = true
Notes = ''
Tmpl = ''
_colOptions = {
ID: {
label: t('Company.ID'),
@@ -40,7 +38,7 @@ class Company extends Model {
},
Title: {
Name: {
label: t('Company.Title'),
visible: true,
dataType: 'text', //numeric, text, date, bool, datetime, time, inet

View File

@@ -21,7 +21,7 @@
/>
<q-input class="col-xs-12 col-sm-6"
v-model="model.Title"
v-model="model.Name"
:label="t('Company.Title')"
bottom-slots
:rules="[]"

View File

@@ -10,7 +10,7 @@
:label="t('selectCompany')"
:options="ld.companies"
option-value="ID"
option-label="Title"
option-label="Name"
dense
options-dense
outlined

View File

@@ -15,7 +15,7 @@
:label="t('selectCompany')"
:options="ld.companies"
option-value="ID"
option-label="Title"
option-label="Name"
dense
options-dense
outlined