diff --git a/backend/go.mod b/backend/go.mod index 69ffb12..b77b072 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -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 ) diff --git a/backend/go.sum b/backend/go.sum index c69aeec..0affbf9 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -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= diff --git a/backend/graph/generated/generated.go b/backend/graph/generated/generated.go index 6166fba..d5483b2 100644 --- a/backend/graph/generated/generated.go +++ b/backend/graph/generated/generated.go @@ -47,19 +47,21 @@ type DirectiveRoot struct { type ComplexityRoot struct { Mutation struct { - CreateTodo func(childComplexity int, input model.NewTodo) int - LoginAttendance func(childComplexity int, email string, idGoogleSignIn string) int + LoginAttendance func(childComplexity int, email string, idGoogleSignIn string) int + MutationClockInAttendance func(childComplexity int, tTransactionMAbsensiTypeID string, tTransactionMStaffID string, tTransactionMCompanyID string, tTransactionCurrentLatitude string, tTransactionCurrentLongitude string, tTransactionDistance string, tTransactionSelfiePhoto *string, tTransactionNote *string) int } Query struct { + QueryCheckDistance func(childComplexity int, mStaffID string, mCompanyID string, mCompanyLatitude string, mCompanyLongitude string, currentLatitude string, currentLongitude string) int SearchStaffByEmail func(childComplexity int, email string) int StaffGetByStaffID func(childComplexity int, staffID string) int StaffListBySearch func(childComplexity int, search *string, page *int, maxPerPage *int) int - Todos func(childComplexity int) int } Staff struct { CompanyID func(childComplexity int) int + CompanyLatitude func(childComplexity int) int + CompanyLongitude func(childComplexity int) int CompanyName func(childComplexity int) int CreatedAt func(childComplexity int) int DisplayNameGoogleSignIn func(childComplexity int) int @@ -76,33 +78,26 @@ type ComplexityRoot struct { Token func(childComplexity int) int } - Todo struct { - Done func(childComplexity int) int - ID func(childComplexity int) int - Text func(childComplexity int) int - User func(childComplexity int) int - } - TokenResponse struct { Message func(childComplexity int) int Token func(childComplexity int) int } - User struct { - ID func(childComplexity int) int - Name func(childComplexity int) int + TransAbsensiResponse struct { + Message func(childComplexity int) int + Status func(childComplexity int) int } } type MutationResolver interface { - CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) LoginAttendance(ctx context.Context, email string, idGoogleSignIn string) (*model.Staff, error) + MutationClockInAttendance(ctx context.Context, tTransactionMAbsensiTypeID string, tTransactionMStaffID string, tTransactionMCompanyID string, tTransactionCurrentLatitude string, tTransactionCurrentLongitude string, tTransactionDistance string, tTransactionSelfiePhoto *string, tTransactionNote *string) (*model.TransAbsensiResponse, error) } type QueryResolver interface { - Todos(ctx context.Context) ([]*model.Todo, error) SearchStaffByEmail(ctx context.Context, email string) (*model.Staff, error) StaffGetByStaffID(ctx context.Context, staffID string) (*model.Staff, error) StaffListBySearch(ctx context.Context, search *string, page *int, maxPerPage *int) ([]*model.Staff, error) + QueryCheckDistance(ctx context.Context, mStaffID string, mCompanyID string, mCompanyLatitude string, mCompanyLongitude string, currentLatitude string, currentLongitude string) (*model.TransAbsensiResponse, error) } type executableSchema struct { @@ -124,18 +119,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Mutation.createTodo": - if e.complexity.Mutation.CreateTodo == nil { - break - } - - args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true - case "Mutation.loginAttendance": if e.complexity.Mutation.LoginAttendance == nil { break @@ -148,6 +131,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.LoginAttendance(childComplexity, args["email"].(string), args["id_google_sign_in"].(string)), true + case "Mutation.mutationClockInAttendance": + if e.complexity.Mutation.MutationClockInAttendance == nil { + break + } + + args, err := ec.field_Mutation_mutationClockInAttendance_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.MutationClockInAttendance(childComplexity, args["T_TransactionM_AbsensiTypeID"].(string), args["T_TransactionM_StaffID"].(string), args["T_TransactionM_CompanyID"].(string), args["T_TransactionCurrentLatitude"].(string), args["T_TransactionCurrentLongitude"].(string), args["T_TransactionDistance"].(string), args["T_TransactionSelfiePhoto"].(*string), args["T_TransactionNote"].(*string)), true + + case "Query.queryCheckDistance": + if e.complexity.Query.QueryCheckDistance == nil { + break + } + + args, err := ec.field_Query_queryCheckDistance_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.QueryCheckDistance(childComplexity, args["M_StaffID"].(string), args["M_CompanyID"].(string), args["M_CompanyLatitude"].(string), args["M_CompanyLongitude"].(string), args["CurrentLatitude"].(string), args["CurrentLongitude"].(string)), true + case "Query.searchStaffByEmail": if e.complexity.Query.SearchStaffByEmail == nil { break @@ -184,13 +191,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.StaffListBySearch(childComplexity, args["search"].(*string), args["page"].(*int), args["maxPerPage"].(*int)), true - case "Query.todos": - if e.complexity.Query.Todos == nil { - break - } - - return e.complexity.Query.Todos(childComplexity), true - case "Staff.company_id": if e.complexity.Staff.CompanyID == nil { break @@ -198,6 +198,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Staff.CompanyID(childComplexity), true + case "Staff.company_latitude": + if e.complexity.Staff.CompanyLatitude == nil { + break + } + + return e.complexity.Staff.CompanyLatitude(childComplexity), true + + case "Staff.company_longitude": + if e.complexity.Staff.CompanyLongitude == nil { + break + } + + return e.complexity.Staff.CompanyLongitude(childComplexity), true + case "Staff.company_name": if e.complexity.Staff.CompanyName == nil { break @@ -296,34 +310,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Staff.Token(childComplexity), true - case "Todo.done": - if e.complexity.Todo.Done == nil { - break - } - - return e.complexity.Todo.Done(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.ID == nil { - break - } - - return e.complexity.Todo.ID(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.user": - if e.complexity.Todo.User == nil { - break - } - - return e.complexity.Todo.User(childComplexity), true - case "TokenResponse.message": if e.complexity.TokenResponse.Message == nil { break @@ -338,19 +324,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TokenResponse.Token(childComplexity), true - case "User.id": - if e.complexity.User.ID == nil { + case "TransAbsensiResponse.message": + if e.complexity.TransAbsensiResponse.Message == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.complexity.TransAbsensiResponse.Message(childComplexity), true - case "User.name": - if e.complexity.User.Name == nil { + case "TransAbsensiResponse.status": + if e.complexity.TransAbsensiResponse.Status == nil { break } - return e.complexity.User.Name(childComplexity), true + return e.complexity.TransAbsensiResponse.Status(childComplexity), true } return 0, false @@ -359,9 +345,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputNewTodo, - ) + inputUnmarshalMap := graphql.BuildUnmarshalerMap() first := true switch rc.Operation.Operation { @@ -458,35 +442,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "../graphqls/schema.graphqls", Input: `# 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! -} -`, BuiltIn: false}, + {Name: "../graphqls/schema.graphqls", Input: ``, BuiltIn: false}, {Name: "../graphqls/staff.graphqls", Input: `# model staff type Staff { staff_id: ID! @@ -496,6 +452,8 @@ type Staff { phone_number: String company_id: ID! company_name: String + company_latitude:String + company_longitude:String is_active: String is_login: String token: String @@ -523,6 +481,23 @@ extend type Query { extend type Mutation { loginAttendance(email:String!, id_google_sign_in:String!) : Staff! }`, BuiltIn: false}, + {Name: "../graphqls/transabsensi.graphqls", Input: `# 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! +} `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -530,21 +505,6 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** -func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 model.NewTodo - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNNewTodo2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐNewTodo(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_loginAttendance_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -569,6 +529,84 @@ func (ec *executionContext) field_Mutation_loginAttendance_args(ctx context.Cont return args, nil } +func (ec *executionContext) field_Mutation_mutationClockInAttendance_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["T_TransactionM_AbsensiTypeID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionM_AbsensiTypeID")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionM_AbsensiTypeID"] = arg0 + var arg1 string + if tmp, ok := rawArgs["T_TransactionM_StaffID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionM_StaffID")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionM_StaffID"] = arg1 + var arg2 string + if tmp, ok := rawArgs["T_TransactionM_CompanyID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionM_CompanyID")) + arg2, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionM_CompanyID"] = arg2 + var arg3 string + if tmp, ok := rawArgs["T_TransactionCurrentLatitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionCurrentLatitude")) + arg3, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionCurrentLatitude"] = arg3 + var arg4 string + if tmp, ok := rawArgs["T_TransactionCurrentLongitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionCurrentLongitude")) + arg4, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionCurrentLongitude"] = arg4 + var arg5 string + if tmp, ok := rawArgs["T_TransactionDistance"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionDistance")) + arg5, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionDistance"] = arg5 + var arg6 *string + if tmp, ok := rawArgs["T_TransactionSelfiePhoto"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionSelfiePhoto")) + arg6, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionSelfiePhoto"] = arg6 + var arg7 *string + if tmp, ok := rawArgs["T_TransactionNote"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("T_TransactionNote")) + arg7, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["T_TransactionNote"] = arg7 + return args, nil +} + func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -584,6 +622,66 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_queryCheckDistance_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["M_StaffID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("M_StaffID")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["M_StaffID"] = arg0 + var arg1 string + if tmp, ok := rawArgs["M_CompanyID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("M_CompanyID")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["M_CompanyID"] = arg1 + var arg2 string + if tmp, ok := rawArgs["M_CompanyLatitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("M_CompanyLatitude")) + arg2, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["M_CompanyLatitude"] = arg2 + var arg3 string + if tmp, ok := rawArgs["M_CompanyLongitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("M_CompanyLongitude")) + arg3, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["M_CompanyLongitude"] = arg3 + var arg4 string + if tmp, ok := rawArgs["CurrentLatitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("CurrentLatitude")) + arg4, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["CurrentLatitude"] = arg4 + var arg5 string + if tmp, ok := rawArgs["CurrentLongitude"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("CurrentLongitude")) + arg5, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["CurrentLongitude"] = arg5 + return args, nil +} + func (ec *executionContext) field_Query_searchStaffByEmail_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -685,71 +783,6 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*model.Todo) - fc.Result = res - return ec.marshalNTodo2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Todo_id(ctx, field) - case "text": - return ec.fieldContext_Todo_text(ctx, field) - case "done": - return ec.fieldContext_Todo_done(ctx, field) - case "user": - return ec.fieldContext_Todo_user(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - func (ec *executionContext) _Mutation_loginAttendance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_loginAttendance(ctx, field) if err != nil { @@ -803,6 +836,10 @@ func (ec *executionContext) fieldContext_Mutation_loginAttendance(ctx context.Co return ec.fieldContext_Staff_company_id(ctx, field) case "company_name": return ec.fieldContext_Staff_company_name(ctx, field) + case "company_latitude": + return ec.fieldContext_Staff_company_latitude(ctx, field) + case "company_longitude": + return ec.fieldContext_Staff_company_longitude(ctx, field) case "is_active": return ec.fieldContext_Staff_is_active(ctx, field) case "is_login": @@ -837,8 +874,8 @@ func (ec *executionContext) fieldContext_Mutation_loginAttendance(ctx context.Co return fc, nil } -func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_todos(ctx, field) +func (ec *executionContext) _Mutation_mutationClockInAttendance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_mutationClockInAttendance(ctx, field) if err != nil { return graphql.Null } @@ -851,7 +888,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx) + return ec.resolvers.Mutation().MutationClockInAttendance(rctx, fc.Args["T_TransactionM_AbsensiTypeID"].(string), fc.Args["T_TransactionM_StaffID"].(string), fc.Args["T_TransactionM_CompanyID"].(string), fc.Args["T_TransactionCurrentLatitude"].(string), fc.Args["T_TransactionCurrentLongitude"].(string), fc.Args["T_TransactionDistance"].(string), fc.Args["T_TransactionSelfiePhoto"].(*string), fc.Args["T_TransactionNote"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -863,31 +900,38 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*model.Todo) + res := resTmp.(*model.TransAbsensiResponse) fc.Result = res - return ec.marshalNTodo2ᚕᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) + return ec.marshalNTransAbsensiResponse2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTransAbsensiResponse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_mutationClockInAttendance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Todo_id(ctx, field) - case "text": - return ec.fieldContext_Todo_text(ctx, field) - case "done": - return ec.fieldContext_Todo_done(ctx, field) - case "user": - return ec.fieldContext_Todo_user(ctx, field) + case "status": + return ec.fieldContext_TransAbsensiResponse_status(ctx, field) + case "message": + return ec.fieldContext_TransAbsensiResponse_message(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TransAbsensiResponse", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_mutationClockInAttendance_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } @@ -944,6 +988,10 @@ func (ec *executionContext) fieldContext_Query_searchStaffByEmail(ctx context.Co return ec.fieldContext_Staff_company_id(ctx, field) case "company_name": return ec.fieldContext_Staff_company_name(ctx, field) + case "company_latitude": + return ec.fieldContext_Staff_company_latitude(ctx, field) + case "company_longitude": + return ec.fieldContext_Staff_company_longitude(ctx, field) case "is_active": return ec.fieldContext_Staff_is_active(ctx, field) case "is_login": @@ -1031,6 +1079,10 @@ func (ec *executionContext) fieldContext_Query_staffGetByStaffId(ctx context.Con return ec.fieldContext_Staff_company_id(ctx, field) case "company_name": return ec.fieldContext_Staff_company_name(ctx, field) + case "company_latitude": + return ec.fieldContext_Staff_company_latitude(ctx, field) + case "company_longitude": + return ec.fieldContext_Staff_company_longitude(ctx, field) case "is_active": return ec.fieldContext_Staff_is_active(ctx, field) case "is_login": @@ -1118,6 +1170,10 @@ func (ec *executionContext) fieldContext_Query_staffListBySearch(ctx context.Con return ec.fieldContext_Staff_company_id(ctx, field) case "company_name": return ec.fieldContext_Staff_company_name(ctx, field) + case "company_latitude": + return ec.fieldContext_Staff_company_latitude(ctx, field) + case "company_longitude": + return ec.fieldContext_Staff_company_longitude(ctx, field) case "is_active": return ec.fieldContext_Staff_is_active(ctx, field) case "is_login": @@ -1152,6 +1208,67 @@ func (ec *executionContext) fieldContext_Query_staffListBySearch(ctx context.Con return fc, nil } +func (ec *executionContext) _Query_queryCheckDistance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_queryCheckDistance(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().QueryCheckDistance(rctx, fc.Args["M_StaffID"].(string), fc.Args["M_CompanyID"].(string), fc.Args["M_CompanyLatitude"].(string), fc.Args["M_CompanyLongitude"].(string), fc.Args["CurrentLatitude"].(string), fc.Args["CurrentLongitude"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.TransAbsensiResponse) + fc.Result = res + return ec.marshalNTransAbsensiResponse2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTransAbsensiResponse(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_queryCheckDistance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "status": + return ec.fieldContext_TransAbsensiResponse_status(ctx, field) + case "message": + return ec.fieldContext_TransAbsensiResponse_message(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TransAbsensiResponse", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_queryCheckDistance_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { @@ -1583,6 +1700,88 @@ func (ec *executionContext) fieldContext_Staff_company_name(ctx context.Context, return fc, nil } +func (ec *executionContext) _Staff_company_latitude(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Staff_company_latitude(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CompanyLatitude, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Staff_company_latitude(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Staff", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Staff_company_longitude(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Staff_company_longitude(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CompanyLongitude, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Staff_company_longitude(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Staff", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Staff_is_active(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Staff_is_active(ctx, field) if err != nil { @@ -1914,188 +2113,6 @@ func (ec *executionContext) fieldContext_Staff_last_updated_at(ctx context.Conte return fc, nil } -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Todo_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Todo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Todo_text(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Text, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Todo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Todo_done(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Done, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Todo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Todo_user(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*model.User) - fc.Result = res - return ec.marshalNUser2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Todo_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Todo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, - } - return fc, nil -} - func (ec *executionContext) _TokenResponse_token(ctx context.Context, field graphql.CollectedField, obj *model.TokenResponse) (ret graphql.Marshaler) { fc, err := ec.fieldContext_TokenResponse_token(ctx, field) if err != nil { @@ -2178,8 +2195,8 @@ func (ec *executionContext) fieldContext_TokenResponse_message(ctx context.Conte return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _TransAbsensiResponse_status(ctx context.Context, field graphql.CollectedField, obj *model.TransAbsensiResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransAbsensiResponse_status(ctx, field) if err != nil { return graphql.Null } @@ -2192,38 +2209,35 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Status, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransAbsensiResponse_status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "TransAbsensiResponse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_name(ctx, field) +func (ec *executionContext) _TransAbsensiResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.TransAbsensiResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TransAbsensiResponse_message(ctx, field) if err != nil { return graphql.Null } @@ -2236,26 +2250,23 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Message, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TransAbsensiResponse_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "TransAbsensiResponse", Field: field, IsMethod: false, IsResolver: false, @@ -4039,40 +4050,6 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Conte // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (model.NewTodo, error) { - var it model.NewTodo - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"text", "userId"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "text": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Text = data - case "userId": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.UserID = data - } - } - - return it, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -4100,16 +4077,16 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") - case "createTodo": + case "loginAttendance": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createTodo(ctx, field) + return ec._Mutation_loginAttendance(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "loginAttendance": + case "mutationClockInAttendance": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_loginAttendance(ctx, field) + return ec._Mutation_mutationClockInAttendance(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -4156,28 +4133,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") - case "todos": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_todos(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "searchStaffByEmail": field := field @@ -4243,6 +4198,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "queryCheckDistance": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_queryCheckDistance(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -4315,6 +4292,10 @@ func (ec *executionContext) _Staff(ctx context.Context, sel ast.SelectionSet, ob } case "company_name": out.Values[i] = ec._Staff_company_name(ctx, field, obj) + case "company_latitude": + out.Values[i] = ec._Staff_company_latitude(ctx, field, obj) + case "company_longitude": + out.Values[i] = ec._Staff_company_longitude(ctx, field, obj) case "is_active": out.Values[i] = ec._Staff_is_active(ctx, field, obj) case "is_login": @@ -4357,60 +4338,6 @@ func (ec *executionContext) _Staff(ctx context.Context, sel ast.SelectionSet, ob return out } -var todoImplementors = []string{"Todo"} - -func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Todo") - case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "done": - out.Values[i] = ec._Todo_done(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "user": - out.Values[i] = ec._Todo_user(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var tokenResponseImplementors = []string{"TokenResponse"} func (ec *executionContext) _TokenResponse(ctx context.Context, sel ast.SelectionSet, obj *model.TokenResponse) graphql.Marshaler { @@ -4449,27 +4376,21 @@ func (ec *executionContext) _TokenResponse(ctx context.Context, sel ast.Selectio return out } -var userImplementors = []string{"User"} +var transAbsensiResponseImplementors = []string{"TransAbsensiResponse"} -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) +func (ec *executionContext) _TransAbsensiResponse(ctx context.Context, sel ast.SelectionSet, obj *model.TransAbsensiResponse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, transAbsensiResponseImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } + out.Values[i] = graphql.MarshalString("TransAbsensiResponse") + case "status": + out.Values[i] = ec._TransAbsensiResponse_status(ctx, field, obj) + case "message": + out.Values[i] = ec._TransAbsensiResponse_message(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -4849,11 +4770,6 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return res } -func (ec *executionContext) unmarshalNNewTodo2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v interface{}) (model.NewTodo, error) { - res, err := ec.unmarshalInputNewTodo(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNStaff2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐStaff(ctx context.Context, sel ast.SelectionSet, v model.Staff) graphql.Marshaler { return ec._Staff(ctx, sel, &v) } @@ -4927,72 +4843,18 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return res } -func (ec *executionContext) marshalNTodo2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) +func (ec *executionContext) marshalNTransAbsensiResponse2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTransAbsensiResponse(ctx context.Context, sel ast.SelectionSet, v model.TransAbsensiResponse) graphql.Marshaler { + return ec._TransAbsensiResponse(ctx, sel, &v) } -func (ec *executionContext) marshalNTodo2ᚕᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNTodo2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodo(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNTodo2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { +func (ec *executionContext) marshalNTransAbsensiResponse2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTransAbsensiResponse(ctx context.Context, sel ast.SelectionSet, v *model.TransAbsensiResponse) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Todo(ctx, sel, v) -} - -func (ec *executionContext) marshalNUser2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._User(ctx, sel, v) + return ec._TransAbsensiResponse(ctx, sel, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { diff --git a/backend/graph/graphqls/schema.graphqls b/backend/graph/graphqls/schema.graphqls index c6a91bb..e69de29 100644 --- a/backend/graph/graphqls/schema.graphqls +++ b/backend/graph/graphqls/schema.graphqls @@ -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! -} diff --git a/backend/graph/graphqls/staff.graphqls b/backend/graph/graphqls/staff.graphqls index c05dd04..b3df76d 100644 --- a/backend/graph/graphqls/staff.graphqls +++ b/backend/graph/graphqls/staff.graphqls @@ -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 diff --git a/backend/graph/graphqls/transabsensi.graphqls b/backend/graph/graphqls/transabsensi.graphqls new file mode 100644 index 0000000..ebfbdd7 --- /dev/null +++ b/backend/graph/graphqls/transabsensi.graphqls @@ -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! +} \ No newline at end of file diff --git a/backend/graph/model/models_gen.go b/backend/graph/model/models_gen.go index d7aa2b7..dca75f0 100644 --- a/backend/graph/model/models_gen.go +++ b/backend/graph/model/models_gen.go @@ -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"` } diff --git a/backend/graph/resolver/schema.resolvers.go b/backend/graph/resolver/schema.resolvers.go index e3237c3..d356a7b 100644 --- a/backend/graph/resolver/schema.resolvers.go +++ b/backend/graph/resolver/schema.resolvers.go @@ -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 } diff --git a/backend/graph/resolver/staff.resolvers.go b/backend/graph/resolver/staff.resolvers.go index 45e89e3..e1f7ba4 100644 --- a/backend/graph/resolver/staff.resolvers.go +++ b/backend/graph/resolver/staff.resolvers.go @@ -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 } diff --git a/backend/graph/resolver/transabsensi.resolvers.go b/backend/graph/resolver/transabsensi.resolvers.go new file mode 100644 index 0000000..7d5de40 --- /dev/null +++ b/backend/graph/resolver/transabsensi.resolvers.go @@ -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")) +} diff --git a/backend/internal/staff/staff.go b/backend/internal/staff/staff.go index 8a7c876..a1cd119 100644 --- a/backend/internal/staff/staff.go +++ b/backend/internal/staff/staff.go @@ -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, diff --git a/backend/pkg/auth/middleware.go b/backend/pkg/auth/middleware.go index 6936ba3..f35982b 100644 --- a/backend/pkg/auth/middleware.go +++ b/backend/pkg/auth/middleware.go @@ -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 }