ready for rpa
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package company
|
||||
|
||||
import (
|
||||
"bordrobot/lib/db"
|
||||
"bordrobot/lib/run"
|
||||
)
|
||||
|
||||
type Company struct {
|
||||
@@ -16,6 +16,6 @@ func (c *Company) Create() error {
|
||||
insert into company (name, member_number, username, password)
|
||||
VALUES (:name, :member_number, :username, :password)
|
||||
`
|
||||
_, err := db.DB.NamedExec(sq, &c)
|
||||
_, err := run.DB.NamedExec(sq, &c)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package company
|
||||
|
||||
import (
|
||||
"bordrobot/lib/db"
|
||||
"bordrobot/lib/run"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCompany_Create(t *testing.T) {
|
||||
err := db.InitDB("../..")
|
||||
err := run.InitDB("../..")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -23,5 +23,5 @@ func TestCompany_Create(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
db.DB.Close()
|
||||
run.DB.Close()
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
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()
|
||||
}
|
||||
5
app/lib/run/app.go
Normal file
5
app/lib/run/app.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package run
|
||||
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
var APP *application.App
|
||||
@@ -1,4 +1,4 @@
|
||||
package db
|
||||
package run
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
76
app/lib/srv/srv.go
Normal file
76
app/lib/srv/srv.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package srv
|
||||
|
||||
import (
|
||||
"bordrobot/lib/company"
|
||||
"bordrobot/lib/run"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/xuri/excelize/v2"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type Srv struct {
|
||||
xlsFileName string
|
||||
}
|
||||
|
||||
func (s *Srv) Companies() ([]company.Company, error) {
|
||||
var res []company.Company
|
||||
err := run.DB.Select(&res, "SELECT * FROM company order by 1")
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (s *Srv) CreateCompany(name, memberNumber, username, password string) error {
|
||||
c := &company.Company{
|
||||
Name: name,
|
||||
MemberNumber: memberNumber,
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
|
||||
return c.Create()
|
||||
}
|
||||
|
||||
func (s *Srv) UploadExcel() string {
|
||||
dialog := application.OpenFileDialog()
|
||||
dialog.AddFilter("Excel Dosyaları", "*.xls;*.xlsx")
|
||||
dialog.SetTitle("Bordro Excel Dosyası Yükleme")
|
||||
file, err := dialog.PromptForSingleSelection()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
s.xlsFileName = file
|
||||
return file
|
||||
}
|
||||
|
||||
func (s *Srv) Rpa(month float64, year float64) error {
|
||||
//wails nümerik değerleri float gönderiyor.. int gönderimi araştırılmalı
|
||||
slog.Debug("inputs", "year", year, "month", month)
|
||||
|
||||
f, err := excelize.OpenFile(s.xlsFileName)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
// Close the spreadsheet.
|
||||
if err := f.Close(); err != nil {
|
||||
slog.Error(err.Error())
|
||||
//return err
|
||||
}
|
||||
}()
|
||||
|
||||
sheets := f.GetSheetList()
|
||||
cols, err := f.GetCols(sheets[0])
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
return err
|
||||
}
|
||||
for _, row := range cols {
|
||||
run.APP.Events.Emit(&application.WailsEvent{
|
||||
Name: "logProcess",
|
||||
Data: row[1],
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user