|
|
@ -4,8 +4,8 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent"
|
|
|
|
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent"
|
|
|
|
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
|
|
|
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
|
|
|
|
|
|
|
|
"git.noahlan.cn/noahlan/ntool/ntime"
|
|
|
|
"github.com/jinzhu/copier"
|
|
|
|
"github.com/jinzhu/copier"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Convert struct {
|
|
|
|
type Convert struct {
|
|
|
@ -24,8 +24,8 @@ func (c *Convert) ConvertRoleRpc(_ context.Context, v *ent.Role) *core.RoleInfo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var tmp core.RoleInfo
|
|
|
|
var tmp core.RoleInfo
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
tmp.CreatedAt = v.CreatedAt.Format(time.DateTime)
|
|
|
|
tmp.CreatedAt = ntime.Format(v.CreatedAt)
|
|
|
|
tmp.UpdatedAt = v.UpdatedAt.Format(time.DateTime)
|
|
|
|
tmp.UpdatedAt = ntime.Format(v.UpdatedAt)
|
|
|
|
tmp.Status = v.Status.String()
|
|
|
|
tmp.Status = v.Status.String()
|
|
|
|
|
|
|
|
|
|
|
|
return &tmp
|
|
|
|
return &tmp
|
|
|
@ -38,8 +38,8 @@ func (c *Convert) ConvertUserRpc(ctx context.Context, v *ent.User) *core.UserInf
|
|
|
|
var tmp core.UserInfo
|
|
|
|
var tmp core.UserInfo
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
tmp.Status = v.Status.String()
|
|
|
|
tmp.Status = v.Status.String()
|
|
|
|
tmp.CreatedAt = v.CreatedAt.Format(time.DateTime)
|
|
|
|
tmp.CreatedAt = ntime.Format(v.CreatedAt)
|
|
|
|
tmp.UpdatedAt = v.UpdatedAt.Format(time.DateTime)
|
|
|
|
tmp.UpdatedAt = ntime.Format(v.UpdatedAt)
|
|
|
|
|
|
|
|
|
|
|
|
// Metadata
|
|
|
|
// Metadata
|
|
|
|
if len(v.Edges.Metas) > 0 {
|
|
|
|
if len(v.Edges.Metas) > 0 {
|
|
|
@ -83,6 +83,9 @@ func (c *Convert) ConvertLoginRecordRpc(_ context.Context, v *ent.LoginRecord) *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var tmp core.LoginRecordInfo
|
|
|
|
var tmp core.LoginRecordInfo
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
|
|
|
|
tmp.CreatedAt = ntime.Format(v.CreatedAt)
|
|
|
|
|
|
|
|
tmp.UpdatedAt = ntime.Format(v.UpdatedAt)
|
|
|
|
|
|
|
|
|
|
|
|
tmp.UserId = v.UserID
|
|
|
|
tmp.UserId = v.UserID
|
|
|
|
tmp.LastLoginUa = v.LastLoginUA
|
|
|
|
tmp.LastLoginUa = v.LastLoginUA
|
|
|
|
return &tmp
|
|
|
|
return &tmp
|
|
|
@ -94,6 +97,9 @@ func (c *Convert) ConvertDepartmentRpc(ctx context.Context, v *ent.Department) *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var tmp core.DepartmentInfo
|
|
|
|
var tmp core.DepartmentInfo
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
|
|
|
|
tmp.CreatedAt = ntime.Format(v.CreatedAt)
|
|
|
|
|
|
|
|
tmp.UpdatedAt = ntime.Format(v.UpdatedAt)
|
|
|
|
|
|
|
|
|
|
|
|
tmp.LeaderId = v.LeaderID
|
|
|
|
tmp.LeaderId = v.LeaderID
|
|
|
|
tmp.ParentId = v.ParentID
|
|
|
|
tmp.ParentId = v.ParentID
|
|
|
|
// relationship
|
|
|
|
// relationship
|
|
|
@ -118,3 +124,20 @@ func (c *Convert) ConvertDepartmentRpc(ctx context.Context, v *ent.Department) *
|
|
|
|
|
|
|
|
|
|
|
|
return &tmp
|
|
|
|
return &tmp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Convert) ConvertOAuthProviderRpc(_ context.Context, v *ent.OauthProvider) *core.OauthProviderInfo {
|
|
|
|
|
|
|
|
if v == nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var tmp core.OauthProviderInfo
|
|
|
|
|
|
|
|
_ = copier.Copy(&tmp, v)
|
|
|
|
|
|
|
|
tmp.CreatedAt = ntime.Format(v.CreatedAt)
|
|
|
|
|
|
|
|
tmp.UpdatedAt = ntime.Format(v.UpdatedAt)
|
|
|
|
|
|
|
|
tmp.ClientId = v.ClientID
|
|
|
|
|
|
|
|
tmp.RedirectUrl = v.RedirectURL
|
|
|
|
|
|
|
|
tmp.AuthUrl = v.AuthURL
|
|
|
|
|
|
|
|
tmp.TokenUrl = v.TokenURL
|
|
|
|
|
|
|
|
tmp.InfoUrl = v.InfoURL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return &tmp
|
|
|
|
|
|
|
|
}
|
|
|
|