migrate from github
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type AttachmentResponse struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
DocumentExternalID string `json:"document_external_id"`
|
||||
Name string `json:"name"`
|
||||
Size int64 `json:"size"`
|
||||
MimeType string `json:"mime_type"`
|
||||
Path string `json:"path"`
|
||||
URL string `json:"url"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dto
|
||||
|
||||
type CreateCommentRequest struct {
|
||||
DocumentExternalID string `json:"document_external_id"`
|
||||
Content string `json:"content"`
|
||||
ParentExternalID *string `json:"parent_external_id,omitempty"`
|
||||
AnchorID *string `json:"anchor_id,omitempty"`
|
||||
Quote *string `json:"quote,omitempty"`
|
||||
CreatorExternalID string `json:"creator_external_id"`
|
||||
MentionedUserExternalIDs []string `json:"mentioned_user_external_ids,omitempty"`
|
||||
}
|
||||
|
||||
type ListCommentsRequest struct {
|
||||
DocumentExternalID string `json:"document_external_id"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type DeleteCommentRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
OperatorExternalID string `json:"operator_external_id"`
|
||||
}
|
||||
|
||||
type UpdateCommentRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Content string `json:"content"`
|
||||
OperatorExternalID string `json:"operator_external_id"`
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/XingfenD/yoresee_doc/internal/model"
|
||||
)
|
||||
|
||||
type DocumentType string
|
||||
|
||||
const DocumentType_Markdown DocumentType = "markdown"
|
||||
const DocumentType_Table DocumentType = "table"
|
||||
const DocumentType_MarkdownSlide DocumentType = "markdown_slide"
|
||||
const DocumentType_YoreseeRichText DocumentType = "yoresee_rich_text"
|
||||
|
||||
type ContainerType string
|
||||
|
||||
const ContainerType_Own ContainerType = "own"
|
||||
const ContainerType_KnowledgeBase ContainerType = "knowledge_base"
|
||||
|
||||
type DocumentBase struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Title string `json:"title"`
|
||||
Type DocumentType `json:"type"`
|
||||
Summary string `json:"summary"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
Tags []string `json:"tags"`
|
||||
ViewCount int `json:"view_count"`
|
||||
EditCount int `json:"edit_count"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type DocumentMetaResponse struct {
|
||||
DocumentBase
|
||||
Children []*DocumentMetaResponse `json:"children,omitempty"`
|
||||
HasChildren bool `json:"hasChildren,omitempty"`
|
||||
}
|
||||
|
||||
type DocumentResponse struct {
|
||||
DocumentMetaResponse
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
func NewDocumentMetaResponseFromModel(doc *model.Document) *DocumentMetaResponse {
|
||||
response := &DocumentMetaResponse{
|
||||
DocumentBase: DocumentBase{
|
||||
ExternalID: doc.ExternalID,
|
||||
Title: doc.Title,
|
||||
Type: DocumentType(doc.Type),
|
||||
Summary: doc.Summary,
|
||||
IsPublic: doc.IsPublic,
|
||||
Tags: doc.Tags,
|
||||
ViewCount: doc.ViewCount,
|
||||
EditCount: doc.EditCount,
|
||||
CreatedAt: doc.CreatedAt,
|
||||
UpdatedAt: doc.UpdatedAt,
|
||||
},
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
func NewDocumentResponseFromModel(doc *model.Document) *DocumentResponse {
|
||||
if doc == nil {
|
||||
return &DocumentResponse{}
|
||||
}
|
||||
response := &DocumentResponse{
|
||||
DocumentMetaResponse: DocumentMetaResponse{
|
||||
DocumentBase: DocumentBase{
|
||||
ExternalID: doc.ExternalID,
|
||||
Title: doc.Title,
|
||||
Type: DocumentType(doc.Type),
|
||||
Summary: doc.Summary,
|
||||
IsPublic: doc.IsPublic,
|
||||
Tags: doc.Tags,
|
||||
ViewCount: doc.ViewCount,
|
||||
EditCount: doc.EditCount,
|
||||
CreatedAt: doc.CreatedAt,
|
||||
UpdatedAt: doc.UpdatedAt,
|
||||
},
|
||||
},
|
||||
Content: doc.Content,
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// type DirectoryResponse struct {
|
||||
// ExternalID string `json:"external_id"`
|
||||
// Title string `json:"title"`
|
||||
// HasChildren bool `json:"has_children"`
|
||||
// ParentID string `json:"parent_id"`
|
||||
// }
|
||||
|
||||
type DocumentsListExternalArgs struct {
|
||||
UserExternalID *string `json:"user_external_id"`
|
||||
RootDocumentExternalID *string `json:"root_document_external_id"`
|
||||
KnowledgeExternalID *string `json:"knowledge_external_id"`
|
||||
}
|
||||
|
||||
type DocumentsListFilterArgs struct {
|
||||
TitleKeyword *string `json:"title_keyword"`
|
||||
DocType *string `json:"doc_type"`
|
||||
Tags []string `json:"tags"`
|
||||
CreateTimeRangeStart *string `json:"create_time_range_start"`
|
||||
CreateTimeRangeEnd *string `json:"create_time_range_end"`
|
||||
UpdateTimeRangeStart *string `json:"update_time_range_start"`
|
||||
UpdateTimeRangeEnd *string `json:"update_time_range_end"`
|
||||
}
|
||||
|
||||
type ListDocumentsBaseArgs struct {
|
||||
ListOwnDoc bool `json:"list_own_doc"`
|
||||
DirectoryOnly bool `json:"directory_only"`
|
||||
}
|
||||
|
||||
type ListRecentDocumentsRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
StartTime *time.Time `json:"start_time"`
|
||||
EndTime *time.Time `json:"end_time"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type RecordRecentDocumentRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
DocumentExternalID string `json:"document_external_id"`
|
||||
}
|
||||
|
||||
type ListDocumentsByExternalRequest struct {
|
||||
ExternalArgs *DocumentsListExternalArgs `json:"external_args"`
|
||||
ListDocumentsBaseArgs
|
||||
FilterArgs *DocumentsListFilterArgs `json:"filter_args"`
|
||||
SortArgs SortArgs `json:"sort_args"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
Options *RecursiveOptions `json:"options"`
|
||||
}
|
||||
|
||||
type CreateDocumentRequest struct {
|
||||
Title string `json:"title"`
|
||||
Type DocumentType `json:"type"`
|
||||
ContainerType ContainerType `json:"container_type"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
CreatorExternalID *string `json:"creator_external_id"`
|
||||
TemplateID *int64 `json:"template_id"`
|
||||
|
||||
// optional
|
||||
ParentExternalID *string `json:"parent_external_id"`
|
||||
KnowledgeExternalID *string `json:"knowledge_external_id"`
|
||||
}
|
||||
|
||||
type CreateDocumentResponse struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type UpdateDocumentRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
KnowledgeBaseExternalID *string `json:"knowledge_base_external_id,omitempty"`
|
||||
ParentExternalID *string `json:"parent_external_id,omitempty"`
|
||||
MoveToContainer *ContainerType `json:"move_to_container,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDocumentMetaRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
Tags *[]string `json:"tags,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dto
|
||||
|
||||
type GetDocumentSettingsRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type DocumentSettingsResponse struct {
|
||||
IsPublic bool `json:"is_public"`
|
||||
}
|
||||
|
||||
type UpdateDocumentSettingsRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type DocumentVersionResponse struct {
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
ChangeSummary string `json:"change_summary"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dto
|
||||
|
||||
type Pagination struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
func (p *Pagination) Validate() bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
if p.Page <= 0 || p.PageSize <= 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type SortArgs struct {
|
||||
Field string `json:"field"`
|
||||
Desc bool `json:"desc"`
|
||||
}
|
||||
|
||||
type RecursiveOptions struct {
|
||||
IncludeChildren bool `json:"include_children"`
|
||||
Recursive bool `json:"recursive"`
|
||||
Depth *int `json:"depth"`
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type ListInvitationsReq struct {
|
||||
CreatorID *int64 `json:"creator_id"`
|
||||
MaxUsedCnt *int64 `json:"max_used_cnt"`
|
||||
ExpiresAtStart *string `json:"expires_at_start"`
|
||||
ExpiresAtEnd *string `json:"expires_at_end"`
|
||||
CreatedAtStart *string `json:"created_at_start"`
|
||||
CreatedAtEnd *string `json:"created_at_end"`
|
||||
Disabled *bool `json:"disabled"`
|
||||
OnlyMine *bool `json:"only_mine"`
|
||||
Keyword *string `json:"keyword"`
|
||||
SortArgs SortArgs `json:"sort_args"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type CreateInvitationRequest struct {
|
||||
CreatorExternalID string `json:"creator_external_id"`
|
||||
MaxUsedCnt *int64 `json:"max_used_cnt"`
|
||||
ExpiresAt *time.Time `json:"expires_at"`
|
||||
Note *string `json:"note"`
|
||||
}
|
||||
|
||||
type UpdateInvitationRequest struct {
|
||||
Code string `json:"code"`
|
||||
MaxUsedCnt *int64 `json:"max_used_cnt"`
|
||||
ExpiresAt *time.Time `json:"expires_at"`
|
||||
Disabled *bool `json:"disabled"`
|
||||
Note *string `json:"note"`
|
||||
}
|
||||
|
||||
type DeleteInvitationRequest struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type InvitationResponse struct {
|
||||
Code string `json:"code"`
|
||||
CreatedByExternalID string `json:"created_by_external_id"`
|
||||
CreatedByName string `json:"created_by_name"`
|
||||
UsedCnt int64 `json:"used_cnt"`
|
||||
MaxUsedCnt *int64 `json:"max_used_cnt"`
|
||||
ExpiresAt *time.Time `json:"expires_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Note *string `json:"note"`
|
||||
}
|
||||
|
||||
type ListInvitationRecordsRequest struct {
|
||||
Code *string `json:"code"`
|
||||
Status *string `json:"status"`
|
||||
UsedAtStart *string `json:"used_at_start"`
|
||||
UsedAtEnd *string `json:"used_at_end"`
|
||||
CreatorID *int64 `json:"creator_id"`
|
||||
OnlyMine *bool `json:"only_mine"`
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type InvitationRecordResponse struct {
|
||||
Code string `json:"code"`
|
||||
UsedBy string `json:"used_by"`
|
||||
UsedByExternalID string `json:"used_by_external_id"`
|
||||
UsedAt time.Time `json:"used_at"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/XingfenD/yoresee_doc/internal/model"
|
||||
)
|
||||
|
||||
type KnowledgeBaseBase struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt time.Time `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type KnowledgeBaseExtend struct {
|
||||
CreatorUserExternalID string `json:"creator_user_external_id"`
|
||||
CreatorName string `json:"creator_name"`
|
||||
DocumentsCount int64 `json:"documents_count"`
|
||||
}
|
||||
|
||||
type KnowledgeBaseResponse struct {
|
||||
KnowledgeBaseBase
|
||||
KnowledgeBaseExtend
|
||||
}
|
||||
|
||||
func NewKnowledgeBaseResponseFromModel(kb *model.KnowledgeBase, kbExtend *KnowledgeBaseExtend) *KnowledgeBaseResponse {
|
||||
response := &KnowledgeBaseResponse{
|
||||
KnowledgeBaseBase: KnowledgeBaseBase{
|
||||
ExternalID: kb.ExternalID,
|
||||
Name: kb.Name,
|
||||
Description: kb.Description,
|
||||
Cover: kb.Cover,
|
||||
IsPublic: kb.IsPublic,
|
||||
CreatedAt: kb.CreatedAt,
|
||||
UpdatedAt: kb.UpdatedAt,
|
||||
DeletedAt: kb.DeletedAt,
|
||||
},
|
||||
}
|
||||
if kbExtend != nil {
|
||||
response.KnowledgeBaseExtend = KnowledgeBaseExtend{
|
||||
CreatorUserExternalID: kbExtend.CreatorUserExternalID,
|
||||
CreatorName: kbExtend.CreatorName,
|
||||
DocumentsCount: kbExtend.DocumentsCount,
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
type CreateRecentKnowledgeBaseRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
KnowledgeBaseExternalID string `json:"knowledge_base_external_id"`
|
||||
AssessTime time.Time `json:"assess_time"`
|
||||
}
|
||||
|
||||
type CreateKnowledgeBaseRequest struct {
|
||||
CreatorExternalID string `json:"creator_external_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
}
|
||||
|
||||
type CreateKnowledgeBaseResponse struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type ListRecentKnowledgeBasesRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
StartTime *time.Time `json:"start_time,omitempty"`
|
||||
EndTime *time.Time `json:"end_time,omitempty"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type KnowledgeBaseListByExternalRequest struct {
|
||||
CreatorExternalID string `json:"creator_external_id"`
|
||||
FilterArgs *KnowledgeBaseListFilterArgs `json:"filter_args"`
|
||||
SortArgs SortArgs `json:"sort_args"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type KnowledgeBaseGetByExternalIDRequest struct {
|
||||
KnowledgeBaseExternalID string `json:"knowledge_base_external_id"`
|
||||
}
|
||||
|
||||
type KnowledgeBaseListFilterArgs struct {
|
||||
IsPublic *bool `json:"is_public"`
|
||||
NameKeyword *string `json:"name_keyword"`
|
||||
CreateTimeRangeStart *string `json:"create_time_range_start"`
|
||||
CreateTimeRangeEnd *string `json:"create_time_range_end"`
|
||||
UpdateTimeRangeStart *string `json:"update_time_range_start"`
|
||||
UpdateTimeRangeEnd *string `json:"update_time_range_end"`
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package dto
|
||||
|
||||
// MembershipType mirrors model.MembershipType to keep DTO layer independent.
|
||||
type MembershipType int64
|
||||
|
||||
const (
|
||||
MembershipType_UserGroup MembershipType = 1
|
||||
MembershipType_OrgNode MembershipType = 2
|
||||
)
|
||||
|
||||
type MembershipRelationBase struct {
|
||||
Type MembershipType `json:"type"`
|
||||
UserID int64 `json:"user_id"`
|
||||
MembershipID int64 `json:"membership_id"`
|
||||
}
|
||||
|
||||
type MembershipBase struct {
|
||||
Type MembershipType `json:"type"`
|
||||
MembershipExternalID string `json:"membership_external_id"`
|
||||
MembershipName string `json:"membership_name"`
|
||||
}
|
||||
|
||||
type MembershipBaseRequest struct {
|
||||
Type MembershipType `json:"type"`
|
||||
MembershipExternalID string `json:"membership_external_id"`
|
||||
}
|
||||
|
||||
type MembershipMetaResponse struct {
|
||||
MembershipBase
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type CreateMembershipRelationRequest struct {
|
||||
MembershipBaseRequest
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
}
|
||||
|
||||
type MembershipRelationResponse struct {
|
||||
MembershipBase
|
||||
UserList []UserBase `json:"user_list"`
|
||||
}
|
||||
|
||||
// type MembershipAuthorityResponse struct {
|
||||
// MembershipBase
|
||||
// CreatorExternalID string
|
||||
// CurrentUserAuthority []model.Permission
|
||||
// }
|
||||
@@ -0,0 +1,20 @@
|
||||
package dto
|
||||
|
||||
type CreateNotificationRequest struct {
|
||||
ReceiverExternalIDs []string `json:"receiver_external_ids"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
PayloadJSON string `json:"payload_json"`
|
||||
}
|
||||
|
||||
type ListNotificationsRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type MarkNotificationsReadRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
ExternalIDs []string `json:"external_ids"`
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package dto
|
||||
|
||||
type OrgNodeResponse struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
ParentExternalID string `json:"parent_external_id"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Description string `json:"description"`
|
||||
CreatorUserExternalID string `json:"creator_user_external_id"`
|
||||
MemberCount int `json:"member_count"`
|
||||
Children []*OrgNodeResponse `json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type ListOrgNodesRequest struct {
|
||||
ParentExternalID string `json:"parent_external_id"`
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
IncludeChildren bool `json:"include_children"`
|
||||
}
|
||||
|
||||
type GetOrgNodeRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
IncludeChildren bool `json:"include_children"`
|
||||
}
|
||||
|
||||
type CreateOrgNodeRequest struct {
|
||||
CreatorUserExternalID string `json:"creator_user_external_id"`
|
||||
ParentExternalID string `json:"parent_external_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
MemberUserExternalIDs []string `json:"member_user_external_ids"`
|
||||
}
|
||||
|
||||
type UpdateOrgNodeRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
SyncMembers bool `json:"sync_members"`
|
||||
MemberUserExternalIDs []string `json:"member_user_external_ids"`
|
||||
}
|
||||
|
||||
type DeleteOrgNodeRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type MoveOrgNodeRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
NewParentExternalID string `json:"new_parent_external_id"`
|
||||
}
|
||||
|
||||
type ListOrgNodeMembersRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PermissionGrant 权限授予请求
|
||||
type PermissionGrant struct {
|
||||
Resource Resource `json:"resource" binding:"required"`
|
||||
Subject Subject `json:"subject" binding:"required"`
|
||||
Permissions []string `json:"permissions" binding:"required"`
|
||||
Scope Scope `json:"scope" binding:"required"`
|
||||
Priority int `json:"priority"`
|
||||
IsDeny bool `json:"is_deny"`
|
||||
ValidFrom *time.Time `json:"valid_from"`
|
||||
ValidUntil *time.Time `json:"valid_until"`
|
||||
}
|
||||
|
||||
// Resource 资源DTO
|
||||
type Resource struct {
|
||||
Type string `json:"type" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
type Subject struct {
|
||||
Type string `json:"type" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type Scope struct {
|
||||
Type string `json:"type" binding:"required"`
|
||||
}
|
||||
|
||||
type PermissionCheck struct {
|
||||
Resource Resource `json:"resource" binding:"required"`
|
||||
Permission string `json:"permission" binding:"required"`
|
||||
}
|
||||
|
||||
type PermissionBatchCheck struct {
|
||||
Resource Resource `json:"resource" binding:"required"`
|
||||
Permissions []string `json:"permissions" binding:"required"`
|
||||
}
|
||||
|
||||
type PermissionBatchCheckResponse map[string]bool
|
||||
|
||||
type PermissionEffectiveResponse []string
|
||||
@@ -0,0 +1,67 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type TemplateContainer string
|
||||
|
||||
const (
|
||||
TemplateContainerOwn TemplateContainer = "own"
|
||||
TemplateContainerKnowledgeBase TemplateContainer = "knowledge_base"
|
||||
TemplateContainerPublic TemplateContainer = "public"
|
||||
)
|
||||
|
||||
type CreateTemplateRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
TargetContainer TemplateContainer `json:"target_container"`
|
||||
KnowledgeBaseExternalID *string `json:"knowledge_base_external_id,omitempty"`
|
||||
TemplateContent string `json:"template_content"`
|
||||
Type DocumentType `json:"type"`
|
||||
}
|
||||
|
||||
type UpdateTemplateSettingsRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
TemplateID int64 `json:"template_id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
IsPublic *bool `json:"is_public,omitempty"`
|
||||
}
|
||||
|
||||
type TemplateResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Content string `json:"content"`
|
||||
Type DocumentType `json:"type"`
|
||||
Scope string `json:"scope"`
|
||||
KnowledgeBaseExternalID string `json:"knowledge_base_external_id"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type TemplateListFilterArgs struct {
|
||||
NameKeyword *string `json:"name_keyword"`
|
||||
TargetContainer *TemplateContainer `json:"target_container"`
|
||||
KnowledgeBaseID *string `json:"knowledge_base_id"`
|
||||
Type *DocumentType `json:"type"`
|
||||
}
|
||||
|
||||
type TemplateListByExternalRequest struct {
|
||||
CreatorExternalID string `json:"creator_external_id"`
|
||||
FilterArgs *TemplateListFilterArgs `json:"filter_args"`
|
||||
SortArgs SortArgs `json:"sort_args"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type CreateRecentTemplateRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
TemplateID int64 `json:"template_id"`
|
||||
AccessTime time.Time `json:"access_time"`
|
||||
}
|
||||
|
||||
type ListRecentTemplatesRequest struct {
|
||||
UserExternalID string `json:"user_external_id"`
|
||||
StartTime *time.Time `json:"start_time,omitempty"`
|
||||
EndTime *time.Time `json:"end_time,omitempty"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/XingfenD/yoresee_doc/internal/model"
|
||||
)
|
||||
|
||||
type UserBase struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
AvatarObjectKey string `json:"-"`
|
||||
AvatarVersion int64 `json:"-"`
|
||||
Status int `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type UserCreate struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
InvitationCode *string `json:"invitation_code"`
|
||||
}
|
||||
|
||||
type UserUpdate struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Status int `json:"status"`
|
||||
InvitationCode *string `json:"invitation_code"`
|
||||
}
|
||||
|
||||
type UpdateProfileRequest struct {
|
||||
Username *string `json:"username"`
|
||||
Email *string `json:"email"`
|
||||
Nickname *string `json:"nickname"`
|
||||
Password *string `json:"password"`
|
||||
AvatarFile []byte `json:"avatar_file"`
|
||||
AvatarFilename *string `json:"avatar_filename"`
|
||||
AvatarContentType *string `json:"avatar_content_type"`
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
UserBase
|
||||
InvitationCode *string `json:"invitation_code"`
|
||||
}
|
||||
|
||||
func NewUserResponseFromModel(user *model.User) *UserResponse {
|
||||
return &UserResponse{
|
||||
UserBase: UserBase{
|
||||
ExternalID: user.ExternalID,
|
||||
Username: user.Username,
|
||||
Email: user.Email,
|
||||
Nickname: user.Nickname,
|
||||
Avatar: "",
|
||||
AvatarObjectKey: user.AvatarObjectKey,
|
||||
AvatarVersion: user.AvatarVersion,
|
||||
Status: user.Status,
|
||||
CreatedAt: user.CreatedAt,
|
||||
UpdatedAt: user.UpdatedAt,
|
||||
},
|
||||
InvitationCode: user.InvitationCode,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package dto
|
||||
|
||||
type UserGroupResponse struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
CreatorUserExternalID string `json:"creator_user_external_id"`
|
||||
MemberCount int `json:"member_count"`
|
||||
}
|
||||
|
||||
type ListUserGroupsRequest struct {
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type GetUserGroupRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type CreateUserGroupRequest struct {
|
||||
CreatorUserExternalID string `json:"creator_user_external_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
MemberUserExternalIDs []string `json:"member_user_external_ids"`
|
||||
}
|
||||
|
||||
type UpdateUserGroupRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
SyncMembers bool `json:"sync_members"`
|
||||
MemberUserExternalIDs []string `json:"member_user_external_ids"`
|
||||
}
|
||||
|
||||
type DeleteUserGroupRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
}
|
||||
|
||||
type ListUsersRequest struct {
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type UpdateUserRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Username *string `json:"username"`
|
||||
Email *string `json:"email"`
|
||||
Nickname *string `json:"nickname"`
|
||||
Status *int32 `json:"status"`
|
||||
}
|
||||
|
||||
type ListUserGroupMembersRequest struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
Keyword *string `json:"keyword"`
|
||||
Pagination Pagination `json:"pagination"`
|
||||
}
|
||||
Reference in New Issue
Block a user