正在显示
18 个修改的文件
包含
128 行增加
和
23 行删除
| @@ -31,6 +31,7 @@ ENV CONFIG_FILE=${CONFIG_FILE} | @@ -31,6 +31,7 @@ ENV CONFIG_FILE=${CONFIG_FILE} | ||
| 31 | 31 | ||
| 32 | COPY --from=builder /build/api/${PROJECT} ./ | 32 | COPY --from=builder /build/api/${PROJECT} ./ |
| 33 | COPY --from=builder /build/cmd/chart-server/api/etc/${CONFIG_FILE} ./etc/ | 33 | COPY --from=builder /build/cmd/chart-server/api/etc/${CONFIG_FILE} ./etc/ |
| 34 | +COPY --from=builder /build/cmd/chart-server/api/public ./public/ | ||
| 34 | 35 | ||
| 35 | EXPOSE 8080 | 36 | EXPOSE 8080 |
| 36 | ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} | 37 | ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} |
| @@ -12,6 +12,7 @@ type Config struct { | @@ -12,6 +12,7 @@ type Config struct { | ||
| 12 | config.Config | 12 | config.Config |
| 13 | Redis redis.RedisConf `json:",optional"` | 13 | Redis redis.RedisConf `json:",optional"` |
| 14 | ByteMetadata ApiService | 14 | ByteMetadata ApiService |
| 15 | + HostName string // 服务域名 | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | type ApiService struct { | 18 | type ApiService struct { |
| 1 | +package public | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + "path/filepath" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func GetFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.PublicGetFileRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + handler := http.FileServer(http.Dir("public")) | ||
| 21 | + r.URL.Path = filepath.Join(req.FileName) | ||
| 22 | + handler.ServeHTTP(w, r) | ||
| 23 | + } | ||
| 24 | +} |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | chart "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/chart" | 7 | chart "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/chart" |
| 8 | log "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/log" | 8 | log "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/log" |
| 9 | page "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/page" | 9 | page "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/page" |
| 10 | + public "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/public" | ||
| 10 | table "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/table" | 11 | table "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/table" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" |
| 12 | 13 | ||
| @@ -17,11 +18,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -17,11 +18,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 17 | server.AddRoutes( | 18 | server.AddRoutes( |
| 18 | []rest.Route{ | 19 | []rest.Route{ |
| 19 | { | 20 | { |
| 20 | - Method: http.MethodGet, | ||
| 21 | - Path: "/chart/:id", | ||
| 22 | - Handler: chart.GetChartHandler(serverCtx), | ||
| 23 | - }, | ||
| 24 | - { | ||
| 25 | Method: http.MethodPost, | 21 | Method: http.MethodPost, |
| 26 | Path: "/chart", | 22 | Path: "/chart", |
| 27 | Handler: chart.SaveChartHandler(serverCtx), | 23 | Handler: chart.SaveChartHandler(serverCtx), |
| @@ -73,6 +69,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -73,6 +69,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 73 | Path: "/chart/load-data", | 69 | Path: "/chart/load-data", |
| 74 | Handler: chart.LoadChartDataHandler(serverCtx), | 70 | Handler: chart.LoadChartDataHandler(serverCtx), |
| 75 | }, | 71 | }, |
| 72 | + { | ||
| 73 | + Method: http.MethodGet, | ||
| 74 | + Path: "/chart/:id", | ||
| 75 | + Handler: chart.GetChartHandler(serverCtx), | ||
| 76 | + }, | ||
| 76 | }, | 77 | }, |
| 77 | rest.WithPrefix("/v1"), | 78 | rest.WithPrefix("/v1"), |
| 78 | ) | 79 | ) |
| @@ -113,11 +114,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -113,11 +114,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 113 | server.AddRoutes( | 114 | server.AddRoutes( |
| 114 | []rest.Route{ | 115 | []rest.Route{ |
| 115 | { | 116 | { |
| 116 | - Method: http.MethodGet, | ||
| 117 | - Path: "/app-page/:id", | ||
| 118 | - Handler: page.GetAppPageHandler(serverCtx), | ||
| 119 | - }, | ||
| 120 | - { | ||
| 121 | Method: http.MethodPost, | 117 | Method: http.MethodPost, |
| 122 | Path: "/app-page", | 118 | Path: "/app-page", |
| 123 | Handler: page.SaveAppPageHandler(serverCtx), | 119 | Handler: page.SaveAppPageHandler(serverCtx), |
| @@ -156,6 +152,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -156,6 +152,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 156 | []rest.Route{ | 152 | []rest.Route{ |
| 157 | { | 153 | { |
| 158 | Method: http.MethodGet, | 154 | Method: http.MethodGet, |
| 155 | + Path: "/app-page/:id", | ||
| 156 | + Handler: page.GetAppPageHandler(serverCtx), | ||
| 157 | + }, | ||
| 158 | + { | ||
| 159 | + Method: http.MethodGet, | ||
| 159 | Path: "/api/app-page/get-share-detail/:key", | 160 | Path: "/api/app-page/get-share-detail/:key", |
| 160 | Handler: page.GetAppPageShareDetailHandler(serverCtx), | 161 | Handler: page.GetAppPageShareDetailHandler(serverCtx), |
| 161 | }, | 162 | }, |
| @@ -173,4 +174,14 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -173,4 +174,14 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 173 | }, | 174 | }, |
| 174 | rest.WithPrefix("/v1"), | 175 | rest.WithPrefix("/v1"), |
| 175 | ) | 176 | ) |
| 177 | + | ||
| 178 | + server.AddRoutes( | ||
| 179 | + []rest.Route{ | ||
| 180 | + { | ||
| 181 | + Method: http.MethodGet, | ||
| 182 | + Path: "/public/:filename", | ||
| 183 | + Handler: public.GetFileHandler(serverCtx), | ||
| 184 | + }, | ||
| 185 | + }, | ||
| 186 | + ) | ||
| 176 | } | 187 | } |
| @@ -2,6 +2,7 @@ package chart | @@ -2,6 +2,7 @@ package chart | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "fmt" | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" |
| 6 | "strings" | 7 | "strings" |
| 7 | 8 | ||
| @@ -26,26 +27,29 @@ func NewSearchChartComponentsLogic(ctx context.Context, svcCtx *svc.ServiceConte | @@ -26,26 +27,29 @@ func NewSearchChartComponentsLogic(ctx context.Context, svcCtx *svc.ServiceConte | ||
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | func (l *SearchChartComponentsLogic) SearchChartComponents(req *types.ChartComponentSearchRequest) (resp *types.ChartComponentSearchResponse, err error) { | 29 | func (l *SearchChartComponentsLogic) SearchChartComponents(req *types.ChartComponentSearchRequest) (resp *types.ChartComponentSearchResponse, err error) { |
| 30 | + pathMaker := func(filename string) string { | ||
| 31 | + return fmt.Sprintf("%s/%s/%s", l.svcCtx.Config.HostName, "public", filename) | ||
| 32 | + } | ||
| 29 | var list = []types.ChartComponentItem{ | 33 | var list = []types.ChartComponentItem{ |
| 30 | { | 34 | { |
| 31 | Name: "记录型表格", | 35 | Name: "记录型表格", |
| 32 | Code: domain.RecordTable1, | 36 | Code: domain.RecordTable1, |
| 33 | - Cover: "", | 37 | + Cover: pathMaker("RecordTable-1.png"), |
| 34 | }, | 38 | }, |
| 35 | { | 39 | { |
| 36 | Name: "总体指标", | 40 | Name: "总体指标", |
| 37 | Code: domain.MetricsCard1, | 41 | Code: domain.MetricsCard1, |
| 38 | - Cover: "", | 42 | + Cover: pathMaker("MetricsCard-1.png"), |
| 39 | }, | 43 | }, |
| 40 | { | 44 | { |
| 41 | Name: "容器卡片", | 45 | Name: "容器卡片", |
| 42 | Code: domain.ContainerCard1, | 46 | Code: domain.ContainerCard1, |
| 43 | - Cover: "", | 47 | + Cover: pathMaker("ContainerCard-1.png"), |
| 44 | }, | 48 | }, |
| 45 | { | 49 | { |
| 46 | Name: "四分图", | 50 | Name: "四分图", |
| 47 | Code: domain.QuarterChart1, | 51 | Code: domain.QuarterChart1, |
| 48 | - Cover: "", | 52 | + Cover: pathMaker("QuarterChart-1.png"), |
| 49 | }, | 53 | }, |
| 50 | } | 54 | } |
| 51 | var result = make([]types.ChartComponentItem, 0) | 55 | var result = make([]types.ChartComponentItem, 0) |
| 1 | +package public | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type GetFileLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewGetFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFileLogic { | ||
| 19 | + return &GetFileLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *GetFileLogic) GetFile(req *types.PublicGetFileRequest) error { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return nil | ||
| 30 | +} |
| @@ -143,6 +143,7 @@ type Title struct { | @@ -143,6 +143,7 @@ type Title struct { | ||
| 143 | SubTitle string `json:"subTitle,optional"` // 副标题 | 143 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 144 | ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file | 144 | ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file |
| 145 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 145 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 146 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 146 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 147 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 147 | Align string `json:"align,optional"` // 文本对齐方式 left center right | 148 | Align string `json:"align,optional"` // 文本对齐方式 left center right |
| 148 | } | 149 | } |
| @@ -311,3 +312,7 @@ type LogGetRequest struct { | @@ -311,3 +312,7 @@ type LogGetRequest struct { | ||
| 311 | 312 | ||
| 312 | type LogGetResponse struct { | 313 | type LogGetResponse struct { |
| 313 | } | 314 | } |
| 315 | + | ||
| 316 | +type PublicGetFileRequest struct { | ||
| 317 | + FileName string `path:"filename"` | ||
| 318 | +} |
97.3 KB
3.8 KB
49.8 KB
23.1 KB
| @@ -53,6 +53,7 @@ type Title struct { | @@ -53,6 +53,7 @@ type Title struct { | ||
| 53 | SubTitle string `json:"subTitle,optional"` // 副标题 | 53 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 54 | ExplainType string `json:"explainType,optional,options=[text,file]"` // text file | 54 | ExplainType string `json:"explainType,optional,options=[text,file]"` // text file |
| 55 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 55 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 56 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 56 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 57 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 57 | Align string `json:"align,optional"` // 文本对齐方式 left center right | 58 | Align string `json:"align,optional"` // 文本对齐方式 left center right |
| 58 | } | 59 | } |
| @@ -2,4 +2,5 @@ import "core/chart.api" | @@ -2,4 +2,5 @@ import "core/chart.api" | ||
| 2 | import "core/table.api" | 2 | import "core/table.api" |
| 3 | import "core/app_page.api" | 3 | import "core/app_page.api" |
| 4 | import "core/log.api" | 4 | import "core/log.api" |
| 5 | +import "core/public.api" | ||
| 5 | // import "./core/chart_stting.api" | 6 | // import "./core/chart_stting.api" |
| @@ -15,9 +15,6 @@ info( | @@ -15,9 +15,6 @@ info( | ||
| 15 | jwt: JwtAuth | 15 | jwt: JwtAuth |
| 16 | ) | 16 | ) |
| 17 | service Core { | 17 | service Core { |
| 18 | - @doc "获取应用页详情" | ||
| 19 | - @handler getAppPage | ||
| 20 | - get /app-page/:id (AppPageGetRequest) returns (AppPageGetResponse) | ||
| 21 | @doc "保存应用页" | 18 | @doc "保存应用页" |
| 22 | @handler saveAppPage | 19 | @handler saveAppPage |
| 23 | post /app-page (AppPageSaveRequest) returns (AppPageSaveResponse) | 20 | post /app-page (AppPageSaveRequest) returns (AppPageSaveResponse) |
| @@ -112,6 +109,10 @@ type ( | @@ -112,6 +109,10 @@ type ( | ||
| 112 | group: page | 109 | group: page |
| 113 | ) | 110 | ) |
| 114 | service Core { | 111 | service Core { |
| 112 | + @doc "获取应用页详情" | ||
| 113 | + @handler getAppPage | ||
| 114 | + get /app-page/:id (AppPageGetRequest) returns (AppPageGetResponse) | ||
| 115 | + | ||
| 115 | @doc "开放接口-获取应用页详情通过KEY" | 116 | @doc "开放接口-获取应用页详情通过KEY" |
| 116 | @handler getAppPageShareDetail | 117 | @handler getAppPageShareDetail |
| 117 | get /api/app-page/get-share-detail/:key (GetAppPageShareDetailRequest) returns (GetAppPageShareDetailResponse) | 118 | get /api/app-page/get-share-detail/:key (GetAppPageShareDetailRequest) returns (GetAppPageShareDetailResponse) |
| @@ -16,9 +16,6 @@ info( | @@ -16,9 +16,6 @@ info( | ||
| 16 | //middleware: Authority | 16 | //middleware: Authority |
| 17 | ) | 17 | ) |
| 18 | service Core { | 18 | service Core { |
| 19 | - @doc "获取图表详情" | ||
| 20 | - @handler getChart | ||
| 21 | - get /chart/:id (ChartGetRequest) returns (ChartGetResponse) | ||
| 22 | @doc "保存图表" | 19 | @doc "保存图表" |
| 23 | @handler saveChart | 20 | @handler saveChart |
| 24 | post /chart (ChartSaveRequest) returns (ChartSaveResponse) | 21 | post /chart (ChartSaveRequest) returns (ChartSaveResponse) |
| @@ -49,13 +46,14 @@ service Core { | @@ -49,13 +46,14 @@ service Core { | ||
| 49 | @server( | 46 | @server( |
| 50 | prefix: v1 | 47 | prefix: v1 |
| 51 | group: chart | 48 | group: chart |
| 52 | - //jwt: JwtAuth | ||
| 53 | - //middleware: Authority | ||
| 54 | ) | 49 | ) |
| 55 | service Core { | 50 | service Core { |
| 56 | @doc "加载图表数据" | 51 | @doc "加载图表数据" |
| 57 | @handler loadChartData | 52 | @handler loadChartData |
| 58 | post /chart/load-data (LoadChartDataRequest) returns (LoadChartDataResponse) | 53 | post /chart/load-data (LoadChartDataRequest) returns (LoadChartDataResponse) |
| 54 | + @doc "获取图表详情" | ||
| 55 | + @handler getChart | ||
| 56 | + get /chart/:id (ChartGetRequest) returns (ChartGetResponse) | ||
| 59 | } | 57 | } |
| 60 | 58 | ||
| 61 | type ( | 59 | type ( |
| @@ -156,7 +154,6 @@ type( | @@ -156,7 +154,6 @@ type( | ||
| 156 | Title Title `json:"title,optional"` // 标题 | 154 | Title Title `json:"title,optional"` // 标题 |
| 157 | TableAbility TableAbility `json:"table,optional"` // 表筛选功能 | 155 | TableAbility TableAbility `json:"table,optional"` // 表筛选功能 |
| 158 | Series []Series `json:"series,optional"` // 系列(数据源) | 156 | Series []Series `json:"series,optional"` // 系列(数据源) |
| 159 | - //Cover string `json:"cover,optional"` // 封面 | ||
| 160 | Other Other `json:"other,optional"` // 其他额外配置 | 157 | Other Other `json:"other,optional"` // 其他额外配置 |
| 161 | } | 158 | } |
| 162 | Other struct { | 159 | Other struct { |
| @@ -184,6 +181,7 @@ type( | @@ -184,6 +181,7 @@ type( | ||
| 184 | SubTitle string `json:"subTitle,optional"` // 副标题 | 181 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 185 | ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file | 182 | ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file |
| 186 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 183 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 184 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 187 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 185 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 188 | Align string `json:"align,optional"` // 文本对齐方式 left center right | 186 | Align string `json:"align,optional"` // 文本对齐方式 left center right |
| 189 | } | 187 | } |
doc/dsl/api/core/public.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "天联字库图表模板" | ||
| 5 | + desc: "图表模板" | ||
| 6 | + author: "小火箭" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +@server( | ||
| 12 | + group: public | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +service Core { | ||
| 16 | + | ||
| 17 | + @doc "获取文件" | ||
| 18 | + @handler getFile | ||
| 19 | + get /public/:filename (PublicGetFileRequest) | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +type( | ||
| 23 | + PublicGetFileRequest struct{ | ||
| 24 | + FileName string `path:"filename"` | ||
| 25 | + } | ||
| 26 | +) |
-
请 注册 或 登录 后发表评论