作者 yangfu

graphql 自定义模型使用

... ... @@ -4,7 +4,7 @@ go 1.15
require (
github.com/99designs/gqlgen v0.13.0
github.com/Laisky/laisky-blog-graphql v0.5.1 // indirect
github.com/Laisky/laisky-blog-graphql v0.5.1
github.com/ajg/form v1.5.1 // indirect
github.com/astaxie/beego v1.12.3
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
... ...
... ... @@ -12,7 +12,7 @@ type GetClientVersionQuery struct {
}
func (getClientVersionQuery *GetClientVersionQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getClientVersionQuery *GetClientVersionQuery) ValidateQuery() error {
... ...
... ... @@ -9,3 +9,7 @@ import (
func CreateTransactionContext(options map[string]interface{}) (application.TransactionContext, error) {
return pG.NewPGTransactionContext(pg.DB), nil
}
func CreateDefaultTransactionContext(options map[string]interface{}) (application.TransactionContext, error) {
return pG.NewPGTransactionContext(pg.DB), nil
}
... ...
package models
type Access struct {
TableName string `pg:"access,alias:access"`
tableName struct{} `pg:"access,alias:access"`
// dcc
Id int64
// 父级Id
... ...
... ... @@ -20,7 +20,7 @@ type ClientVersion struct {
// 其他备注信息
Remark string
// 客户端安装包信息
ClientPackageInfo []*domain.ClientPackageInfo `pg:",array"`
ClientPackageInfo []*domain.ClientPackageInfo
// 创建时间
CreateTime time.Time
}
... ...
... ... @@ -49,7 +49,7 @@ func (repository *AccessRepository) Remove(access *domain.Access) (*domain.Acces
return access, nil
}
func (repository *AccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.Access, error) {
tx := repository.transactionContext.PgTx
tx := repository.transactionContext.PgDd
accessModel := new(models.Access)
query := tx.Model(accessModel)
if accessId, ok := queryOptions["id"]; ok {
... ... @@ -69,7 +69,7 @@ func (repository *AccessRepository) FindOne(queryOptions map[string]interface{})
}
}
func (repository *AccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Access, error) {
tx := repository.transactionContext.PgTx
tx := repository.transactionContext.PgDd
var accessModels []*models.Access
accesss := make([]*domain.Access, 0)
query := tx.Model(&accessModels)
... ...
... ... @@ -49,7 +49,7 @@ func (repository *RoleAccessRepository) Remove(roleAccess *domain.RoleAccess) (*
return roleAccess, nil
}
func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.RoleAccess, error) {
tx := repository.transactionContext.PgTx
tx := repository.transactionContext.PgDd
roleAccessModel := new(models.RoleAccess)
query := tx.Model(roleAccessModel)
if roleAccessId, ok := queryOptions["id"]; ok {
... ... @@ -69,7 +69,7 @@ func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interfac
}
}
func (repository *RoleAccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.RoleAccess, error) {
tx := repository.transactionContext.PgTx
tx := repository.transactionContext.PgDd
var roleAccessModels []*models.RoleAccess
roleAccesss := make([]*domain.RoleAccess, 0)
query := tx.Model(&roleAccessModels)
... ...
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls
- graph/access/*.graphqls
# Where should the generated server code go?
exec:
... ... @@ -22,6 +23,9 @@ resolver:
layout: follow-schema
dir: graph
package: graph
#resolver:
# filename: resolver.go
# type: Resolver
# Optional: turn on use `gqlgen:"fieldName"` tags in your models
# struct_tag: json
... ... @@ -55,4 +59,8 @@ models:
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Date:
model: github.com/Laisky/laisky-blog-graphql/types.Datetime
\ No newline at end of file
model: github.com/tiptok/godevp/pkg/port/graphql/graph/libs.Datetime
ClientVersion:
model: github.com/tiptok/godevp/pkg/domain.ClientVersion
ClientPackageInfo:
model: github.com/tiptok/godevp/pkg/domain.ClientPackageInfo
\ No newline at end of file
... ...
package graph
// 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.
import (
"context"
"fmt"
"github.com/tiptok/godevp/pkg/port/graphql/graph/generated"
"github.com/tiptok/godevp/pkg/port/graphql/graph/model"
)
func (r *accessResolver) User(ctx context.Context, obj *model.Access) (*model.Users, error) {
panic(fmt.Errorf("not implemented"))
}
func (r *mutationResolver) CreateMenu(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error) {
panic(fmt.Errorf("not implemented"))
}
func (r *queryResolver) Menu(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error) {
panic(fmt.Errorf("not implemented"))
}
// Access returns generated.AccessResolver implementation.
func (r *Resolver) Access() generated.AccessResolver { return &accessResolver{r} }
type accessResolver struct{ *Resolver }
... ...
## type
type Access{
id: Int
parentId: Int
accessName: String
accessCode: String
accessType: String
sort: Int
object: String
action: String
module: String
icon: String
status: Int
user: Users
}
## input
input menuAccessInput{
name: String
}
extend type Query {
menu(input: menuAccessInput): [Access!]
}
extend type Mutation {
createMenu(input: menuAccessInput): [Access!]
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,8 @@ import (
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/tiptok/godevp/pkg/domain"
"github.com/tiptok/godevp/pkg/port/graphql/graph/libs"
"github.com/tiptok/godevp/pkg/port/graphql/graph/model"
gqlparser "github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
... ... @@ -35,8 +37,11 @@ type Config struct {
}
type ResolverRoot interface {
Access() AccessResolver
ClientVersion() ClientVersionResolver
Mutation() MutationResolver
Query() QueryResolver
Role() RoleResolver
Users() UsersResolver
}
... ... @@ -44,18 +49,54 @@ type DirectiveRoot struct {
}
type ComplexityRoot struct {
Access struct {
AccessCode func(childComplexity int) int
AccessName func(childComplexity int) int
AccessType func(childComplexity int) int
Action func(childComplexity int) int
ID func(childComplexity int) int
Icon func(childComplexity int) int
Module func(childComplexity int) int
Object func(childComplexity int) int
ParentID func(childComplexity int) int
Sort func(childComplexity int) int
Status func(childComplexity int) int
User func(childComplexity int) int
}
ClientPackageInfo struct {
FileName func(childComplexity int) int
Path func(childComplexity int) int
}
ClientVersion struct {
ClientPackageInfo func(childComplexity int) int
Commiter func(childComplexity int) int
CreateTime func(childComplexity int) int
Id func(childComplexity int) int
ProjectName func(childComplexity int) int
Remark func(childComplexity int) int
Title func(childComplexity int) int
Version func(childComplexity int) int
}
Mutation struct {
CreateMenu func(childComplexity int, input *model.MenuAccessInput) int
CreateUsers func(childComplexity int, input model.CreateUsersInput) int
RemoveUsers func(childComplexity int, input model.RemoveUsersInput) int
UpdateUsers func(childComplexity int, input model.UpdateUsersInput) int
}
Query struct {
ClientVersion func(childComplexity int, id *int) int
Menu func(childComplexity int, input *model.MenuAccessInput) int
Menus func(childComplexity int, input *model.MenuAccessInput) int
User func(childComplexity int, input model.GetUsersInput) int
Users func(childComplexity int, input model.ListUsersInput) int
}
Role struct {
Access func(childComplexity int) int
CreateTime func(childComplexity int) int
ID func(childComplexity int) int
ParentID func(childComplexity int) int
... ... @@ -74,14 +115,27 @@ type ComplexityRoot struct {
}
}
type AccessResolver interface {
User(ctx context.Context, obj *model.Access) (*model.Users, error)
}
type ClientVersionResolver interface {
CreateTime(ctx context.Context, obj *domain.ClientVersion) (*libs.Datetime, error)
}
type MutationResolver interface {
CreateUsers(ctx context.Context, input model.CreateUsersInput) (*model.Users, error)
RemoveUsers(ctx context.Context, input model.RemoveUsersInput) (*model.Users, error)
UpdateUsers(ctx context.Context, input model.UpdateUsersInput) (*model.Users, error)
CreateMenu(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error)
}
type QueryResolver interface {
User(ctx context.Context, input model.GetUsersInput) (*model.Users, error)
Users(ctx context.Context, input model.ListUsersInput) ([]*model.Users, error)
Menus(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error)
ClientVersion(ctx context.Context, id *int) (*domain.ClientVersion, error)
Menu(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error)
}
type RoleResolver interface {
Access(ctx context.Context, obj *model.Role) ([]*model.Access, error)
}
type UsersResolver interface {
Roles(ctx context.Context, obj *model.Users) ([]*model.Role, error)
... ... @@ -102,6 +156,172 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
_ = ec
switch typeName + "." + field {
case "Access.accessCode":
if e.complexity.Access.AccessCode == nil {
break
}
return e.complexity.Access.AccessCode(childComplexity), true
case "Access.accessName":
if e.complexity.Access.AccessName == nil {
break
}
return e.complexity.Access.AccessName(childComplexity), true
case "Access.accessType":
if e.complexity.Access.AccessType == nil {
break
}
return e.complexity.Access.AccessType(childComplexity), true
case "Access.action":
if e.complexity.Access.Action == nil {
break
}
return e.complexity.Access.Action(childComplexity), true
case "Access.id":
if e.complexity.Access.ID == nil {
break
}
return e.complexity.Access.ID(childComplexity), true
case "Access.icon":
if e.complexity.Access.Icon == nil {
break
}
return e.complexity.Access.Icon(childComplexity), true
case "Access.module":
if e.complexity.Access.Module == nil {
break
}
return e.complexity.Access.Module(childComplexity), true
case "Access.object":
if e.complexity.Access.Object == nil {
break
}
return e.complexity.Access.Object(childComplexity), true
case "Access.parentId":
if e.complexity.Access.ParentID == nil {
break
}
return e.complexity.Access.ParentID(childComplexity), true
case "Access.sort":
if e.complexity.Access.Sort == nil {
break
}
return e.complexity.Access.Sort(childComplexity), true
case "Access.status":
if e.complexity.Access.Status == nil {
break
}
return e.complexity.Access.Status(childComplexity), true
case "Access.user":
if e.complexity.Access.User == nil {
break
}
return e.complexity.Access.User(childComplexity), true
case "ClientPackageInfo.FileName":
if e.complexity.ClientPackageInfo.FileName == nil {
break
}
return e.complexity.ClientPackageInfo.FileName(childComplexity), true
case "ClientPackageInfo.Path":
if e.complexity.ClientPackageInfo.Path == nil {
break
}
return e.complexity.ClientPackageInfo.Path(childComplexity), true
case "ClientVersion.clientPackageInfo":
if e.complexity.ClientVersion.ClientPackageInfo == nil {
break
}
return e.complexity.ClientVersion.ClientPackageInfo(childComplexity), true
case "ClientVersion.commiter":
if e.complexity.ClientVersion.Commiter == nil {
break
}
return e.complexity.ClientVersion.Commiter(childComplexity), true
case "ClientVersion.createTime":
if e.complexity.ClientVersion.CreateTime == nil {
break
}
return e.complexity.ClientVersion.CreateTime(childComplexity), true
case "ClientVersion.id":
if e.complexity.ClientVersion.Id == nil {
break
}
return e.complexity.ClientVersion.Id(childComplexity), true
case "ClientVersion.projectName":
if e.complexity.ClientVersion.ProjectName == nil {
break
}
return e.complexity.ClientVersion.ProjectName(childComplexity), true
case "ClientVersion.remark":
if e.complexity.ClientVersion.Remark == nil {
break
}
return e.complexity.ClientVersion.Remark(childComplexity), true
case "ClientVersion.title":
if e.complexity.ClientVersion.Title == nil {
break
}
return e.complexity.ClientVersion.Title(childComplexity), true
case "ClientVersion.version":
if e.complexity.ClientVersion.Version == nil {
break
}
return e.complexity.ClientVersion.Version(childComplexity), true
case "Mutation.createMenu":
if e.complexity.Mutation.CreateMenu == nil {
break
}
args, err := ec.field_Mutation_createMenu_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Mutation.CreateMenu(childComplexity, args["input"].(*model.MenuAccessInput)), true
case "Mutation.createUsers":
if e.complexity.Mutation.CreateUsers == nil {
break
... ... @@ -138,6 +358,42 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Mutation.UpdateUsers(childComplexity, args["input"].(model.UpdateUsersInput)), true
case "Query.clientVersion":
if e.complexity.Query.ClientVersion == nil {
break
}
args, err := ec.field_Query_clientVersion_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.ClientVersion(childComplexity, args["id"].(*int)), true
case "Query.menu":
if e.complexity.Query.Menu == nil {
break
}
args, err := ec.field_Query_menu_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.Menu(childComplexity, args["input"].(*model.MenuAccessInput)), true
case "Query.menus":
if e.complexity.Query.Menus == nil {
break
}
args, err := ec.field_Query_menus_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.Menus(childComplexity, args["input"].(*model.MenuAccessInput)), true
case "Query.user":
if e.complexity.Query.User == nil {
break
... ... @@ -162,6 +418,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.Users(childComplexity, args["input"].(model.ListUsersInput)), true
case "Role.access":
if e.complexity.Role.Access == nil {
break
}
return e.complexity.Role.Access(childComplexity), true
case "Role.createTime":
if e.complexity.Role.CreateTime == nil {
break
... ... @@ -310,7 +573,9 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er
}
var sources = []*ast.Source{
{Name: "graph/schema.graphqls", Input: `## type
{Name: "graph/schema.graphqls", Input: `scalar Date
## type
type Users{
name: String
phone: String
... ... @@ -326,6 +591,22 @@ type Role{
parentId: Int
createTime: String
updateTime: String
access:[Access!]
}
type ClientVersion{
id: Int
commiter: String
projectName: String
version: String
title: String
remark: String
clientPackageInfo: [ClientPackageInfo!]
createTime: Date
}
type ClientPackageInfo{
FileName: String
Path: String
}
## user input
... ... @@ -351,6 +632,10 @@ input listUsersInput{
type Query {
user(input : getUsersInput!): Users!
users(input : listUsersInput!): [Users!]
menus(input: menuAccessInput): [Access!]
clientVersion(id :Int):ClientVersion!
}
type Mutation{
... ... @@ -358,6 +643,32 @@ type Mutation{
removeUsers(input : removeUsersInput!): Users!
updateUsers(input : updateUsersInput!): Users!
}`, BuiltIn: false},
{Name: "graph/access/access.graphqls", Input: `## type
type Access{
id: Int
parentId: Int
accessName: String
accessCode: String
accessType: String
sort: Int
object: String
action: String
module: String
icon: String
status: Int
user: Users
}
## input
input menuAccessInput{
name: String
}
extend type Query {
menu(input: menuAccessInput): [Access!]
}
extend type Mutation {
createMenu(input: menuAccessInput): [Access!]
}`, BuiltIn: false},
}
var parsedSchema = gqlparser.MustLoadSchema(sources...)
... ... @@ -365,6 +676,21 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
// region ***************************** args.gotpl *****************************
func (ec *executionContext) field_Mutation_createMenu_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 *model.MenuAccessInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
arg0, err = ec.unmarshalOmenuAccessInput2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐMenuAccessInput(ctx, tmp)
if err != nil {
return nil, err
}
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Mutation_createUsers_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
... ... @@ -425,6 +751,51 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs
return args, nil
}
func (ec *executionContext) field_Query_clientVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 *int
if tmp, ok := rawArgs["id"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
if err != nil {
return nil, err
}
}
args["id"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_menu_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 *model.MenuAccessInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
arg0, err = ec.unmarshalOmenuAccessInput2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐMenuAccessInput(ctx, tmp)
if err != nil {
return nil, err
}
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_menus_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 *model.MenuAccessInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
arg0, err = ec.unmarshalOmenuAccessInput2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐMenuAccessInput(ctx, tmp)
if err != nil {
return nil, err
}
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
... ... @@ -436,63 +807,767 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m
return nil, err
}
}
args["input"] = arg0
return args, nil
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_users_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 model.ListUsersInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
arg0, err = ec.unmarshalNlistUsersInput2githubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐListUsersInput(ctx, tmp)
if err != nil {
return nil, err
}
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
if err != nil {
return nil, err
}
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
if err != nil {
return nil, err
}
}
args["includeDeprecated"] = arg0
return args, nil
}
// endregion ***************************** args.gotpl *****************************
// region ************************** directives.gotpl **************************
// endregion ************************** directives.gotpl **************************
// region **************************** field.gotpl *****************************
func (ec *executionContext) _Access_id(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
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 {
return graphql.Null
}
res := resTmp.(*int)
fc.Result = res
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
}
func (ec *executionContext) _Access_parentId(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ParentID, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*int)
fc.Result = res
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
}
func (ec *executionContext) _Access_accessName(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.AccessName, 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) _Access_accessCode(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.AccessCode, 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) _Access_accessType(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.AccessType, 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) _Access_sort(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Sort, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*int)
fc.Result = res
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
}
func (ec *executionContext) _Access_object(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Object, 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) _Access_action(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Action, 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) _Access_module(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Module, 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) _Access_icon(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Icon, 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) _Access_status(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Status, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*int)
fc.Result = res
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
}
func (ec *executionContext) _Access_user(ctx context.Context, field graphql.CollectedField, obj *model.Access) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Access",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Access().User(rctx, obj)
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*model.Users)
fc.Result = res
return ec.marshalOUsers2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐUsers(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientPackageInfo_FileName(ctx context.Context, field graphql.CollectedField, obj *domain.ClientPackageInfo) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientPackageInfo",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.FileName, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientPackageInfo_Path(ctx context.Context, field graphql.CollectedField, obj *domain.ClientPackageInfo) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientPackageInfo",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Path, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_id(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
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 {
return graphql.Null
}
res := resTmp.(int64)
fc.Result = res
return ec.marshalOInt2int64(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_commiter(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Commiter, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_projectName(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ProjectName, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_version(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Version, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_title(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Title, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_remark(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Remark, 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.marshalOString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ClientVersion_clientPackageInfo(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
func (ec *executionContext) field_Query_users_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 model.ListUsersInput
if tmp, ok := rawArgs["input"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
arg0, err = ec.unmarshalNlistUsersInput2githubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐListUsersInput(ctx, tmp)
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ClientPackageInfo, nil
})
if err != nil {
return nil, err
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
args["input"] = arg0
return args, nil
res := resTmp.([]*domain.ClientPackageInfo)
fc.Result = res
return ec.marshalOClientPackageInfo2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientPackageInfoᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
if err != nil {
return nil, err
func (ec *executionContext) _ClientVersion_createTime(ctx context.Context, field graphql.CollectedField, obj *domain.ClientVersion) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ClientVersion",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 bool
if tmp, ok := rawArgs["includeDeprecated"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated"))
arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp)
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.ClientVersion().CreateTime(rctx, obj)
})
if err != nil {
return nil, err
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
args["includeDeprecated"] = arg0
return args, nil
res := resTmp.(*libs.Datetime)
fc.Result = res
return ec.marshalODate2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋlibsᚐDatetime(ctx, field.Selections, res)
}
// endregion ***************************** args.gotpl *****************************
// region ************************** directives.gotpl **************************
// endregion ************************** directives.gotpl **************************
// region **************************** field.gotpl *****************************
func (ec *executionContext) _Mutation_createUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
... ... @@ -619,6 +1694,45 @@ func (ec *executionContext) _Mutation_updateUsers(ctx context.Context, field gra
return ec.marshalNUsers2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐUsers(ctx, field.Selections, res)
}
func (ec *executionContext) _Mutation_createMenu(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Mutation",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Mutation_createMenu_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().CreateMenu(rctx, args["input"].(*model.MenuAccessInput))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.([]*model.Access)
fc.Result = res
return ec.marshalOAccess2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccessᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
... ... @@ -700,6 +1814,126 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll
return ec.marshalOUsers2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐUsersᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_menus(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Query_menus_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().Menus(rctx, args["input"].(*model.MenuAccessInput))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.([]*model.Access)
fc.Result = res
return ec.marshalOAccess2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccessᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_clientVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Query_clientVersion_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().ClientVersion(rctx, args["id"].(*int))
})
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.(*domain.ClientVersion)
fc.Result = res
return ec.marshalNClientVersion2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientVersion(ctx, field.Selections, res)
}
func (ec *executionContext) _Query_menu(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Query",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Query_menu_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().Menu(rctx, args["input"].(*model.MenuAccessInput))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.([]*model.Access)
fc.Result = res
return ec.marshalOAccess2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccessᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
... ... @@ -931,6 +2165,38 @@ func (ec *executionContext) _Role_updateTime(ctx context.Context, field graphql.
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) _Role_access(ctx context.Context, field graphql.CollectedField, obj *model.Role) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Role",
Field: field,
Args: nil,
IsMethod: true,
IsResolver: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Role().Access(rctx, obj)
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.([]*model.Access)
fc.Result = res
return ec.marshalOAccess2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccessᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _Users_name(ctx context.Context, field graphql.CollectedField, obj *model.Users) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
... ... @@ -2307,8 +3573,28 @@ func (ec *executionContext) unmarshalInputlistUsersInput(ctx context.Context, ob
case "limit":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit"))
it.Limit, err = ec.unmarshalNInt2int(ctx, v)
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit"))
it.Limit, err = ec.unmarshalNInt2int(ctx, v)
if err != nil {
return it, err
}
}
}
return it, nil
}
func (ec *executionContext) unmarshalInputmenuAccessInput(ctx context.Context, obj interface{}) (model.MenuAccessInput, error) {
var it model.MenuAccessInput
var asMap = obj.(map[string]interface{})
for k, v := range asMap {
switch k {
case "name":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v)
if err != nil {
return it, err
}
... ... @@ -2374,6 +3660,134 @@ func (ec *executionContext) unmarshalInputupdateUsersInput(ctx context.Context,
// region **************************** object.gotpl ****************************
var accessImplementors = []string{"Access"}
func (ec *executionContext) _Access(ctx context.Context, sel ast.SelectionSet, obj *model.Access) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, accessImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Access")
case "id":
out.Values[i] = ec._Access_id(ctx, field, obj)
case "parentId":
out.Values[i] = ec._Access_parentId(ctx, field, obj)
case "accessName":
out.Values[i] = ec._Access_accessName(ctx, field, obj)
case "accessCode":
out.Values[i] = ec._Access_accessCode(ctx, field, obj)
case "accessType":
out.Values[i] = ec._Access_accessType(ctx, field, obj)
case "sort":
out.Values[i] = ec._Access_sort(ctx, field, obj)
case "object":
out.Values[i] = ec._Access_object(ctx, field, obj)
case "action":
out.Values[i] = ec._Access_action(ctx, field, obj)
case "module":
out.Values[i] = ec._Access_module(ctx, field, obj)
case "icon":
out.Values[i] = ec._Access_icon(ctx, field, obj)
case "status":
out.Values[i] = ec._Access_status(ctx, field, obj)
case "user":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Access_user(ctx, field, obj)
return res
})
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var clientPackageInfoImplementors = []string{"ClientPackageInfo"}
func (ec *executionContext) _ClientPackageInfo(ctx context.Context, sel ast.SelectionSet, obj *domain.ClientPackageInfo) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, clientPackageInfoImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ClientPackageInfo")
case "FileName":
out.Values[i] = ec._ClientPackageInfo_FileName(ctx, field, obj)
case "Path":
out.Values[i] = ec._ClientPackageInfo_Path(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var clientVersionImplementors = []string{"ClientVersion"}
func (ec *executionContext) _ClientVersion(ctx context.Context, sel ast.SelectionSet, obj *domain.ClientVersion) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, clientVersionImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ClientVersion")
case "id":
out.Values[i] = ec._ClientVersion_id(ctx, field, obj)
case "commiter":
out.Values[i] = ec._ClientVersion_commiter(ctx, field, obj)
case "projectName":
out.Values[i] = ec._ClientVersion_projectName(ctx, field, obj)
case "version":
out.Values[i] = ec._ClientVersion_version(ctx, field, obj)
case "title":
out.Values[i] = ec._ClientVersion_title(ctx, field, obj)
case "remark":
out.Values[i] = ec._ClientVersion_remark(ctx, field, obj)
case "clientPackageInfo":
out.Values[i] = ec._ClientVersion_clientPackageInfo(ctx, field, obj)
case "createTime":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._ClientVersion_createTime(ctx, field, obj)
return res
})
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var mutationImplementors = []string{"Mutation"}
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
... ... @@ -2404,6 +3818,8 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null {
invalids++
}
case "createMenu":
out.Values[i] = ec._Mutation_createMenu(ctx, field)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
... ... @@ -2455,6 +3871,42 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
res = ec._Query_users(ctx, field)
return res
})
case "menus":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_menus(ctx, field)
return res
})
case "clientVersion":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_clientVersion(ctx, field)
if res == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
return res
})
case "menu":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_menu(ctx, field)
return res
})
case "__type":
out.Values[i] = ec._Query___type(ctx, field)
case "__schema":
... ... @@ -2491,6 +3943,17 @@ func (ec *executionContext) _Role(ctx context.Context, sel ast.SelectionSet, obj
out.Values[i] = ec._Role_createTime(ctx, field, obj)
case "updateTime":
out.Values[i] = ec._Role_updateTime(ctx, field, obj)
case "access":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Role_access(ctx, field, obj)
return res
})
default:
panic("unknown field " + strconv.Quote(field.Name))
}
... ... @@ -2792,6 +4255,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o
// region ***************************** type.gotpl *****************************
func (ec *executionContext) marshalNAccess2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccess(ctx context.Context, sel ast.SelectionSet, v *model.Access) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
return ec._Access(ctx, sel, v)
}
func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
... ... @@ -2807,6 +4280,30 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res
}
func (ec *executionContext) marshalNClientPackageInfo2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientPackageInfo(ctx context.Context, sel ast.SelectionSet, v *domain.ClientPackageInfo) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
return ec._ClientPackageInfo(ctx, sel, v)
}
func (ec *executionContext) marshalNClientVersion2githubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientVersion(ctx context.Context, sel ast.SelectionSet, v domain.ClientVersion) graphql.Marshaler {
return ec._ClientVersion(ctx, sel, &v)
}
func (ec *executionContext) marshalNClientVersion2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientVersion(ctx context.Context, sel ast.SelectionSet, v *domain.ClientVersion) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
return ec._ClientVersion(ctx, sel, v)
}
func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
res, err := graphql.UnmarshalInt(v)
return res, graphql.ErrorOnPath(ctx, err)
... ... @@ -3115,6 +4612,46 @@ func (ec *executionContext) unmarshalNupdateUsersInput2githubᚗcomᚋtiptokᚋg
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOAccess2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccessᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Access) graphql.Marshaler {
if v == nil {
return graphql.Null
}
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.marshalNAccess2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐAccess(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
return ret
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
... ... @@ -3139,6 +4676,71 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
return graphql.MarshalBoolean(*v)
}
func (ec *executionContext) marshalOClientPackageInfo2ᚕᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientPackageInfoᚄ(ctx context.Context, sel ast.SelectionSet, v []*domain.ClientPackageInfo) graphql.Marshaler {
if v == nil {
return graphql.Null
}
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.marshalNClientPackageInfo2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋdomainᚐClientPackageInfo(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
return ret
}
func (ec *executionContext) unmarshalODate2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋlibsᚐDatetime(ctx context.Context, v interface{}) (*libs.Datetime, error) {
if v == nil {
return nil, nil
}
var res = new(libs.Datetime)
err := res.UnmarshalGQL(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalODate2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋlibsᚐDatetime(ctx context.Context, sel ast.SelectionSet, v *libs.Datetime) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return v
}
func (ec *executionContext) unmarshalOInt2int64(ctx context.Context, v interface{}) (int64, error) {
res, err := graphql.UnmarshalInt64(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler {
return graphql.MarshalInt64(v)
}
func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) {
if v == nil {
return nil, nil
... ... @@ -3258,6 +4860,13 @@ func (ec *executionContext) marshalOUsers2ᚕᚖgithubᚗcomᚋtiptokᚋgodevp
return ret
}
func (ec *executionContext) marshalOUsers2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐUsers(ctx context.Context, sel ast.SelectionSet, v *model.Users) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Users(ctx, sel, v)
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
... ... @@ -3432,4 +5041,12 @@ func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen
return ec.___Type(ctx, sel, v)
}
func (ec *executionContext) unmarshalOmenuAccessInput2ᚖgithubᚗcomᚋtiptokᚋgodevpᚋpkgᚋportᚋgraphqlᚋgraphᚋmodelᚐMenuAccessInput(ctx context.Context, v interface{}) (*model.MenuAccessInput, error) {
if v == nil {
return nil, nil
}
res, err := ec.unmarshalInputmenuAccessInput(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
// endregion ***************************** type.gotpl *****************************
... ...
package libs
import (
"encoding/json"
"fmt"
"io"
"net/url"
"time"
)
type Datetime struct {
t time.Time
}
const TimeLayout = "2006-01-02T15:04:05.000Z"
func NewDatetimeFromTime(t time.Time) *Datetime {
return &Datetime{
t: t,
}
}
func (d *Datetime) GetTime() time.Time {
return d.t
}
func (d *Datetime) UnmarshalGQL(vi interface{}) (err error) {
v, ok := vi.(string)
if !ok {
return fmt.Errorf("unknown type of Datetime: `%+v`", vi)
}
if d.t, err = time.Parse(TimeLayout, v); err != nil {
return err
}
return nil
}
func (d Datetime) MarshalGQL(w io.Writer) {
if _, err := w.Write(appendQuote([]byte(d.t.Format(TimeLayout)))); err != nil {
//Logger.Error("write datetime bytes", zap.Error(err))
}
}
type QuotedString string
func (qs *QuotedString) UnmarshalGQL(vi interface{}) (err error) {
switch v := vi.(type) {
case string:
if v, err = url.QueryUnescape(v); err != nil {
//Logger.Debug("unquote string", zap.String("quoted", v), zap.Error(err))
return err
}
*qs = QuotedString(v)
return nil
}
//Logger.Debug("unknown type of QuotedString", zap.String("quoted", fmt.Sprint(vi)))
return fmt.Errorf("unknown type of QuotedString: `%+v`", vi)
}
func (qs QuotedString) MarshalGQL(w io.Writer) {
if _, err := w.Write(appendQuote([]byte(qs))); err != nil {
//Logger.Error("write bytes", zap.Error(err))
}
}
type JSONString string
func (qs *JSONString) UnmarshalGQL(vi interface{}) (err error) {
v, ok := vi.(string)
if !ok {
//Logger.Debug("unknown type of JSONString", zap.String("val", fmt.Sprint(vi)))
}
// var v string
//if err = json.UnmarshalFromString(v, &v); err != nil {
// //Logger.Debug("decode string", zap.String("quoted", v), zap.Error(err))
// return err
//}
*qs = JSONString(v)
return nil
}
func (qs JSONString) MarshalGQL(w io.Writer) {
if vb, err := json.Marshal(qs); err != nil {
//Logger.Error("marshal json", zap.Error(err))
} else {
if _, err = w.Write(vb); err != nil {
//Logger.Error("write bytes", zap.Error(err))
}
}
}
... ...
package libs
func appendQuote(v []byte) []byte {
r := []byte("\"")
r = append(r, v...)
r = append(r, '"')
return r
}
... ...
package model
type Access struct {
ID *int `json:"id"`
ParentID *int `json:"parentId"`
AccessName *string `json:"accessName"`
AccessCode *string `json:"accessCode"`
AccessType *string `json:"accessType"`
Sort *int `json:"sort"`
Object *string `json:"object"`
Action *string `json:"action"`
Module *string `json:"module"`
Icon *string `json:"icon"`
Status *int `json:"status"`
User *int `json:"user"`
}
... ...
... ... @@ -2,14 +2,6 @@
package model
type Role struct {
ID *int `json:"id"`
RoleName *string `json:"roleName"`
ParentID *int `json:"parentId"`
CreateTime *string `json:"createTime"`
UpdateTime *string `json:"updateTime"`
}
type CreateUsersInput struct {
Name string `json:"name"`
Phone string `json:"phone"`
... ... @@ -24,6 +16,10 @@ type ListUsersInput struct {
Limit int `json:"limit"`
}
type MenuAccessInput struct {
Name *string `json:"name"`
}
type RemoveUsersInput struct {
ID int `json:"id"`
}
... ...
package model
type Role struct {
ID *int `json:"id"`
RoleName *string `json:"roleName"`
ParentID *int `json:"parentId"`
CreateTime *string `json:"createTime"`
UpdateTime *string `json:"updateTime"`
Access []*int `json:"access"`
}
... ...
scalar Date
## type
type Users{
name: String
... ... @@ -14,6 +16,22 @@ type Role{
parentId: Int
createTime: String
updateTime: String
access:[Access!]
}
type ClientVersion{
id: Int
commiter: String
projectName: String
version: String
title: String
remark: String
clientPackageInfo: [ClientPackageInfo!]
createTime: Date
}
type ClientPackageInfo{
FileName: String
Path: String
}
## user input
... ... @@ -39,6 +57,10 @@ input listUsersInput{
type Query {
user(input : getUsersInput!): Users!
users(input : listUsersInput!): [Users!]
menus(input: menuAccessInput): [Access!]
clientVersion(id :Int):ClientVersion!
}
type Mutation{
... ...
... ... @@ -6,17 +6,27 @@ package graph
import (
"context"
"fmt"
query2 "github.com/tiptok/godevp/pkg/application/clientVersion/query"
"unsafe"
"github.com/tiptok/gocomm/common"
clientVersionService "github.com/tiptok/godevp/pkg/application/clientVersion/service"
"github.com/tiptok/godevp/pkg/application/factory"
"github.com/tiptok/godevp/pkg/application/users/command"
"github.com/tiptok/godevp/pkg/application/users/query"
"github.com/tiptok/godevp/pkg/application/users/service"
domain1 "github.com/tiptok/godevp/pkg/domain"
"github.com/tiptok/godevp/pkg/domain/role"
domain "github.com/tiptok/godevp/pkg/domain/users"
"github.com/tiptok/godevp/pkg/port/graphql/graph/generated"
"github.com/tiptok/godevp/pkg/port/graphql/graph/libs"
"github.com/tiptok/godevp/pkg/port/graphql/graph/model"
)
func (r *clientVersionResolver) CreateTime(ctx context.Context, obj *domain1.ClientVersion) (*libs.Datetime, error) {
return libs.NewDatetimeFromTime(obj.CreateTime), nil
}
func (r *mutationResolver) CreateUsers(ctx context.Context, input model.CreateUsersInput) (*model.Users, error) {
usersService := service.NewUsersService(nil)
createUsersCommand := &command.CreateUsersCommand{
... ... @@ -93,6 +103,44 @@ func (r *queryResolver) Users(ctx context.Context, input model.ListUsersInput) (
return nil, fmt.Errorf("type error except: domain.Users")
}
func (r *queryResolver) Menus(ctx context.Context, input *model.MenuAccessInput) ([]*model.Access, error) {
transactionContext, _ := factory.CreateDefaultTransactionContext(nil)
var AccessRepository, _ = factory.CreateAccessRepository(map[string]interface{}{"transactionContext": transactionContext})
_, access, _ := AccessRepository.Find(map[string]interface{}{})
var rsp []*model.Access
for _, item := range access {
rsp = append(rsp, &model.Access{
ID: (*int)(unsafe.Pointer(&item.Id)),
ParentID: (*int)(unsafe.Pointer(&item.ParentId)),
AccessName: &item.AccessName,
AccessCode: &item.AccessCode,
AccessType: &item.AccessType,
Sort: (*int)(unsafe.Pointer(&item.Sort)),
Object: &item.Object,
Action: &item.Action,
Module: &item.Module,
Icon: &item.Icon,
Status: (*int)(unsafe.Pointer(&item.Status)),
})
}
return rsp, nil
}
func (r *queryResolver) ClientVersion(ctx context.Context, id *int) (*domain1.ClientVersion, error) {
svr := clientVersionService.NewClientVersionService(nil)
m, err := svr.GetClientVersion(&query2.GetClientVersionQuery{Id: int64(*id)})
if err != nil || m == nil {
return nil, err
}
return m.(*domain1.ClientVersion), nil
}
func (r *roleResolver) Access(ctx context.Context, obj *model.Role) ([]*model.Access, error) {
return []*model.Access{
&model.Access{},
}, nil
}
func (r *usersResolver) Roles(ctx context.Context, obj *model.Users) ([]*model.Role, error) {
var ro = &role.Role{
Id: 1,
... ... @@ -112,15 +160,23 @@ func (r *usersResolver) Roles(ctx context.Context, obj *model.Users) ([]*model.R
}, nil
}
// ClientVersion returns generated.ClientVersionResolver implementation.
func (r *Resolver) ClientVersion() generated.ClientVersionResolver { return &clientVersionResolver{r} }
// 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} }
// Role returns generated.RoleResolver implementation.
func (r *Resolver) Role() generated.RoleResolver { return &roleResolver{r} }
// Users returns generated.UsersResolver implementation.
func (r *Resolver) Users() generated.UsersResolver { return &usersResolver{r} }
type clientVersionResolver struct{ *Resolver }
type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
type roleResolver struct{ *Resolver }
type usersResolver struct{ *Resolver }
... ...