step 5 : add comp longi & lati, check distance gql, trans clock in gql
This commit is contained in:
@@ -3,14 +3,14 @@ module com.sismedika.com.absensi
|
||||
go 1.21.5
|
||||
|
||||
require (
|
||||
github.com/99designs/gqlgen v0.17.42
|
||||
github.com/99designs/gqlgen v0.17.44-0.20240120140729-5524a399d35c
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/fsnotify/fsnotify v1.7.0
|
||||
github.com/go-chi/chi v1.5.5
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
github.com/rs/cors v1.10.1
|
||||
github.com/spf13/viper v1.18.2
|
||||
github.com/vektah/gqlparser/v2 v2.5.10
|
||||
github.com/vektah/gqlparser/v2 v2.5.11
|
||||
golang.org/x/crypto v0.18.0
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
github.com/99designs/gqlgen v0.17.42 h1:BVWDOb2VVHQC5k3m6oa0XhDnxltLLrU4so7x/u39Zu4=
|
||||
github.com/99designs/gqlgen v0.17.42/go.mod h1:GQ6SyMhwFbgHR0a8r2Wn8fYgEwPxxmndLFPhU63+cJE=
|
||||
github.com/99designs/gqlgen v0.17.44-0.20240120140729-5524a399d35c h1:7Bb7oV6i+qqaewxJycio3G6gObQts35FuYPai7Lk3ik=
|
||||
github.com/99designs/gqlgen v0.17.44-0.20240120140729-5524a399d35c/go.mod h1:lO0Zjy8MkZgBdv4T1U91x09r0e0WFOdhVUutlQs1Rsc=
|
||||
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
||||
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
|
||||
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
|
||||
@@ -87,8 +87,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc=
|
||||
github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU=
|
||||
github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
|
||||
github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8=
|
||||
github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
||||
# GraphQL schema example
|
||||
#
|
||||
# https://gqlgen.com/getting-started/
|
||||
|
||||
type Todo {
|
||||
id: ID!
|
||||
text: String!
|
||||
done: Boolean!
|
||||
user: User!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: ID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type Query {
|
||||
todos: [Todo!]!
|
||||
}
|
||||
|
||||
input NewTodo {
|
||||
text: String!
|
||||
userId: String!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createTodo(input: NewTodo!): Todo!
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
# model staff
|
||||
type Staff {
|
||||
staff_id: ID!
|
||||
nip: String!
|
||||
name: String!
|
||||
email: String!
|
||||
phone_number: String
|
||||
company_id: ID!
|
||||
company_name: String
|
||||
is_active: String
|
||||
is_login: String
|
||||
token: String
|
||||
expired: String
|
||||
id_google_sign_in: String!
|
||||
display_name_google_sign_in: String
|
||||
created_at: String
|
||||
last_updated_at: String
|
||||
staff_id: ID!
|
||||
nip: String!
|
||||
name: String!
|
||||
email: String!
|
||||
phone_number: String
|
||||
company_id: ID!
|
||||
company_name: String
|
||||
company_latitude:String
|
||||
company_longitude:String
|
||||
is_active: String
|
||||
is_login: String
|
||||
token: String
|
||||
expired: String
|
||||
id_google_sign_in: String!
|
||||
display_name_google_sign_in: String
|
||||
created_at: String
|
||||
last_updated_at: String
|
||||
}
|
||||
|
||||
# model token response ketika login
|
||||
|
||||
17
backend/graph/graphqls/transabsensi.graphqls
Normal file
17
backend/graph/graphqls/transabsensi.graphqls
Normal file
@@ -0,0 +1,17 @@
|
||||
# response error atau success dan set message
|
||||
type TransAbsensiResponse {
|
||||
status: String
|
||||
message: String
|
||||
}
|
||||
|
||||
# query
|
||||
extend type Query {
|
||||
# untuk cek distance dengan fungsi distance_v2 di database
|
||||
queryCheckDistance(M_StaffID:String!, M_CompanyID:String!, M_CompanyLatitude:String!, M_CompanyLongitude:String!, CurrentLatitude:String!, CurrentLongitude:String!) : TransAbsensiResponse!
|
||||
}
|
||||
|
||||
# mutation
|
||||
extend type Mutation {
|
||||
# untuk clock in absensi (absensi masuk)
|
||||
mutationClockInAttendance(T_TransactionM_AbsensiTypeID:String!, T_TransactionM_StaffID:String!, T_TransactionM_CompanyID:String!, T_TransactionCurrentLatitude:String!, T_TransactionCurrentLongitude:String!, T_TransactionDistance:String!, T_TransactionSelfiePhoto:String, T_TransactionNote:String):TransAbsensiResponse!
|
||||
}
|
||||
@@ -5,11 +5,6 @@ package model
|
||||
type Mutation struct {
|
||||
}
|
||||
|
||||
type NewTodo struct {
|
||||
Text string `json:"text"`
|
||||
UserID string `json:"userId"`
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
}
|
||||
|
||||
@@ -21,6 +16,8 @@ type Staff struct {
|
||||
PhoneNumber *string `json:"phone_number,omitempty"`
|
||||
CompanyID string `json:"company_id"`
|
||||
CompanyName *string `json:"company_name,omitempty"`
|
||||
CompanyLatitude *string `json:"company_latitude,omitempty"`
|
||||
CompanyLongitude *string `json:"company_longitude,omitempty"`
|
||||
IsActive *string `json:"is_active,omitempty"`
|
||||
IsLogin *string `json:"is_login,omitempty"`
|
||||
Token *string `json:"token,omitempty"`
|
||||
@@ -31,19 +28,12 @@ type Staff struct {
|
||||
LastUpdatedAt *string `json:"last_updated_at,omitempty"`
|
||||
}
|
||||
|
||||
type Todo struct {
|
||||
ID string `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Done bool `json:"done"`
|
||||
User *User `json:"user"`
|
||||
}
|
||||
|
||||
type TokenResponse struct {
|
||||
Token *string `json:"token,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
type TransAbsensiResponse struct {
|
||||
Status *string `json:"status,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,32 +1 @@
|
||||
package resolver
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.42
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"com.sismedika.com.absensi/graph/generated"
|
||||
"com.sismedika.com.absensi/graph/model"
|
||||
)
|
||||
|
||||
// CreateTodo is the resolver for the createTodo field.
|
||||
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) {
|
||||
panic(fmt.Errorf("not implemented: CreateTodo - createTodo"))
|
||||
}
|
||||
|
||||
// Todos is the resolver for the todos field.
|
||||
func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
|
||||
panic(fmt.Errorf("not implemented: Todos - todos"))
|
||||
}
|
||||
|
||||
// Mutation returns generated.MutationResolver implementation.
|
||||
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }
|
||||
|
||||
// Query returns generated.QueryResolver implementation.
|
||||
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
|
||||
@@ -2,12 +2,13 @@ package resolver
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.42
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.43-dev
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"com.sismedika.com.absensi/graph/generated"
|
||||
"com.sismedika.com.absensi/graph/model"
|
||||
staffinternal "com.sismedika.com.absensi/internal/staff"
|
||||
)
|
||||
@@ -35,12 +36,11 @@ func (r *queryResolver) StaffListBySearch(ctx context.Context, search *string, p
|
||||
panic(fmt.Errorf("not implemented: StaffListBySearch - staffListBySearch"))
|
||||
}
|
||||
|
||||
// !!! WARNING !!!
|
||||
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
|
||||
// one last chance to move it out of harms way if you want. There are two reasons this happens:
|
||||
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
|
||||
// it when you're done.
|
||||
// - You have helper methods in this file. Move them out to keep these resolver files clean.
|
||||
func (r *mutationResolver) GenerateToken(ctx context.Context, email string, idGoogleSignIn string, publickey string) (*model.TokenResponse, error) {
|
||||
panic(fmt.Errorf("not implemented: GenerateToken - generateToken"))
|
||||
}
|
||||
// Mutation returns generated.MutationResolver implementation.
|
||||
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }
|
||||
|
||||
// Query returns generated.QueryResolver implementation.
|
||||
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
|
||||
35
backend/graph/resolver/transabsensi.resolvers.go
Normal file
35
backend/graph/resolver/transabsensi.resolvers.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package resolver
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.43-dev
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"com.sismedika.com.absensi/graph/model"
|
||||
)
|
||||
|
||||
// MutationClockInAttendance is the resolver for the mutationClockInAttendance field.
|
||||
func (r *mutationResolver) MutationClockInAttendance(ctx context.Context, tTransactionMAbsensiTypeID string, tTransactionMStaffID string, tTransactionMCompanyID string, tTransactionCurrentLatitude string, tTransactionCurrentLongitude string, tTransactionDistance string, tTransactionSelfiePhoto *string, tTransactionNote *string) (*model.TransAbsensiResponse, error) {
|
||||
panic(fmt.Errorf("not implemented: MutationClockInAttendance - mutationClockInAttendance"))
|
||||
}
|
||||
|
||||
// QueryCheckDistance is the resolver for the queryCheckDistance field.
|
||||
func (r *queryResolver) QueryCheckDistance(ctx context.Context, mStaffID string, mCompanyID string, mCompanyLatitude string, mCompanyLongitude string, currentLatitude string, currentLongitude string) (*model.TransAbsensiResponse, error) {
|
||||
panic(fmt.Errorf("not implemented: QueryCheckDistance - queryCheckDistance"))
|
||||
}
|
||||
|
||||
// !!! WARNING !!!
|
||||
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
|
||||
// one last chance to move it out of harms way if you want. There are two reasons this happens:
|
||||
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
|
||||
// it when you're done.
|
||||
// - You have helper methods in this file. Move them out to keep these resolver files clean.
|
||||
func (r *mutationResolver) MClockInAttendance(ctx context.Context, tTransactionMAbsensiTypeID string, tTransactionMStaffID string, tTransactionMCompanyID string, tTransactionCurrentLatitude string, tTransactionCurrentLongitude string, tTransactionDistance string, tTransactionSelfiePhoto *string, tTransactionNote *string) (*model.TransAbsensiResponse, error) {
|
||||
panic(fmt.Errorf("not implemented: MClockInAttendance - mClockInAttendance"))
|
||||
}
|
||||
func (r *queryResolver) QCheckDistance(ctx context.Context, mStaffID string, mCompanyID string, mCompanyLatitude string, mCompanyLongitude string, currentLatitude string, currentLongitude string) (*model.TransAbsensiResponse, error) {
|
||||
panic(fmt.Errorf("not implemented: QCheckDistance - qCheckDistance"))
|
||||
}
|
||||
@@ -92,6 +92,8 @@ func (staff *Staff) LoginAttendance(email string, id_google_sign_in string) (*mo
|
||||
M_StaffNoHp,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
M_CompanyLatitude,
|
||||
M_CompanyLongitude,
|
||||
M_StaffIsActive,
|
||||
M_StaffIsLogin,
|
||||
M_StaffToken,
|
||||
@@ -121,6 +123,8 @@ func (staff *Staff) LoginAttendance(email string, id_google_sign_in string) (*mo
|
||||
&ret.PhoneNumber,
|
||||
&ret.CompanyID,
|
||||
&ret.CompanyName,
|
||||
&ret.CompanyLatitude,
|
||||
&ret.CompanyLongitude,
|
||||
&ret.IsActive,
|
||||
&ret.IsLogin,
|
||||
&ret.Token,
|
||||
|
||||
@@ -64,7 +64,7 @@ func Middleware() func(http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
// ForContext finds the user from the context. REQUIRES Middleware to have run.
|
||||
func ForContext(ctx context.Context) *model.User {
|
||||
raw, _ := ctx.Value(userCtxKey).(*model.User)
|
||||
func ForContext(ctx context.Context) *model.Staff {
|
||||
raw, _ := ctx.Value(userCtxKey).(*model.Staff)
|
||||
return raw
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user