compnay select

This commit is contained in:
ctengiz
2024-03-25 23:09:30 +03:00
parent 18ff9ddbfd
commit 888d0800bb
18 changed files with 315 additions and 280 deletions

View File

@@ -1,93 +0,0 @@
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,13 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @function Create
* @returns {Promise<void>}
**/
export async function Create() {
return Call.ByName("company.Company.Create", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -0,0 +1,25 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @function Companies
* @returns {Promise<Company[], void>}
**/
export async function Companies() {
return Call.ByName("dbsrv.Srv.Companies", ...Array.prototype.slice.call(arguments, 0));
}
/**
* @function CreateCompany
* @param name {string}
* @param memberNumber {string}
* @param username {string}
* @param password {string}
* @returns {Promise<void>}
**/
export async function CreateCompany(name, memberNumber, username, password) {
return Call.ByName("dbsrv.Srv.CreateCompany", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -1,13 +0,0 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @function ClaimFile
* @returns {Promise<string>}
**/
export async function ClaimFile() {
return Call.ByName("main.BotService.ClaimFile", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -1,18 +0,0 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {Call} from '@wailsio/runtime';
/**
* @typedef {import('./models').LoginUser} LoginUser
*/
/**
* @function Login
* @param userName {string}
* @param password {string}
* @returns {Promise<LoginUser>}
**/
export async function Login(userName, password) {
return Call.ByName("main.LoginService.Login", ...Array.prototype.slice.call(arguments, 0));
}

View File

@@ -1,33 +0,0 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export const LoginUser = class {
/**
* Creates a new LoginUser instance.
* @constructor
* @param {Object} source - The source object to create the LoginUser.
* @param {string} source.UserName
* @param {string} source.password
* @param {string} source.Token
* @param {boolean} source.LoggedIn
*/
constructor(source = {}) {
const { userName = "", password = "", token = "", loggedIn = false } = source;
this.userName = userName;
this.password = password;
this.token = token;
this.loggedIn = loggedIn;
}
/**
* Creates a new LoginUser instance from a string or object.
* @param {string|object} source - The source data to create a LoginUser instance from.
* @returns {LoginUser} A new LoginUser instance.
*/
static createFrom(source) {
let parsedSource = typeof source === 'string' ? JSON.parse(source) : source;
return new LoginUser(parsedSource);
}
};

View File

@@ -1,33 +0,0 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export const LoginUser = class {
/**
* Creates a new LoginUser instance.
* @constructor
* @param {Object} source - The source object to create the LoginUser.
* @param {string} source.UserName
* @param {string} source.password
* @param {string} source.Token
* @param {boolean} source.LoggedIn
*/
constructor(source = {}) {
const { userName = "", password = "", token = "", loggedIn = false } = source;
this.userName = userName;
this.password = password;
this.token = token;
this.loggedIn = loggedIn;
}
/**
* Creates a new LoginUser instance from a string or object.
* @param {string|object} source - The source data to create a LoginUser instance from.
* @returns {LoginUser} A new LoginUser instance.
*/
static createFrom(source) {
let parsedSource = typeof source === 'string' ? JSON.parse(source) : source;
return new LoginUser(parsedSource);
}
};

View File

@@ -1,47 +0,0 @@
<template>
<q-item
clickable
:to="link"
>
<q-item-section
v-if="icon"
avatar
>
<q-icon :name="icon" />
</q-item-section>
<q-item-section>
<q-item-label>{{ title }}</q-item-label>
<q-item-label caption>{{ caption }}</q-item-label>
</q-item-section>
</q-item>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'EssentialLink',
props: {
title: {
type: String,
required: true
},
caption: {
type: String,
default: ''
},
link: {
type: String,
default: '#'
},
icon: {
type: String,
default: ''
}
}
})
</script>

View File

@@ -1,14 +1,14 @@
<template> <template>
<q-dialog ref="dialogRef" persistent @hide="onDialogHide"> <q-dialog ref="dialogRef" persistent @hide="onDialogHide">
<q-card> <q-card style="width: 600px;">
<q-card-section class="bg-purple text-white"> <q-card-section class="bg-purple text-white">
<span class="text-h6 text-weight-bolder">Veri Tabanı Bağlantısı</span> <span class="text-h6 text-weight-bolder">Şirket Ekleme</span>
</q-card-section> </q-card-section>
<q-card-section> <q-card-section>
<q-input v-model="ld.host" label="Host"/> <q-input v-model="ld.name" label="Şirket Adı"/>
<q-input v-model.number="ld.port" label="Port"/> <q-input v-model="ld.memberNumber" label="Üye No"/>
<q-input v-model="ld.username" label="Username"/> <q-input v-model="ld.username" label="Kullanıcı Adı"/>
<q-input v-model="ld.userpass" label="Password"/> <q-input v-model="ld.password" label="Parola"/>
</q-card-section> </q-card-section>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn label="İptal" <q-btn label="İptal"
@@ -17,7 +17,7 @@
@click="onDialogCancel" @click="onDialogCancel"
/> />
<q-btn label="Bağlan" no-caps outline color="positive" <q-btn label="Kaydet" no-caps outline color="positive"
icon="check" icon="check"
@click="onDialogOK(toRaw(ld))"/> @click="onDialogOK(toRaw(ld))"/>
</q-card-actions> </q-card-actions>
@@ -38,10 +38,10 @@ defineEmits([
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent() const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
const ld = reactive({ const ld = reactive({
host: '127.0.0.1', name: '',
port: 5432, memberNumber: '',
username: 'postgres', username: '',
userpass: 'tayitkan', password: '',
}) })

View File

@@ -15,7 +15,7 @@
Bordro Robotu Bordro Robotu
</q-toolbar-title> </q-toolbar-title>
<q-space /> <q-space/>
<q-btn <q-btn
icon="mdi-database-sync" flat icon="mdi-database-sync" flat
@@ -32,21 +32,11 @@
> >
<q-btn <q-btn
icon="mdi-database-sync" icon="mdi-database-sync"
@click="getDatabaseList"
/> />
<q-list> <q-list>
<q-item-label
header
>
Essential Links
</q-item-label>
<EssentialLink
v-for="link in linksList"
:key="link.title"
v-bind="link"
/>
</q-list> </q-list>
</q-drawer> </q-drawer>
@@ -58,14 +48,12 @@
<script setup> <script setup>
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import EssentialLink from 'components/EssentialLink.vue'
import { useQuasar } from 'quasar' import { useQuasar } from 'quasar'
import DbConnect from 'components/dlg/DbConnect.vue'
const $q = useQuasar() const $q = useQuasar()
const ld = reactive({ const ld = reactive({
selectedDB: '', selectedDB: '',
databases: [] databases: [],
}) })
const linksList = [ const linksList = [
@@ -87,7 +75,7 @@ const toggleLeftDrawer = function () {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.header-input .q-field .q-field__control-container .q-field__native,.q-field__label { .header-input .q-field .q-field__control-container .q-field__native, .q-field__label {
color: white!important; color: white !important;
} }
</style> </style>

View File

@@ -1,18 +1,67 @@
<template> <template>
<q-page padding> <q-page padding>
AAAAA <q-card>
<img <q-card-section>
alt="Quasar logo" <div class="row">
src="~assets/quasar-logo-vertical.svg" <div class="col">
style="width: 200px; height: 200px" <q-select v-model="ld.companyID"
label="Şirket"
option-label="Name"
option-value="Name"
:options="ld.companies"
map-options
emit-value
> >
<template v-slot:after>
<q-btn
label="Yeni Şirket Ekle"
color="primary"
@click="createCompany"
/>
</template>
</q-select>
</div>
</div>
</q-card-section>
</q-card>
</q-page> </q-page>
</template> </template>
<script> <script setup>
import { defineComponent } from 'vue' import { onMounted, reactive } from 'vue'
import Company from 'components/dlg/Company.vue'
import { useQuasar } from 'quasar'
import { Companies, CreateCompany } from 'app/bindings/lib/dbsrv/Srv'
export default defineComponent({ const $q = useQuasar()
name: 'IndexPage'
const ld = reactive({
companyID: null,
companies: [],
}) })
onMounted(()=> {
getCompanies()
})
const createCompany = function () {
$q.dialog({
component: Company,
parent: this,
// ----------------------
// props that are passed to component instancde
}).onOk(data => {
CreateCompany(data.name, data.memberNumber, data.username, data.password)
})
}
const getCompanies = function () {
ld.companies.splice(0)
Companies().then(res => {
ld.companies.push(...res)
})
}
</script> </script>

View File

@@ -4,12 +4,29 @@ go 1.22
toolchain go1.22.1 toolchain go1.22.1
require github.com/wailsapp/wails/v3 v3.0.0-alpha.0 require (
github.com/jmoiron/sqlx v1.3.5
github.com/wailsapp/wails/v3 v3.0.0-alpha.0
modernc.org/sqlite v1.29.5
)
require ( require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/imdario/mergo v0.3.12 // indirect github.com/imdario/mergo v0.3.12 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect github.com/leaanthony/slicer v1.5.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 // indirect github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 // indirect
golang.org/x/net v0.21.0 // indirect golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.41.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
) )

View File

@@ -1,23 +1,71 @@
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY= github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY= github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 h1:Wn+nhnS+VytzE0PegUzSh4T3hXJCtggKGD/4U5H9+wQ= github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 h1:Wn+nhnS+VytzE0PegUzSh4T3hXJCtggKGD/4U5H9+wQ=
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8= github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8=
github.com/wailsapp/wails/v3 v3.0.0-alpha.0 h1:T5gqG98Xr8LBf69oxlPkhpsFD59w2SnqUZk6XHj8Zoc= github.com/wailsapp/wails/v3 v3.0.0-alpha.0 h1:T5gqG98Xr8LBf69oxlPkhpsFD59w2SnqUZk6XHj8Zoc=
github.com/wailsapp/wails/v3 v3.0.0-alpha.0/go.mod h1:OAfO5bP0TSUvCIHZYc6Dqfow/9RqxzHvYtmhWPpo1c0= github.com/wailsapp/wails/v3 v3.0.0-alpha.0/go.mod h1:OAfO5bP0TSUvCIHZYc6Dqfow/9RqxzHvYtmhWPpo1c0=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk=
modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
modernc.org/sqlite v1.29.5 h1:8l/SQKAjDtZFo9lkJLdk8g9JEOeYRG4/ghStDCCTiTE=
modernc.org/sqlite v1.29.5/go.mod h1:S02dvcmm7TnTRvGhv8IGYyLnIt7AS2KPaB1F/71p75U=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

View File

@@ -0,0 +1,21 @@
package company
import (
"bordrobot/lib/db"
)
type Company struct {
Name string `db:"name"`
MemberNumber string `db:"member_number"`
Username string `db:"username"`
Password string `db:"password"`
}
func (c *Company) Create() error {
sq := `
insert into company (name, member_number, username, password)
VALUES (:name, :member_number, :username, :password)
`
_, err := db.DB.NamedExec(sq, &c)
return err
}

View File

@@ -0,0 +1,27 @@
package company
import (
"bordrobot/lib/db"
"testing"
)
func TestCompany_Create(t *testing.T) {
err := db.InitDB("../..")
if err != nil {
t.Fatal(err)
}
c := &Company{
Name: "Deneme Firması",
MemberNumber: "1234",
Username: "u1",
Password: "p1",
}
err = c.Create()
if err != nil {
t.Fatal(err)
}
db.DB.Close()
}

50
app/lib/db/db.go Normal file
View File

@@ -0,0 +1,50 @@
package db
import (
"database/sql"
"fmt"
"github.com/jmoiron/sqlx"
_ "modernc.org/sqlite"
)
var DB *sqlx.DB
func createTableIfNotExists(tableName string, schema string) error {
var tmpName string
sqCheck := "SELECT name FROM sqlite_master WHERE type='table' AND name=?"
err := DB.QueryRow(sqCheck, tableName).Scan(&tmpName)
if err != nil {
if err != sql.ErrNoRows {
return err
}
} else {
return nil
}
_, err = DB.Exec(schema)
return err
}
func InitDB(path string) error {
var err error
fname := fmt.Sprintf("%s/%s", path, "bordro_robot.db")
DB, err = sqlx.Open("sqlite", fname)
if err != nil {
return err
}
companySchema := `
create table Company (
name text not null unique,
member_number text not null,
username text not null,
password text not null
)
`
err = createTableIfNotExists("company", companySchema)
return err
}

25
app/lib/dbsrv/dbsrv.go Normal file
View File

@@ -0,0 +1,25 @@
package dbsrv
import (
"bordrobot/lib/company"
"bordrobot/lib/db"
)
type Srv struct{}
func (ds *Srv) Companies() ([]company.Company, error) {
var res []company.Company
err := db.DB.Select(&res, "SELECT * FROM company order by 1")
return res, err
}
func (ds *Srv) CreateCompany(name, memberNumber, username, password string) error {
c := &company.Company{
Name: name,
MemberNumber: memberNumber,
Username: username,
Password: password,
}
return c.Create()
}

View File

@@ -1,6 +1,9 @@
package main package main
import ( import (
"bordrobot/lib/company"
"bordrobot/lib/db"
"bordrobot/lib/dbsrv"
"embed" "embed"
"log" "log"
"time" "time"
@@ -21,6 +24,12 @@ var assets embed.FS
// logs any error that might occur. // logs any error that might occur.
func main() { func main() {
//Init SqLite database
err := db.InitDB(".")
if err != nil {
log.Fatal(err)
}
// Create a new Wails application by providing the necessary options. // Create a new Wails application by providing the necessary options.
// Variables 'Name' and 'Description' are for application metadata. // Variables 'Name' and 'Description' are for application metadata.
// 'Assets' configures the asset server with the 'FS' variable pointing to the frontend files. // 'Assets' configures the asset server with the 'FS' variable pointing to the frontend files.
@@ -30,8 +39,8 @@ func main() {
Name: "bordro-robotu", Name: "bordro-robotu",
Description: "A demo of using raw HTML & CSS", Description: "A demo of using raw HTML & CSS",
Bind: []any{ Bind: []any{
&BotService{}, &company.Company{},
&LoginService{}, &dbsrv.Srv{},
}, },
Assets: application.AssetOptions{ Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets), Handler: application.AssetFileServerFS(assets),
@@ -70,7 +79,7 @@ func main() {
} }
}() }()
// Run the application. This blocks until the application has been exited. // Run the application. This blocks until the application has been exited.
err := app.Run() err = app.Run()
// If an error occurred while running the application, log it and exit. // If an error occurred while running the application, log it and exit.
if err != nil { if err != nil {