Compare commits

..

5 Commits

Author SHA1 Message Date
51d8f0822f update migration 2025-01-15 14:05:43 +03:00
ctengiz
a2215b9363 upgrade code 2025-01-15 11:50:12 +03:00
ctengiz
20e4a15286 nadmin fixes 2024-06-23 21:09:24 +03:00
ctengiz
29ca0b9965 fix 2024-06-14 17:21:20 +03:00
ctengiz
f54c5660ea comnpany to cm 2024-06-14 17:19:38 +03:00
21 changed files with 126 additions and 80 deletions

View File

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

View File

@@ -0,0 +1,3 @@
alter table cm_usr drop constraint uq_company_usr;
alter table cm_usr rename cm_id to cmid;
alter table cm_usr add constraint uq_cm_usr unique (cmid, usr_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 >>

Binary file not shown.

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,10 @@
package api
import (
"bordro-esleme/api/public"
"fmt"
"git.makki.io/makki/libgo/napi"
"git.makki.io/makki/libgo/nauth"
"git.makki.io/makki/libgo/mhttp"
"git.notitek.com.tr/common/notgo/napi"
"git.notitek.com.tr/common/notgo/nauth"
"net/http"
"os"
"path"
@@ -20,6 +20,20 @@ import (
)
func HttpHandler(re enums.TRunEnv) http.Handler {
lookup := &mhttp.Lookup{
DoClientCheck: true,
Funcs: map[string]mhttp.LookupFunc{
"entegrator": napi.Entegrators,
"invmarket": napi.InvMarket,
"usr": napi.Usr,
"rates": napi.Currency,
},
CompanyCheckQueries: []string{"mmitem", "acchart", "ficomp"},
JwtAuth: svc.S.JWT,
}
mux := chi.NewRouter()
// Gerekli middleware stack
@@ -51,17 +65,25 @@ 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) {
// Seek, verify and validate JWT tokens
r.Use(jwtauth.Verifier(svc.S.JWT))
r.Use(jwtauth.Verify(svc.S.JWT, jwtauth.TokenFromHeader, jwtauth.TokenFromCookie, jwtauth.TokenFromQuery))
// Handle valid / invalid tokens.
r.Use(nauth.CheckTokenValidity)
// Set clientID
r.Use(nauth.ClientID)
// Handle valid / invalid tokens.
r.Use(nauth.CheckTokenValidity)
// lookup
r.Method("post", "/lookup/{query}", lookup)
// sy routes
r.Get("/sy/companies", napi.CompanyList)

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

@@ -19,6 +19,7 @@
"jwt-decode": "^4.0.0",
"pinia": "^2.0.11",
"quasar": "^2.8.0",
"reconnecting-websocket": "^4.4.0",
"vue": "^3.4.18",
"vue-i18n": "^9.9.0",
"vue-router": "^4.0.12",

View File

@@ -64,6 +64,7 @@ module.exports = configure(function (ctx) {
// analyze: true,
env: {
showLangSelect: false,
wsActive: false,
apiAddr: (() => {
if (process.env.CUSTOM_API) {
return process.env.CUSTOM_API
@@ -150,6 +151,8 @@ module.exports = configure(function (ctx) {
'Loading',
'Dialog',
'Meta',
'LocalStorage',
'SessionStorage'
],
},

View File

@@ -3,12 +3,14 @@
import { EventBus } from 'quasar'
import { boot } from 'quasar/wrappers'
export default boot(({ app }) => {
const bus = new EventBus()
export default boot(({ app }) => {
// for Options API
app.config.globalProperties.$bus = bus
// for Composition API
app.provide('bus', bus)
})
export { bus }

View File

@@ -5,6 +5,7 @@ const prjI18n = {
app: 'Uygulamalar'
},
Company: {
ID: 'Şirket ID',
Code: 'Şirket Kod',
Title: 'Şirket Ad',
IsActive: 'Kullanımda',

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

View File

@@ -3,6 +3,7 @@ import { LocalStorage } from 'quasar'
import { api } from 'boot/axios'
import { jwtDecode } from "jwt-decode"
import Router from 'src/router/index'
import {bus} from 'boot/bus'
export const sessionName = 'bresSession'
@@ -10,17 +11,26 @@ const defaultState = {
LoggedIn: false,
IsAdmin: false,
Token: '',
UsrKSUID: '',
UsrKsuid: '',
UsrEmail: '',
UsrFullname: '',
UsrFullName: '',
Username: '',
ClientKSUID: '',
ClientKsuid: '',
ClientCode: '',
LicenseCode: '',
PkgConf: {}
PkgConf: {},
companyID: null
}
bus.on('companySelect', (companyID) => {
const store = useLoginStore()
//store.companyID = companyID
store.setCompanyID(companyID)
})
export const useLoginStore = defineStore('login', {
state: () => {
return JSON.parse(JSON.stringify(defaultState))
@@ -28,6 +38,11 @@ export const useLoginStore = defineStore('login', {
getters: {},
actions: {
setCompanyID(companyID) {
this.companyID = companyID
this.save()
},
login (payload) {
// kaldıysa önceki session'ı uçuralım
LocalStorage.remove(sessionName)
@@ -58,6 +73,14 @@ export const useLoginStore = defineStore('login', {
}
},
updateProfile (payload) {
this.UsrFullName = payload.fullname
this.UsrEmail = payload.email
this.Username = payload.username
this.save()
},
updateState (payload) {
Object.assign(this, payload)
api.defaults.headers.common['Authorization'] = `Bearer ${payload.Token}`
@@ -76,9 +99,17 @@ export const useLoginStore = defineStore('login', {
}
},
save () {
const pl = {}
Object.keys(defaultState).forEach((key) => {
pl[key] = this[key]
})
LocalStorage.set(sessionName, pl)
},
IsLoggedIn () {
return this.LoggedIn
}
},
}
})

View File

@@ -2593,6 +2593,11 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"
reconnecting-websocket@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz#3b0e5b96ef119e78a03135865b8bb0af1b948783"
integrity sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==
register-service-worker@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/register-service-worker/-/register-service-worker-1.7.2.tgz#6516983e1ef790a98c4225af1216bc80941a4bd2"