app_page.api 3.8 KB

syntax = "v1"

info(
    title: "天联字库图表模板"
    desc: "图表模板"
    author: "小火箭"
    email: "email"
    version: "v1"
)

@server(
    prefix: v1
    group: page
    jwt: JwtAuth
    middleware: LoginStatusCheck,LogRequest
)
service Core {
    @doc "保存应用页"
    @handler saveAppPage
    post /app-page (AppPageSaveRequest) returns (AppPageSaveResponse)
    @doc "应用页另存为"
    @handler saveAsAppPage
    post /app-page/saveas (AppPageSaveAsRequest) returns (AppPageSaveAsResponse)
    @doc "删除应用页"
    @handler deleteAppPage
    delete /app-page/:id (AppPageDeleteRequest) returns (AppPageDeleteResponse)
    @doc "更新应用页"
    @handler updateAppPage
    put /app-page/:id (AppPageUpdateRequest) returns (AppPageUpdateResponse)
    @doc "搜索"
    @handler searchAppPage
    post /app-page/search (AppPageSearchRequest) returns (AppPageSearchResponse)
    @doc "创建应用页分享"
    @handler createAppPageShareUrl
    post /app-page/create-share (AppPageCreateShareRequest) returns (AppPageCreateShareResponse)
}


type (
    AppPageGetRequest {
		Id int64 `path:"id"`
	}
    AppPageGetResponse struct{
		AppPage AppPageItem `json:"page"`
    }

	AppPageSaveRequest struct{
        Name      string      `json:"name"`   // 名称
        Charts    []int64     `json:"charts"`// 图表
        Cover        string   `json:"cover,optional"`  // 封面
    }
    AppPageSaveResponse struct{
        Id int64 `json:"id"`
    }

    AppPageSaveAsRequest struct{
        Id        int64  `json:"id"`     // 页面ID
        Name      string `json:"name"`   // 名称
    }
    AppPageSaveAsResponse struct{
        Id        int64 `path:"id"`
        Name      string `json:"name"`   // 名称
        Charts    []int64 `json:"charts"`// 图表
    }
    AppPageCreateShareRequest struct{
        Id int64 `json:"id"` // 页面ID
    }
    AppPageCreateShareResponse struct{
        Key       string `json:"key,optional"`    // 分享,预览时绑定映射到Id
    }
	AppPageDeleteRequest struct{
        Id int64 `path:"id"` // 页面ID
    }
    AppPageDeleteResponse struct{}

	AppPageUpdateRequest struct{
		Id int64 `path:"id"`
        Name      string `json:"name,optional"`   // 名称
        Charts    []int64 `json:"charts"`// 图表
        Cover     string  `json:"cover,optional"`  // 封面
    }
    AppPageUpdateResponse struct{}

 	AppPageSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    AppPageSearchResponse{
        List []AppPageItem  `json:"list"`
        Total int64 `json:"total"`
    }
	AppPageItem struct{
        Id        int64 `json:"id,optional"` // 唯一标识
        Name      string `json:"name,optional"`   // 名称
        Cover     string  `json:"cover,optional"`  // 封面
        Charts    []AppPageChartItem `json:"charts,optional"`// 图表
        UpdatedAt int64 `json:"updatedAt,optional"` //更新时间
	}
    AppPageChartItem struct{
        ChartId      int64        `json:"chartId"`  // 图表ID
        Name         string       `json:"name"`   // 图表名称
        Cover        string       `json:"cover"`  // 图表封面
        ChartType    string       `json:"chartType,optional"` // 图表类型
    }
)


@server(
    prefix: v1
    group: page
    middleware: LogRequest
)
service Core {
    @doc "获取应用页详情"
    @handler getAppPage
    get /app-page/:id (AppPageGetRequest) returns (AppPageGetResponse)

    @doc "开放接口-获取应用页详情通过KEY"
    @handler getAppPageShareDetail
    get /api/app-page/get-share-detail/:key (GetAppPageShareDetailRequest) returns (GetAppPageShareDetailResponse)
}

type (
    GetAppPageShareDetailRequest struct{
        Key string `path:"key"`
    }
    GetAppPageShareDetailResponse struct{
        AppPage AppPageItem `json:"page"`
    }
)