正在显示
50 个修改的文件
包含
768 行增加
和
87 行删除
| @@ -19,7 +19,7 @@ FROM alpine:latest | @@ -19,7 +19,7 @@ FROM alpine:latest | ||
| 19 | # Define the project name | 定义项目名称 | 19 | # Define the project name | 定义项目名称 |
| 20 | ARG PROJECT=core | 20 | ARG PROJECT=core |
| 21 | # Define the config file name | 定义配置文件名 | 21 | # Define the config file name | 定义配置文件名 |
| 22 | -ARG CONFIG_FILE=core.yaml | 22 | +ARG CONFIG_FILE=core-dev.yaml |
| 23 | # Define the author | 定义作者 | 23 | # Define the author | 定义作者 |
| 24 | ARG AUTHOR=785409885@qq.com | 24 | ARG AUTHOR=785409885@qq.com |
| 25 | 25 | ||
| @@ -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} |
DockerfilePrd
0 → 100644
| 1 | +FROM golang:1.19-alpine as builder | ||
| 2 | + | ||
| 3 | +# Define the project name | 定义项目名称 | ||
| 4 | +ARG PROJECT=core | ||
| 5 | + | ||
| 6 | +WORKDIR /build | ||
| 7 | +COPY . . | ||
| 8 | + | ||
| 9 | +RUN go env -w GO111MODULE=on \ | ||
| 10 | + && go env -w GOPROXY=https://goproxy.cn,direct \ | ||
| 11 | + && go env -w CGO_ENABLED=0 \ | ||
| 12 | + && go env \ | ||
| 13 | + && go mod tidy \ | ||
| 14 | + && cd cmd/chart-server/api \ | ||
| 15 | + && go build -ldflags="-s -w" -o /build/api/${PROJECT} ${PROJECT}.go | ||
| 16 | + | ||
| 17 | +FROM alpine:latest | ||
| 18 | + | ||
| 19 | +# Define the project name | 定义项目名称 | ||
| 20 | +ARG PROJECT=core | ||
| 21 | +# Define the config file name | 定义配置文件名 | ||
| 22 | +ARG CONFIG_FILE=core-prod.yaml | ||
| 23 | +# Define the author | 定义作者 | ||
| 24 | +ARG AUTHOR=785409885@qq.com | ||
| 25 | + | ||
| 26 | +LABEL org.opencontainers.image.authors=${AUTHOR} | ||
| 27 | + | ||
| 28 | +WORKDIR /app | ||
| 29 | +ENV PROJECT=${PROJECT} | ||
| 30 | +ENV CONFIG_FILE=${CONFIG_FILE} | ||
| 31 | + | ||
| 32 | +COPY --from=builder /build/api/${PROJECT} ./ | ||
| 33 | +COPY --from=builder /build/cmd/chart-server/api/etc/${CONFIG_FILE} ./etc/ | ||
| 34 | +COPY --from=builder /build/cmd/chart-server/api/public ./public/ | ||
| 35 | + | ||
| 36 | +EXPOSE 8080 | ||
| 37 | +ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} |
| @@ -2,7 +2,7 @@ package main | @@ -2,7 +2,7 @@ package main | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "flag" | 4 | "flag" |
| 5 | - "fmt" | 5 | + "github.com/zeromicro/go-zero/core/logx" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" |
| 8 | "net/http" | 8 | "net/http" |
| @@ -57,6 +57,6 @@ func main() { | @@ -57,6 +57,6 @@ func main() { | ||
| 57 | 57 | ||
| 58 | db.Migrate(ctx.DB) | 58 | db.Migrate(ctx.DB) |
| 59 | 59 | ||
| 60 | - fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) | 60 | + logx.Infof("Starting server at %s:%d... \n", c.Host, c.Port) |
| 61 | server.Start() | 61 | server.Start() |
| 62 | } | 62 | } |
cmd/chart-server/api/etc/core-dev.yaml
0 → 100644
| 1 | +Name: chart | ||
| 2 | +Host: 0.0.0.0 | ||
| 3 | +Port: 8080 | ||
| 4 | +Verbose: true | ||
| 5 | +HostName: http://sumifcc-bchart-dev.sumifcc.com | ||
| 6 | + | ||
| 7 | +Log: | ||
| 8 | + Mode: file | ||
| 9 | + Encoding: plain | ||
| 10 | + Level: debug # info | ||
| 11 | + | ||
| 12 | +JwtAuth: | ||
| 13 | + AccessSecret: digital-platform | ||
| 14 | + Expire: 360000 | ||
| 15 | + | ||
| 16 | +Redis: | ||
| 17 | + Host: 192.168.0.243:6379 | ||
| 18 | + Type: node | ||
| 19 | + Pass: | ||
| 20 | +DB: | ||
| 21 | + DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-bchart-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai | ||
| 22 | + | ||
| 23 | +ByteMetadata: | ||
| 24 | + Name: ApiByteMetadata | ||
| 25 | + Host: http://character-library-metadata-bastion-test.fjmaimaimai.com | ||
| 26 | + Timeout: 0s |
cmd/chart-server/api/etc/core-prd.yaml
0 → 100644
| 1 | +Name: chart | ||
| 2 | +Host: 0.0.0.0 | ||
| 3 | +Port: 8080 | ||
| 4 | +Verbose: false | ||
| 5 | +HostName: http://sumifcc-bchart.sumifcc.com | ||
| 6 | + | ||
| 7 | +Log: | ||
| 8 | + Mode: file | ||
| 9 | + Encoding: plain | ||
| 10 | + Level: info | ||
| 11 | + | ||
| 12 | +JwtAuth: | ||
| 13 | + AccessSecret: digital-platform | ||
| 14 | + Expire: 360000 | ||
| 15 | + | ||
| 16 | +Redis: | ||
| 17 | + Host: 192.168.0.243:6379 | ||
| 18 | + Type: node | ||
| 19 | + Pass: | ||
| 20 | +DB: | ||
| 21 | + DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-bchart-prd port=31543 sslmode=disable TimeZone=Asia/Shanghai | ||
| 22 | + | ||
| 23 | +ByteMetadata: | ||
| 24 | + Name: ApiByteMetadata | ||
| 25 | + Host: https://character-library-metadata-bastion.sumifcc.com | ||
| 26 | + Timeout: 0s |
| 1 | Name: chart | 1 | Name: chart |
| 2 | Host: 0.0.0.0 | 2 | Host: 0.0.0.0 |
| 3 | -Port: 8080 | 3 | +Port: 8081 |
| 4 | Verbose: true | 4 | Verbose: true |
| 5 | +HostName: http://sumifcc-bchart-dev.sumifcc.com | ||
| 6 | + | ||
| 7 | +Log: | ||
| 8 | + #Mode: file | ||
| 9 | + Encoding: plain | ||
| 10 | + Level: debug # info | ||
| 11 | + MaxSize: 1 # 2MB | ||
| 12 | + TimeFormat: 2006-01-02 15:04:05.000 | ||
| 5 | 13 | ||
| 6 | JwtAuth: | 14 | JwtAuth: |
| 7 | AccessSecret: digital-platform | 15 | AccessSecret: digital-platform |
| @@ -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 log | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + "path/filepath" | ||
| 6 | + "strings" | ||
| 7 | + | ||
| 8 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func GetLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.LogGetRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + path := svcCtx.Config.Log.Path | ||
| 21 | + if svcCtx.Config.Log.Mode != "file" { | ||
| 22 | + return | ||
| 23 | + } | ||
| 24 | + if path == "" { | ||
| 25 | + path = "logs" | ||
| 26 | + } | ||
| 27 | + if !strings.HasSuffix(req.Module, ".log") { | ||
| 28 | + req.Module += ".log" | ||
| 29 | + } | ||
| 30 | + handler := http.FileServer(http.Dir(path)) | ||
| 31 | + r.URL.Path = filepath.Join(req.Module) | ||
| 32 | + handler.ServeHTTP(w, r) | ||
| 33 | + } | ||
| 34 | +} |
| 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 | +} |
| @@ -5,7 +5,9 @@ import ( | @@ -5,7 +5,9 @@ import ( | ||
| 5 | "net/http" | 5 | "net/http" |
| 6 | 6 | ||
| 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 | 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" | ||
| 9 | 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" |
| 10 | "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" |
| 11 | 13 | ||
| @@ -16,11 +18,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -16,11 +18,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 16 | server.AddRoutes( | 18 | server.AddRoutes( |
| 17 | []rest.Route{ | 19 | []rest.Route{ |
| 18 | { | 20 | { |
| 19 | - Method: http.MethodGet, | ||
| 20 | - Path: "/chart/:id", | ||
| 21 | - Handler: chart.GetChartHandler(serverCtx), | ||
| 22 | - }, | ||
| 23 | - { | ||
| 24 | Method: http.MethodPost, | 21 | Method: http.MethodPost, |
| 25 | Path: "/chart", | 22 | Path: "/chart", |
| 26 | Handler: chart.SaveChartHandler(serverCtx), | 23 | Handler: chart.SaveChartHandler(serverCtx), |
| @@ -72,6 +69,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -72,6 +69,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 72 | Path: "/chart/load-data", | 69 | Path: "/chart/load-data", |
| 73 | Handler: chart.LoadChartDataHandler(serverCtx), | 70 | Handler: chart.LoadChartDataHandler(serverCtx), |
| 74 | }, | 71 | }, |
| 72 | + { | ||
| 73 | + Method: http.MethodGet, | ||
| 74 | + Path: "/chart/:id", | ||
| 75 | + Handler: chart.GetChartHandler(serverCtx), | ||
| 76 | + }, | ||
| 75 | }, | 77 | }, |
| 76 | rest.WithPrefix("/v1"), | 78 | rest.WithPrefix("/v1"), |
| 77 | ) | 79 | ) |
| @@ -112,11 +114,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -112,11 +114,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 112 | server.AddRoutes( | 114 | server.AddRoutes( |
| 113 | []rest.Route{ | 115 | []rest.Route{ |
| 114 | { | 116 | { |
| 115 | - Method: http.MethodGet, | ||
| 116 | - Path: "/app-page/:id", | ||
| 117 | - Handler: page.GetAppPageHandler(serverCtx), | ||
| 118 | - }, | ||
| 119 | - { | ||
| 120 | Method: http.MethodPost, | 117 | Method: http.MethodPost, |
| 121 | Path: "/app-page", | 118 | Path: "/app-page", |
| 122 | Handler: page.SaveAppPageHandler(serverCtx), | 119 | Handler: page.SaveAppPageHandler(serverCtx), |
| @@ -155,10 +152,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -155,10 +152,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 155 | []rest.Route{ | 152 | []rest.Route{ |
| 156 | { | 153 | { |
| 157 | Method: http.MethodGet, | 154 | Method: http.MethodGet, |
| 155 | + Path: "/app-page/:id", | ||
| 156 | + Handler: page.GetAppPageHandler(serverCtx), | ||
| 157 | + }, | ||
| 158 | + { | ||
| 159 | + Method: http.MethodGet, | ||
| 158 | Path: "/api/app-page/get-share-detail/:key", | 160 | Path: "/api/app-page/get-share-detail/:key", |
| 159 | Handler: page.GetAppPageShareDetailHandler(serverCtx), | 161 | Handler: page.GetAppPageShareDetailHandler(serverCtx), |
| 160 | }, | 162 | }, |
| 161 | }, | 163 | }, |
| 162 | rest.WithPrefix("/v1"), | 164 | rest.WithPrefix("/v1"), |
| 163 | ) | 165 | ) |
| 166 | + | ||
| 167 | + server.AddRoutes( | ||
| 168 | + []rest.Route{ | ||
| 169 | + { | ||
| 170 | + Method: http.MethodGet, | ||
| 171 | + Path: "/log/:module", | ||
| 172 | + Handler: log.GetLogHandler(serverCtx), | ||
| 173 | + }, | ||
| 174 | + }, | ||
| 175 | + rest.WithPrefix("/v1"), | ||
| 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 | + ) | ||
| 164 | } | 187 | } |
| @@ -30,7 +30,7 @@ func NewSaveChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveCha | @@ -30,7 +30,7 @@ func NewSaveChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveCha | ||
| 30 | 30 | ||
| 31 | func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.ChartSaveResponse, err error) { | 31 | func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.ChartSaveResponse, err error) { |
| 32 | var ( | 32 | var ( |
| 33 | - //conn = l.svcCtx.DefaultDBConn() | 33 | + conn = l.svcCtx.DefaultDBConn() |
| 34 | //parentChart *domain.Chart | 34 | //parentChart *domain.Chart |
| 35 | chart *domain.Chart | 35 | chart *domain.Chart |
| 36 | chartSetting *domain.ChartSetting | 36 | chartSetting *domain.ChartSetting |
| @@ -62,6 +62,9 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha | @@ -62,6 +62,9 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha | ||
| 62 | //if currentSortChart, _ := l.svcCtx.ChartRepository.FindOneByGroup(l.ctx, conn, tenantId, req.Pid); currentSortChart != nil { | 62 | //if currentSortChart, _ := l.svcCtx.ChartRepository.FindOneByGroup(l.ctx, conn, tenantId, req.Pid); currentSortChart != nil { |
| 63 | // chart.Sort = currentSortChart.Sort + 1 | 63 | // chart.Sort = currentSortChart.Sort + 1 |
| 64 | //} | 64 | //} |
| 65 | + if total, _, _ := l.svcCtx.ChartRepository.FindByTypeAndName(l.ctx, conn, tenantId, req.Type, req.Name); total > 0 { | ||
| 66 | + return nil, xerr.NewErrMsgErr("图表名字重复", nil) | ||
| 67 | + } | ||
| 65 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | 68 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { |
| 66 | if chart, err = l.svcCtx.ChartRepository.Insert(ctx, conn, chart); err != nil { | 69 | if chart, err = l.svcCtx.ChartRepository.Insert(ctx, conn, chart); err != nil { |
| 67 | return err | 70 | return err |
| @@ -76,6 +79,7 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha | @@ -76,6 +79,7 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha | ||
| 76 | Title: chartProperty.Title, | 79 | Title: chartProperty.Title, |
| 77 | TableAbility: chartProperty.TableAbility, | 80 | TableAbility: chartProperty.TableAbility, |
| 78 | Series: chartProperty.Series, | 81 | Series: chartProperty.Series, |
| 82 | + Other: chartProperty.Other, | ||
| 79 | TenantId: chart.TenantId, | 83 | TenantId: chart.TenantId, |
| 80 | } | 84 | } |
| 81 | if chartSetting, err = l.svcCtx.ChartSettingRepository.Insert(l.ctx, conn, chartSetting); err != nil { | 85 | if chartSetting, err = l.svcCtx.ChartSettingRepository.Insert(l.ctx, conn, chartSetting); err != nil { |
| @@ -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 log | ||
| 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 GetLogLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewGetLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLogLogic { | ||
| 19 | + return &GetLogLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *GetLogLogic) GetLog(req *types.LogGetRequest) (resp *types.LogGetResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| @@ -2,6 +2,7 @@ package page | @@ -2,6 +2,7 @@ package page | ||
| 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/db/transaction" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/tool" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/tool" |
| @@ -41,9 +42,12 @@ func (l *CreateAppPageShareUrlLogic) CreateAppPageShareUrl(req *types.AppPageCre | @@ -41,9 +42,12 @@ func (l *CreateAppPageShareUrlLogic) CreateAppPageShareUrl(req *types.AppPageCre | ||
| 41 | if appPage.Key != "" { | 42 | if appPage.Key != "" { |
| 42 | return | 43 | return |
| 43 | } | 44 | } |
| 44 | - | 45 | + key := tool.Krand(18, tool.KC_RAND_KIND_ALL) |
| 46 | + if found, _ := l.svcCtx.AppPageRepository.FindOneByKey(l.ctx, conn, key); found != nil { | ||
| 47 | + return nil, xerr.NewErrMsgErr("创建页面分享链接失败", fmt.Errorf("重复key")) | ||
| 48 | + } | ||
| 45 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | 49 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { |
| 46 | - appPage.Key = tool.Krand(18, tool.KC_RAND_KIND_ALL) | 50 | + appPage.Key = key |
| 47 | if appPage, err = l.svcCtx.AppPageRepository.UpdateWithVersion(l.ctx, conn, appPage); err != nil { | 51 | if appPage, err = l.svcCtx.AppPageRepository.UpdateWithVersion(l.ctx, conn, appPage); err != nil { |
| 48 | return err | 52 | return err |
| 49 | } | 53 | } |
| @@ -29,7 +29,7 @@ func NewSaveAppPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveA | @@ -29,7 +29,7 @@ func NewSaveAppPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveA | ||
| 29 | 29 | ||
| 30 | func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *types.AppPageSaveResponse, err error) { | 30 | func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *types.AppPageSaveResponse, err error) { |
| 31 | var ( | 31 | var ( |
| 32 | - //conn = l.svcCtx.DefaultDBConn() | 32 | + conn = l.svcCtx.DefaultDBConn() |
| 33 | appPage *domain.AppPage | 33 | appPage *domain.AppPage |
| 34 | tenantId = contextdata.GetTenantFromCtx(l.ctx) | 34 | tenantId = contextdata.GetTenantFromCtx(l.ctx) |
| 35 | ) | 35 | ) |
| @@ -37,6 +37,10 @@ func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *typ | @@ -37,6 +37,10 @@ func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *typ | ||
| 37 | Name: req.Name, | 37 | Name: req.Name, |
| 38 | Charts: req.Charts, | 38 | Charts: req.Charts, |
| 39 | TenantId: tenantId, | 39 | TenantId: tenantId, |
| 40 | + Cover: req.Cover, | ||
| 41 | + } | ||
| 42 | + if total, _, _ := l.svcCtx.AppPageRepository.FindByName(l.ctx, conn, tenantId, req.Name); total > 0 { | ||
| 43 | + return nil, xerr.NewErrMsgErr("页面名字重复", nil) | ||
| 40 | } | 44 | } |
| 41 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | 45 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { |
| 42 | if appPage, err = l.svcCtx.AppPageRepository.Insert(l.ctx, conn, appPage); err != nil { | 46 | if appPage, err = l.svcCtx.AppPageRepository.Insert(l.ctx, conn, appPage); err != nil { |
| @@ -36,8 +36,13 @@ func (l *UpdateAppPageLogic) UpdateAppPage(req *types.AppPageUpdateRequest) (res | @@ -36,8 +36,13 @@ func (l *UpdateAppPageLogic) UpdateAppPage(req *types.AppPageUpdateRequest) (res | ||
| 36 | } | 36 | } |
| 37 | resp = &types.AppPageUpdateResponse{} | 37 | resp = &types.AppPageUpdateResponse{} |
| 38 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | 38 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { |
| 39 | - appPage.Name = req.Name | ||
| 40 | appPage.Charts = req.Charts | 39 | appPage.Charts = req.Charts |
| 40 | + if req.Cover != "" { | ||
| 41 | + appPage.Cover = req.Cover | ||
| 42 | + } | ||
| 43 | + if req.Name != "" { | ||
| 44 | + appPage.Name = req.Name | ||
| 45 | + } | ||
| 41 | if appPage, err = l.svcCtx.AppPageRepository.UpdateWithVersion(l.ctx, conn, appPage); err != nil { | 46 | if appPage, err = l.svcCtx.AppPageRepository.UpdateWithVersion(l.ctx, conn, appPage); err != nil { |
| 42 | return err | 47 | return err |
| 43 | } | 48 | } |
| 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 | +} |
| @@ -55,6 +55,7 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM | @@ -55,6 +55,7 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM | ||
| 55 | TableTypes: []string{bytelib.CalculateItem, bytelib.CalculateSet}, | 55 | TableTypes: []string{bytelib.CalculateItem, bytelib.CalculateSet}, |
| 56 | Module: bytelib.ModuleCalculateCenter, | 56 | Module: bytelib.ModuleCalculateCenter, |
| 57 | ReturnGroupItem: true, | 57 | ReturnGroupItem: true, |
| 58 | + ExcludeTables: []int{0}, | ||
| 58 | }) | 59 | }) |
| 59 | if err != nil { | 60 | if err != nil { |
| 60 | batchError.Add(err) | 61 | batchError.Add(err) |
| @@ -26,6 +26,15 @@ func NewSearchTableDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *S | @@ -26,6 +26,15 @@ func NewSearchTableDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *S | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest) (resp interface{}, err error) { | 28 | func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest) (resp interface{}, err error) { |
| 29 | + if req.ObjectId == 0 { | ||
| 30 | + resp = map[string]interface{}{ | ||
| 31 | + "objectId": 0, | ||
| 32 | + "fields": nil, | ||
| 33 | + "total": 0, | ||
| 34 | + "data": make([]string, 0), | ||
| 35 | + } | ||
| 36 | + return | ||
| 37 | + } | ||
| 29 | tableDataPreviewRequest := &bytelib.TableDataPreviewRequest{ | 38 | tableDataPreviewRequest := &bytelib.TableDataPreviewRequest{ |
| 30 | Token: req.Token, | 39 | Token: req.Token, |
| 31 | ObjectType: bytelib.ObjectMetaTable, | 40 | ObjectType: bytelib.ObjectMetaTable, |
| @@ -54,17 +54,17 @@ func (l *SearchTableFieldOptionalValuesLogic) SearchTableFieldOptionalValues(req | @@ -54,17 +54,17 @@ func (l *SearchTableFieldOptionalValuesLogic) SearchTableFieldOptionalValues(req | ||
| 54 | func newWhere(conditions []*types.Condition) *bytelib.TableQueryWhere { | 54 | func newWhere(conditions []*types.Condition) *bytelib.TableQueryWhere { |
| 55 | where := &bytelib.TableQueryWhere{} | 55 | where := &bytelib.TableQueryWhere{} |
| 56 | for _, c := range conditions { | 56 | for _, c := range conditions { |
| 57 | - order := c.Order | ||
| 58 | - if order == "" { | ||
| 59 | - order = "ASC" | ||
| 60 | - } | 57 | + //order := c.Order |
| 58 | + //if order == "" { | ||
| 59 | + // order = "ASC" | ||
| 60 | + //} | ||
| 61 | where.Conditions = append(where.Conditions, &bytelib.TableQueryCondition{ | 61 | where.Conditions = append(where.Conditions, &bytelib.TableQueryCondition{ |
| 62 | Field: &bytelib.Field{ | 62 | Field: &bytelib.Field{ |
| 63 | Name: c.FieldName, | 63 | Name: c.FieldName, |
| 64 | }, | 64 | }, |
| 65 | - Like: c.Like, | ||
| 66 | - In: c.In, | ||
| 67 | - Order: order, | 65 | + Like: c.Like, |
| 66 | + In: c.In, | ||
| 67 | + //Order: order, | ||
| 68 | }) | 68 | }) |
| 69 | } | 69 | } |
| 70 | return where | 70 | return where |
| @@ -27,7 +27,7 @@ type ServiceContext struct { | @@ -27,7 +27,7 @@ type ServiceContext struct { | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | func NewServiceContext(c config.Config) *ServiceContext { | 29 | func NewServiceContext(c config.Config) *ServiceContext { |
| 30 | - db := database.OpenGormPGDB(c.DB.DataSource) | 30 | + db := database.OpenGormPGDB(c.DB.DataSource, c.Log.Mode) |
| 31 | mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) | 31 | mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) |
| 32 | redisCache := gzcache.NewClusterCache([]string{c.Redis.Host}, c.Redis.Pass) | 32 | redisCache := gzcache.NewClusterCache([]string{c.Redis.Host}, c.Redis.Pass) |
| 33 | redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) | 33 | redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) |
| @@ -39,15 +39,17 @@ func NewAppPageItem(appPage *domain.AppPage, charts []*domain.Chart) AppPageItem | @@ -39,15 +39,17 @@ func NewAppPageItem(appPage *domain.AppPage, charts []*domain.Chart) AppPageItem | ||
| 39 | return item.Id, item | 39 | return item.Id, item |
| 40 | }) | 40 | }) |
| 41 | item := AppPageItem{ | 41 | item := AppPageItem{ |
| 42 | - Id: appPage.Id, | ||
| 43 | - Name: appPage.Name, | 42 | + Id: appPage.Id, |
| 43 | + Name: appPage.Name, | ||
| 44 | + Cover: appPage.Cover, | ||
| 44 | } | 45 | } |
| 45 | for _, id := range appPage.Charts { | 46 | for _, id := range appPage.Charts { |
| 46 | if v, ok := chartsMap[id]; ok { | 47 | if v, ok := chartsMap[id]; ok { |
| 47 | item.Charts = append(item.Charts, AppPageChartItem{ | 48 | item.Charts = append(item.Charts, AppPageChartItem{ |
| 48 | - ChartId: v.Id, | ||
| 49 | - Name: v.Name, | ||
| 50 | - Cover: v.Cover, | 49 | + ChartId: v.Id, |
| 50 | + Name: v.Name, | ||
| 51 | + Cover: v.Cover, | ||
| 52 | + ChartType: v.ChartType, | ||
| 51 | }) | 53 | }) |
| 52 | } | 54 | } |
| 53 | } | 55 | } |
| @@ -127,10 +127,12 @@ type Quarter struct { | @@ -127,10 +127,12 @@ type Quarter struct { | ||
| 127 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 | 127 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 |
| 128 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 | 128 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 |
| 129 | Area string `json:"area"` // 图形面积 | 129 | Area string `json:"area"` // 图形面积 |
| 130 | + AreaColor bool `json:"areaColor"` // 颜色 | ||
| 130 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 | 131 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | type QuarterSeries struct { | 134 | type QuarterSeries struct { |
| 135 | + SeriesValue string `json:"seriesValue"` | ||
| 134 | } | 136 | } |
| 135 | 137 | ||
| 136 | type Title struct { | 138 | type Title struct { |
| @@ -141,8 +143,11 @@ type Title struct { | @@ -141,8 +143,11 @@ type Title struct { | ||
| 141 | SubTitle string `json:"subTitle,optional"` // 副标题 | 143 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 142 | 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 |
| 143 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 145 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 146 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 144 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 147 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 145 | - Align string `json:"align,optional"` // 文本对齐方式 left center right | 148 | + Align string `json:"align,optional"` // 废弃 文本对齐方式 left center right |
| 149 | + HeadingAlign string `json:"headingAlign,optional"` // 主标题 文本对齐方式 left center right | ||
| 150 | + SubAlign string `json:"subAlign,optional"` // 副标题 文本对齐方式 left center right | ||
| 146 | } | 151 | } |
| 147 | 152 | ||
| 148 | type TableAbility struct { | 153 | type TableAbility struct { |
| @@ -208,7 +213,7 @@ type GetTableDetailResponse struct { | @@ -208,7 +213,7 @@ type GetTableDetailResponse struct { | ||
| 208 | 213 | ||
| 209 | type SearchTableDataRequest struct { | 214 | type SearchTableDataRequest struct { |
| 210 | Token string `header:"x-mmm-accesstoken,optional"` | 215 | Token string `header:"x-mmm-accesstoken,optional"` |
| 211 | - ObjectId int `json:"objectId"` // 对象ID | 216 | + ObjectId int `json:"objectId,optional"` // 对象ID |
| 212 | PageNumber int `json:"page,optional"` // 分页数 | 217 | PageNumber int `json:"page,optional"` // 分页数 |
| 213 | PageSize int `json:"size,optional"` // 页码 | 218 | PageSize int `json:"size,optional"` // 页码 |
| 214 | Condition []*Condition `json:"conditions,optional"` // 条件 | 219 | Condition []*Condition `json:"conditions,optional"` // 条件 |
| @@ -226,8 +231,9 @@ type AppPageGetResponse struct { | @@ -226,8 +231,9 @@ type AppPageGetResponse struct { | ||
| 226 | } | 231 | } |
| 227 | 232 | ||
| 228 | type AppPageSaveRequest struct { | 233 | type AppPageSaveRequest struct { |
| 229 | - Name string `json:"name"` // 名称 | ||
| 230 | - Charts []int64 `json:"charts"` // 图表 | 234 | + Name string `json:"name"` // 名称 |
| 235 | + Charts []int64 `json:"charts"` // 图表 | ||
| 236 | + Cover string `json:"cover,optional"` // 封面 | ||
| 231 | } | 237 | } |
| 232 | 238 | ||
| 233 | type AppPageSaveResponse struct { | 239 | type AppPageSaveResponse struct { |
| @@ -262,8 +268,9 @@ type AppPageDeleteResponse struct { | @@ -262,8 +268,9 @@ type AppPageDeleteResponse struct { | ||
| 262 | 268 | ||
| 263 | type AppPageUpdateRequest struct { | 269 | type AppPageUpdateRequest struct { |
| 264 | Id int64 `path:"id"` | 270 | Id int64 `path:"id"` |
| 265 | - Name string `json:"name"` // 名称 | ||
| 266 | - Charts []int64 `json:"charts"` // 图表 | 271 | + Name string `json:"name,optional"` // 名称 |
| 272 | + Charts []int64 `json:"charts"` // 图表 | ||
| 273 | + Cover string `json:"cover,optional"` // 封面 | ||
| 267 | } | 274 | } |
| 268 | 275 | ||
| 269 | type AppPageUpdateResponse struct { | 276 | type AppPageUpdateResponse struct { |
| @@ -282,13 +289,15 @@ type AppPageSearchResponse struct { | @@ -282,13 +289,15 @@ type AppPageSearchResponse struct { | ||
| 282 | type AppPageItem struct { | 289 | type AppPageItem struct { |
| 283 | Id int64 `json:"id,optional"` // 唯一标识 | 290 | Id int64 `json:"id,optional"` // 唯一标识 |
| 284 | Name string `json:"name,optional"` // 名称 | 291 | Name string `json:"name,optional"` // 名称 |
| 292 | + Cover string `json:"cover,optional"` // 封面 | ||
| 285 | Charts []AppPageChartItem `json:"charts,optional"` // 图表 | 293 | Charts []AppPageChartItem `json:"charts,optional"` // 图表 |
| 286 | } | 294 | } |
| 287 | 295 | ||
| 288 | type AppPageChartItem struct { | 296 | type AppPageChartItem struct { |
| 289 | - ChartId int64 `json:"chartId"` // 图表ID | ||
| 290 | - Name string `json:"name"` // 图表名称 | ||
| 291 | - Cover string `json:"cover"` // 图表封面 | 297 | + ChartId int64 `json:"chartId"` // 图表ID |
| 298 | + Name string `json:"name"` // 图表名称 | ||
| 299 | + Cover string `json:"cover"` // 图表封面 | ||
| 300 | + ChartType string `json:"chartType,optional"` // 图表类型 | ||
| 292 | } | 301 | } |
| 293 | 302 | ||
| 294 | type GetAppPageShareDetailRequest struct { | 303 | type GetAppPageShareDetailRequest struct { |
| @@ -298,3 +307,14 @@ type GetAppPageShareDetailRequest struct { | @@ -298,3 +307,14 @@ type GetAppPageShareDetailRequest struct { | ||
| 298 | type GetAppPageShareDetailResponse struct { | 307 | type GetAppPageShareDetailResponse struct { |
| 299 | AppPage AppPageItem `json:"page"` | 308 | AppPage AppPageItem `json:"page"` |
| 300 | } | 309 | } |
| 310 | + | ||
| 311 | +type LogGetRequest struct { | ||
| 312 | + Module string `path:"module"` | ||
| 313 | +} | ||
| 314 | + | ||
| 315 | +type LogGetResponse struct { | ||
| 316 | +} | ||
| 317 | + | ||
| 318 | +type PublicGetFileRequest struct { | ||
| 319 | + FileName string `path:"filename"` | ||
| 320 | +} |
97.3 KB
3.8 KB
49.8 KB
23.1 KB
| @@ -9,11 +9,11 @@ import ( | @@ -9,11 +9,11 @@ import ( | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | type AppPage struct { | 11 | type AppPage struct { |
| 12 | - Id int64 // 唯一标识 | ||
| 13 | - Name string // 名称 | ||
| 14 | - Charts []int64 `gorm:"serializer:json"` // 图表 | ||
| 15 | - Key string // 分享,预览时绑定映射到Id | ||
| 16 | - | 12 | + Id int64 // 唯一标识 |
| 13 | + Name string // 名称 | ||
| 14 | + Charts []int64 `gorm:"serializer:json"` // 图表 | ||
| 15 | + Key string // 分享,预览时绑定映射到Id | ||
| 16 | + Cover string // 封面 | ||
| 17 | TenantId int64 `gorm:"index:idx_app_page_t_id"` // 租户ID | 17 | TenantId int64 `gorm:"index:idx_app_page_t_id"` // 租户ID |
| 18 | CreatedAt int64 `json:",omitempty"` | 18 | CreatedAt int64 `json:",omitempty"` |
| 19 | UpdatedAt int64 `json:",omitempty"` | 19 | UpdatedAt int64 `json:",omitempty"` |
| @@ -195,6 +195,36 @@ func (repository *AppPageRepository) Find(ctx context.Context, conn transaction. | @@ -195,6 +195,36 @@ func (repository *AppPageRepository) Find(ctx context.Context, conn transaction. | ||
| 195 | return total, dms, nil | 195 | return total, dms, nil |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | +func (repository *AppPageRepository) FindByName(ctx context.Context, conn transaction.Conn, tenantId int64, name string) (int64, []*domain.AppPage, error) { | ||
| 199 | + var ( | ||
| 200 | + tx = conn.DB() | ||
| 201 | + ms []*models.AppPage | ||
| 202 | + dms = make([]*domain.AppPage, 0) | ||
| 203 | + ) | ||
| 204 | + queryFunc := func() (interface{}, error) { | ||
| 205 | + tx = tx.Model(&ms).Order("id desc") | ||
| 206 | + tx.Where("tenant_id = ?", tenantId) | ||
| 207 | + tx.Where("name = ?", name) | ||
| 208 | + if tx = tx.Find(&ms); tx.Error != nil { | ||
| 209 | + return dms, tx.Error | ||
| 210 | + } | ||
| 211 | + return dms, nil | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + if _, err := repository.Query(queryFunc); err != nil { | ||
| 215 | + return 0, nil, err | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + for _, item := range ms { | ||
| 219 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
| 220 | + return 0, dms, err | ||
| 221 | + } else { | ||
| 222 | + dms = append(dms, dm) | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + return int64(len(dms)), dms, nil | ||
| 226 | +} | ||
| 227 | + | ||
| 198 | func (repository *AppPageRepository) ModelToDomainModel(from *models.AppPage) (*domain.AppPage, error) { | 228 | func (repository *AppPageRepository) ModelToDomainModel(from *models.AppPage) (*domain.AppPage, error) { |
| 199 | to := &domain.AppPage{} | 229 | to := &domain.AppPage{} |
| 200 | err := copier.Copy(to, from) | 230 | err := copier.Copy(to, from) |
| @@ -149,6 +149,39 @@ func (repository *ChartRepository) Find(ctx context.Context, conn transaction.Co | @@ -149,6 +149,39 @@ func (repository *ChartRepository) Find(ctx context.Context, conn transaction.Co | ||
| 149 | return total, dms, nil | 149 | return total, dms, nil |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | +// FindByTypeAndName 按类型、名称搜索图表(判断重复的图表) | ||
| 153 | +func (repository *ChartRepository) FindByTypeAndName(ctx context.Context, conn transaction.Conn, tenantId int64, t string, name string) (int64, []*domain.Chart, error) { | ||
| 154 | + var ( | ||
| 155 | + tx = conn.DB() | ||
| 156 | + ms []*models.Chart | ||
| 157 | + dms = make([]*domain.Chart, 0) | ||
| 158 | + //total int64 | ||
| 159 | + ) | ||
| 160 | + queryFunc := func() (interface{}, error) { | ||
| 161 | + tx = tx.Model(&ms).Order("id desc") //.Order("pid asc").Order("sort asc") | ||
| 162 | + tx.Where("tenant_id = ?", tenantId) | ||
| 163 | + tx.Where("type = ?", t) | ||
| 164 | + tx.Where("name = ?", name) | ||
| 165 | + if tx = tx.Find(&ms); tx.Error != nil { | ||
| 166 | + return dms, tx.Error | ||
| 167 | + } | ||
| 168 | + return dms, nil | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + if _, err := repository.Query(queryFunc); err != nil { | ||
| 172 | + return 0, nil, err | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + for _, item := range ms { | ||
| 176 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
| 177 | + return 0, dms, err | ||
| 178 | + } else { | ||
| 179 | + dms = append(dms, dm) | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + return int64(len(dms)), dms, nil | ||
| 183 | +} | ||
| 184 | + | ||
| 152 | func (repository *ChartRepository) FindOneByGroup(ctx context.Context, conn transaction.Conn, tenantId, pid int64) (*domain.Chart, error) { | 185 | func (repository *ChartRepository) FindOneByGroup(ctx context.Context, conn transaction.Conn, tenantId, pid int64) (*domain.Chart, error) { |
| 153 | var ( | 186 | var ( |
| 154 | err error | 187 | err error |
| @@ -11,6 +11,7 @@ type AppPage struct { | @@ -11,6 +11,7 @@ type AppPage struct { | ||
| 11 | Charts []int64 // 图表 | 11 | Charts []int64 // 图表 |
| 12 | Key string // 分享,预览时绑定映射到Id | 12 | Key string // 分享,预览时绑定映射到Id |
| 13 | TenantId int64 // 租户ID | 13 | TenantId int64 // 租户ID |
| 14 | + Cover string // 封面 | ||
| 14 | CreatedAt int64 `json:",omitempty"` | 15 | CreatedAt int64 `json:",omitempty"` |
| 15 | UpdatedAt int64 `json:",omitempty"` | 16 | UpdatedAt int64 `json:",omitempty"` |
| 16 | DeletedAt int64 `json:",omitempty"` | 17 | DeletedAt int64 `json:",omitempty"` |
| @@ -26,6 +27,7 @@ type AppPageRepository interface { | @@ -26,6 +27,7 @@ type AppPageRepository interface { | ||
| 26 | FindOneByKey(ctx context.Context, conn transaction.Conn, key string) (*AppPage, error) | 27 | FindOneByKey(ctx context.Context, conn transaction.Conn, key string) (*AppPage, error) |
| 27 | FindOneByChartId(ctx context.Context, conn transaction.Conn, tenantId, chartId int64) (*AppPage, error) | 28 | FindOneByChartId(ctx context.Context, conn transaction.Conn, tenantId, chartId int64) (*AppPage, error) |
| 28 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*AppPage, error) | 29 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*AppPage, error) |
| 30 | + FindByName(ctx context.Context, conn transaction.Conn, tenantId int64, name string) (int64, []*AppPage, error) | ||
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | func (m *AppPage) Identify() interface{} { | 33 | func (m *AppPage) Identify() interface{} { |
| @@ -34,6 +34,7 @@ type ChartRepository interface { | @@ -34,6 +34,7 @@ type ChartRepository interface { | ||
| 34 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Chart, error) | 34 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Chart, error) |
| 35 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Chart, error) | 35 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Chart, error) |
| 36 | FindOneByGroup(ctx context.Context, conn transaction.Conn, tenantId, pid int64) (*Chart, error) | 36 | FindOneByGroup(ctx context.Context, conn transaction.Conn, tenantId, pid int64) (*Chart, error) |
| 37 | + FindByTypeAndName(ctx context.Context, conn transaction.Conn, tenantId int64, t string, name string) (int64, []*Chart, error) | ||
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | /*************** 索引函数 开始****************/ | 40 | /*************** 索引函数 开始****************/ |
| @@ -37,9 +37,12 @@ type Quarter struct { | @@ -37,9 +37,12 @@ type Quarter struct { | ||
| 37 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 | 37 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 |
| 38 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 | 38 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 |
| 39 | Area string `json:"area"` // 图形面积 | 39 | Area string `json:"area"` // 图形面积 |
| 40 | + AreaColor bool `json:"areaColor"` // 颜色 | ||
| 40 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 | 41 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 |
| 41 | } | 42 | } |
| 43 | + | ||
| 42 | type QuarterSeries struct { | 44 | type QuarterSeries struct { |
| 45 | + SeriesValue string `json:"seriesValue"` | ||
| 43 | } | 46 | } |
| 44 | 47 | ||
| 45 | type Title struct { | 48 | type Title struct { |
| @@ -50,8 +53,11 @@ type Title struct { | @@ -50,8 +53,11 @@ type Title struct { | ||
| 50 | SubTitle string `json:"subTitle,optional"` // 副标题 | 53 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 51 | ExplainType string `json:"explainType,optional,options=[text,file]"` // text file | 54 | ExplainType string `json:"explainType,optional,options=[text,file]"` // text file |
| 52 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 55 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 56 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 53 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 57 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 54 | - Align string `json:"align,optional"` // 文本对齐方式 left center right | 58 | + Align string `json:"align,optional"` // 废弃 文本对齐方式 left center right |
| 59 | + HeadingAlign string `json:"headingAlign,optional"` // 主标题 文本对齐方式 left center right | ||
| 60 | + SubAlign string `json:"subAlign,optional"` // 副标题 文本对齐方式 left center right | ||
| 55 | } | 61 | } |
| 56 | 62 | ||
| 57 | type TableAbility struct { | 63 | type TableAbility struct { |
| @@ -70,6 +70,14 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | @@ -70,6 +70,14 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | ||
| 70 | if err = json.Unmarshal(body, &baseResponse); err != nil { | 70 | if err = json.Unmarshal(body, &baseResponse); err != nil { |
| 71 | return err | 71 | return err |
| 72 | } | 72 | } |
| 73 | + if baseResponse.Code != 0 { | ||
| 74 | + return HttpError{ | ||
| 75 | + Base: Response{ | ||
| 76 | + Code: baseResponse.Code, | ||
| 77 | + Msg: baseResponse.Msg, | ||
| 78 | + }, | ||
| 79 | + } | ||
| 80 | + } | ||
| 73 | if err = mapping.UnmarshalJsonBytes(baseResponse.Data, result); err != nil { | 81 | if err = mapping.UnmarshalJsonBytes(baseResponse.Data, result); err != nil { |
| 74 | return err | 82 | return err |
| 75 | } | 83 | } |
| @@ -40,7 +40,7 @@ type TableQueryWhere struct { | @@ -40,7 +40,7 @@ type TableQueryWhere struct { | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | func (w *TableQueryWhere) WithPageSize(page, size int) *TableQueryWhere { | 42 | func (w *TableQueryWhere) WithPageSize(page, size int) *TableQueryWhere { |
| 43 | - w.PageNumber = page - 1 | 43 | + w.PageNumber = page |
| 44 | w.PageSize = size | 44 | w.PageSize = size |
| 45 | if page == 0 { | 45 | if page == 0 { |
| 46 | w.PageNumber = 0 | 46 | w.PageNumber = 0 |
deploy/k8s/dev/install.sh
0 → 100644
| 1 | +#!/bin/bash | ||
| 2 | +export PATH=/root/local/bin:$PATH | ||
| 3 | +kubectl -n mmm-suplus-dev get pods | grep -q sumifcc-bchart | ||
| 4 | +if [ "$?" == "1" ];then | ||
| 5 | + kubectl create -f /tmp/dev/sumifcc-bchart/sumifcc-bchart.yaml --record | ||
| 6 | + kubectl -n mmm-suplus-dev get svc | grep -q sumifcc-bchart | ||
| 7 | + if [ "$?" == "0" ];then | ||
| 8 | + echo "sumifcc-bchart service install success!" | ||
| 9 | + else | ||
| 10 | + echo "sumifcc-bchart service install fail!" | ||
| 11 | + fi | ||
| 12 | + kubectl -n mmm-suplus-dev get pods | grep -q sumifcc-bchart | ||
| 13 | + if [ "$?" == "0" ];then | ||
| 14 | + echo "sumifcc-bchart deployment install success!" | ||
| 15 | + else | ||
| 16 | + echo "sumifcc-bchart deployment install fail!" | ||
| 17 | + fi | ||
| 18 | +else | ||
| 19 | + kubectl delete -f /tmp/dev/sumifcc-bchart/sumifcc-bchart.yaml | ||
| 20 | + kubectl -n mmm-suplus-dev get svc | grep -q sumifcc-bchart | ||
| 21 | + while [ "$?" == "0" ] | ||
| 22 | + do | ||
| 23 | + kubectl -n mmm-suplus-dev get svc | grep -q sumifcc-bchart | ||
| 24 | + done | ||
| 25 | + kubectl -n mmm-suplus-dev get pods | grep -q sumifcc-bchart | ||
| 26 | + while [ "$?" == "0" ] | ||
| 27 | + do | ||
| 28 | + kubectl -n mmm-suplus-dev get pods | grep -q sumifcc-bchart | ||
| 29 | + done | ||
| 30 | + kubectl create -f /tmp/dev/sumifcc-bchart/sumifcc-bchart.yaml --record | ||
| 31 | + kubectl -n mmm-suplus-dev get svc | grep -q sumifcc-bchart | ||
| 32 | + if [ "$?" == "0" ];then | ||
| 33 | + echo "sumifcc-bchart service update success!" | ||
| 34 | + else | ||
| 35 | + echo "sumifcc-bchart service update fail!" | ||
| 36 | + fi | ||
| 37 | + kubectl -n mmm-suplus-dev get pods | grep -q sumifcc-bchart | ||
| 38 | + if [ "$?" == "0" ];then | ||
| 39 | + echo "sumifcc-bchart deployment update success!" | ||
| 40 | + else | ||
| 41 | + echo "sumifcc-bchart deployment update fail!" | ||
| 42 | + fi | ||
| 43 | +fi |
deploy/k8s/dev/sumifcc-bchart.yaml
0 → 100644
| 1 | +apiVersion: v1 | ||
| 2 | +kind: Service | ||
| 3 | +metadata: | ||
| 4 | + name: sumifcc-bchart | ||
| 5 | + namespace: mmm-suplus-dev | ||
| 6 | + labels: | ||
| 7 | + k8s-app: sumifcc-bchart | ||
| 8 | +spec: | ||
| 9 | + ports: | ||
| 10 | + - name: "http" | ||
| 11 | + port: 80 | ||
| 12 | + targetPort: 8080 | ||
| 13 | + selector: | ||
| 14 | + k8s-app: sumifcc-bchart | ||
| 15 | +--- | ||
| 16 | +apiVersion: extensions/v1beta1 | ||
| 17 | +kind: Deployment | ||
| 18 | +metadata: | ||
| 19 | + name: sumifcc-bchart | ||
| 20 | + namespace: mmm-suplus-dev | ||
| 21 | + labels: | ||
| 22 | + k8s-app: sumifcc-bchart | ||
| 23 | +spec: | ||
| 24 | + replicas: 1 | ||
| 25 | + template: | ||
| 26 | + metadata: | ||
| 27 | + labels: | ||
| 28 | + k8s-app: sumifcc-bchart | ||
| 29 | + spec: | ||
| 30 | + affinity: | ||
| 31 | + nodeAffinity: | ||
| 32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
| 33 | + - preference: {} | ||
| 34 | + weight: 100 | ||
| 35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
| 36 | + nodeSelectorTerms: | ||
| 37 | + - matchExpressions: | ||
| 38 | + - key: kubernetes.io/hostname | ||
| 39 | + operator: In | ||
| 40 | + values: | ||
| 41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
| 42 | + containers: | ||
| 43 | + - name: sumifcc-bchart | ||
| 44 | + image: 192.168.0.243:5000/mmm/sumifcc-bchart:dev | ||
| 45 | + imagePullPolicy: Always | ||
| 46 | + ports: | ||
| 47 | + - containerPort: 8080 | ||
| 48 | + volumeMounts: | ||
| 49 | + - mountPath: /opt/logs | ||
| 50 | + name: accesslogs | ||
| 51 | + env: | ||
| 52 | + - name: LOG_LEVEL | ||
| 53 | + value: "debug" | ||
| 54 | + - name: ERROR_BASE_CODE | ||
| 55 | + value: "1" | ||
| 56 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
| 57 | + value: "1000" | ||
| 58 | + volumes: | ||
| 59 | + - name: accesslogs | ||
| 60 | + emptyDir: {} |
deploy/k8s/test/install.sh
0 → 100644
| 1 | +#!/bin/bash | ||
| 2 | +export PATH=/root/local/bin:$PATH | ||
| 3 | +kubectl -n <replace-your-k8s-namespace> get pods | grep -q sumifcc-survey-server | ||
| 4 | +if [ "$?" == "1" ];then | ||
| 5 | + kubectl create -f /tmp/dev/sumifcc-survey-server/sumifcc-survey-server.yaml --record | ||
| 6 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q sumifcc-survey-server | ||
| 7 | + if [ "$?" == "0" ];then | ||
| 8 | + echo "sumifcc-survey-server service install success!" | ||
| 9 | + else | ||
| 10 | + echo "sumifcc-survey-server service install fail!" | ||
| 11 | + fi | ||
| 12 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q sumifcc-survey-server | ||
| 13 | + if [ "$?" == "0" ];then | ||
| 14 | + echo "sumifcc-survey-server deployment install success!" | ||
| 15 | + else | ||
| 16 | + echo "sumifcc-survey-server deployment install fail!" | ||
| 17 | + fi | ||
| 18 | +else | ||
| 19 | + kubectl delete -f /tmp/dev/sumifcc-survey-server/sumifcc-survey-server.yaml | ||
| 20 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q sumifcc-survey-server | ||
| 21 | + while [ "$?" == "0" ] | ||
| 22 | + do | ||
| 23 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q sumifcc-survey-server | ||
| 24 | + done | ||
| 25 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q sumifcc-survey-server | ||
| 26 | + while [ "$?" == "0" ] | ||
| 27 | + do | ||
| 28 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q sumifcc-survey-server | ||
| 29 | + done | ||
| 30 | + kubectl create -f /tmp/dev/sumifcc-survey-server/sumifcc-survey-server.yaml --record | ||
| 31 | + kubectl -n <replace-your-k8s-namespace> get svc | grep -q sumifcc-survey-server | ||
| 32 | + if [ "$?" == "0" ];then | ||
| 33 | + echo "sumifcc-survey-server service update success!" | ||
| 34 | + else | ||
| 35 | + echo "sumifcc-survey-server service update fail!" | ||
| 36 | + fi | ||
| 37 | + kubectl -n <replace-your-k8s-namespace> get pods | grep -q sumifcc-survey-server | ||
| 38 | + if [ "$?" == "0" ];then | ||
| 39 | + echo "sumifcc-survey-server deployment update success!" | ||
| 40 | + else | ||
| 41 | + echo "sumifcc-survey-server deployment update fail!" | ||
| 42 | + fi | ||
| 43 | +fi |
deploy/k8s/test/sumifcc-survey-server.yaml
0 → 100644
| 1 | +apiVersion: v1 | ||
| 2 | +kind: Service | ||
| 3 | +metadata: | ||
| 4 | + name: sumifcc-survey-server | ||
| 5 | + namespace: <replace-your-k8s-namespace> | ||
| 6 | + labels: | ||
| 7 | + k8s-app: sumifcc-survey-server | ||
| 8 | +spec: | ||
| 9 | + ports: | ||
| 10 | + - name: "http" | ||
| 11 | + port: 80 | ||
| 12 | + targetPort: 8082 | ||
| 13 | + selector: | ||
| 14 | + k8s-app: sumifcc-survey-server | ||
| 15 | +--- | ||
| 16 | +apiVersion: extensions/v1beta1 | ||
| 17 | +kind: Deployment | ||
| 18 | +metadata: | ||
| 19 | + name: sumifcc-survey-server | ||
| 20 | + namespace: <replace-your-k8s-namespace> | ||
| 21 | + labels: | ||
| 22 | + k8s-app: sumifcc-survey-server | ||
| 23 | +spec: | ||
| 24 | + replicas: 1 | ||
| 25 | + template: | ||
| 26 | + metadata: | ||
| 27 | + labels: | ||
| 28 | + k8s-app: sumifcc-survey-server | ||
| 29 | + spec: | ||
| 30 | + affinity: | ||
| 31 | + nodeAffinity: | ||
| 32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
| 33 | + - preference: {} | ||
| 34 | + weight: 100 | ||
| 35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
| 36 | + nodeSelectorTerms: | ||
| 37 | + - matchExpressions: | ||
| 38 | + - key: kubernetes.io/hostname | ||
| 39 | + operator: In | ||
| 40 | + values: | ||
| 41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
| 42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
| 43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
| 44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
| 45 | + containers: | ||
| 46 | + - name: sumifcc-survey-server | ||
| 47 | + image: 192.168.0.243:5000/mmm/sumifcc-survey-server:dev | ||
| 48 | + imagePullPolicy: Always | ||
| 49 | + ports: | ||
| 50 | + - containerPort: 8082 | ||
| 51 | + volumeMounts: | ||
| 52 | + - mountPath: /opt/logs | ||
| 53 | + name: accesslogs | ||
| 54 | + env: | ||
| 55 | + - name: LOG_LEVEL | ||
| 56 | + value: "debug" | ||
| 57 | + - name: ERROR_BASE_CODE | ||
| 58 | + value: "1" | ||
| 59 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
| 60 | + value: "1000" | ||
| 61 | + volumes: | ||
| 62 | + - name: accesslogs | ||
| 63 | + emptyDir: {} |
| @@ -20,4 +20,13 @@ goctl api plugin -plugin goctl-swagger="swagger -filename core.json" -api .\doc\ | @@ -20,4 +20,13 @@ goctl api plugin -plugin goctl-swagger="swagger -filename core.json" -api .\doc\ | ||
| 20 | 20 | ||
| 21 | ``` | 21 | ``` |
| 22 | docker build -f Dockerfile -t tiptok/sumifcc-bchart:1.0.0 . | 22 | docker build -f Dockerfile -t tiptok/sumifcc-bchart:1.0.0 . |
| 23 | +``` | ||
| 24 | + | ||
| 25 | +## 基础镜像 | ||
| 26 | + | ||
| 27 | +``` | ||
| 28 | +docker build -f DockerfileBase -t tiptok/sumifcc-bchart-base:1.0.0 . | ||
| 29 | +docker save -o sumifcc-bchart-base.tar tiptok/sumifcc-bchart-base:1.0.0 | ||
| 30 | +docker load --input sumifcc-bchart-base.tar | ||
| 31 | +docker tag | ||
| 23 | ``` | 32 | ``` |
| @@ -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) |
| @@ -48,8 +45,9 @@ type ( | @@ -48,8 +45,9 @@ type ( | ||
| 48 | } | 45 | } |
| 49 | 46 | ||
| 50 | AppPageSaveRequest struct{ | 47 | AppPageSaveRequest struct{ |
| 51 | - Name string `json:"name"` // 名称 | ||
| 52 | - Charts []int64 `json:"charts"`// 图表 | 48 | + Name string `json:"name"` // 名称 |
| 49 | + Charts []int64 `json:"charts"`// 图表 | ||
| 50 | + Cover string `json:"cover,optional"` // 封面 | ||
| 53 | } | 51 | } |
| 54 | AppPageSaveResponse struct{ | 52 | AppPageSaveResponse struct{ |
| 55 | Id int64 `json:"id"` | 53 | Id int64 `json:"id"` |
| @@ -77,8 +75,9 @@ type ( | @@ -77,8 +75,9 @@ type ( | ||
| 77 | 75 | ||
| 78 | AppPageUpdateRequest struct{ | 76 | AppPageUpdateRequest struct{ |
| 79 | Id int64 `path:"id"` | 77 | Id int64 `path:"id"` |
| 80 | - Name string `json:"name"` // 名称 | 78 | + Name string `json:"name,optional"` // 名称 |
| 81 | Charts []int64 `json:"charts"`// 图表 | 79 | Charts []int64 `json:"charts"`// 图表 |
| 80 | + Cover string `json:"cover,optional"` // 封面 | ||
| 82 | } | 81 | } |
| 83 | AppPageUpdateResponse struct{} | 82 | AppPageUpdateResponse struct{} |
| 84 | 83 | ||
| @@ -93,12 +92,14 @@ type ( | @@ -93,12 +92,14 @@ type ( | ||
| 93 | AppPageItem struct{ | 92 | AppPageItem struct{ |
| 94 | Id int64 `json:"id,optional"` // 唯一标识 | 93 | Id int64 `json:"id,optional"` // 唯一标识 |
| 95 | Name string `json:"name,optional"` // 名称 | 94 | Name string `json:"name,optional"` // 名称 |
| 95 | + Cover string `json:"cover,optional"` // 封面 | ||
| 96 | Charts []AppPageChartItem `json:"charts,optional"`// 图表 | 96 | Charts []AppPageChartItem `json:"charts,optional"`// 图表 |
| 97 | } | 97 | } |
| 98 | AppPageChartItem struct{ | 98 | AppPageChartItem struct{ |
| 99 | - ChartId int64 `json:"chartId"` // 图表ID | ||
| 100 | - Name string `json:"name"` // 图表名称 | ||
| 101 | - Cover string `json:"cover"` // 图表封面 | 99 | + ChartId int64 `json:"chartId"` // 图表ID |
| 100 | + Name string `json:"name"` // 图表名称 | ||
| 101 | + Cover string `json:"cover"` // 图表封面 | ||
| 102 | + ChartType string `json:"chartType,optional"` // 图表类型 | ||
| 102 | } | 103 | } |
| 103 | ) | 104 | ) |
| 104 | 105 | ||
| @@ -108,6 +109,10 @@ type ( | @@ -108,6 +109,10 @@ type ( | ||
| 108 | group: page | 109 | group: page |
| 109 | ) | 110 | ) |
| 110 | service Core { | 111 | service Core { |
| 112 | + @doc "获取应用页详情" | ||
| 113 | + @handler getAppPage | ||
| 114 | + get /app-page/:id (AppPageGetRequest) returns (AppPageGetResponse) | ||
| 115 | + | ||
| 111 | @doc "开放接口-获取应用页详情通过KEY" | 116 | @doc "开放接口-获取应用页详情通过KEY" |
| 112 | @handler getAppPageShareDetail | 117 | @handler getAppPageShareDetail |
| 113 | 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 { |
| @@ -170,9 +167,11 @@ type( | @@ -170,9 +167,11 @@ type( | ||
| 170 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 | 167 | YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1 |
| 171 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 | 168 | YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2 |
| 172 | Area string `json:"area"` // 图形面积 | 169 | Area string `json:"area"` // 图形面积 |
| 170 | + AreaColor bool `json:"areaColor"` // 颜色 | ||
| 173 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 | 171 | SeriesList []QuarterSeries `json:"seriesList"` // 图形系列 |
| 174 | } | 172 | } |
| 175 | QuarterSeries struct { | 173 | QuarterSeries struct { |
| 174 | + SeriesValue string `json:"seriesValue"` | ||
| 176 | } | 175 | } |
| 177 | Title struct { | 176 | Title struct { |
| 178 | TitleSwitch bool `json:"titleSwitch,optional"` // 组件标题开关 | 177 | TitleSwitch bool `json:"titleSwitch,optional"` // 组件标题开关 |
| @@ -182,8 +181,11 @@ type( | @@ -182,8 +181,11 @@ type( | ||
| 182 | SubTitle string `json:"subTitle,optional"` // 副标题 | 181 | SubTitle string `json:"subTitle,optional"` // 副标题 |
| 183 | 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 |
| 184 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 183 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 184 | + FileName string `json:"fileName,optional"` // 文件名 | ||
| 185 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 185 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 186 | - Align string `json:"align,optional"` // 文本对齐方式 left center right | 186 | + Align string `json:"align,optional"` // 废弃 文本对齐方式 left center right |
| 187 | + HeadingAlign string `json:"headingAlign,optional"` // 主标题 文本对齐方式 left center right | ||
| 188 | + SubAlign string `json:"subAlign,optional"` // 副标题 文本对齐方式 left center right | ||
| 187 | } | 189 | } |
| 188 | TableAbility struct { | 190 | TableAbility struct { |
| 189 | FilterSwitch bool `json:"filterSwitch,optional"` // 表筛选功能开关 | 191 | FilterSwitch bool `json:"filterSwitch,optional"` // 表筛选功能开关 |
doc/dsl/api/core/log.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 | + prefix: v1 | ||
| 13 | + group: log | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +service Core { | ||
| 17 | + @doc "获取图表详情" | ||
| 18 | + @handler getLog | ||
| 19 | + get /log/:module (LogGetRequest) returns (LogGetResponse) | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +type( | ||
| 23 | + LogGetRequest struct{ | ||
| 24 | + Module string `path:"module"` | ||
| 25 | + } | ||
| 26 | + LogGetResponse struct{ | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | +) |
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 | +) |
| @@ -80,7 +80,7 @@ type ( | @@ -80,7 +80,7 @@ type ( | ||
| 80 | 80 | ||
| 81 | SearchTableDataRequest struct{ | 81 | SearchTableDataRequest struct{ |
| 82 | Token string `header:"x-mmm-accesstoken,optional"` | 82 | Token string `header:"x-mmm-accesstoken,optional"` |
| 83 | - ObjectId int `json:"objectId"` // 对象ID | 83 | + ObjectId int `json:"objectId,optional"` // 对象ID |
| 84 | PageNumber int `json:"page,optional"` // 分页数 | 84 | PageNumber int `json:"page,optional"` // 分页数 |
| 85 | PageSize int `json:"size,optional"` // 页码 | 85 | PageSize int `json:"size,optional"` // 页码 |
| 86 | Condition []*Condition `json:"conditions,optional"` // 条件 | 86 | Condition []*Condition `json:"conditions,optional"` // 条件 |
go.sum
0 → 100644
此 diff 太大无法显示。
| 1 | package cache | 1 | package cache |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "fmt" | ||
| 5 | "github.com/tiptok/gocomm/pkg/cache" | 4 | "github.com/tiptok/gocomm/pkg/cache" |
| 6 | "github.com/tiptok/gocomm/pkg/cache/gzcache" | 5 | "github.com/tiptok/gocomm/pkg/cache/gzcache" |
| 7 | "github.com/tiptok/gocomm/pkg/log" | 6 | "github.com/tiptok/gocomm/pkg/log" |
| 7 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | func NewMultiLevelCache(hosts []string, password string) *cache.MultiLevelCache { | 10 | func NewMultiLevelCache(hosts []string, password string) *cache.MultiLevelCache { |
| 11 | - fmt.Println("starting multi level cache...") | 11 | + logx.Infof("starting multi level cache...") |
| 12 | mlCache := cache.NewMultiLevelCacheNew(cache.WithDebugLog(true, func() log.Log { | 12 | mlCache := cache.NewMultiLevelCacheNew(cache.WithDebugLog(true, func() log.Log { |
| 13 | return log.DefaultLog | 13 | return log.DefaultLog |
| 14 | })) | 14 | })) |
| 1 | package database | 1 | package database |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "context" | ||
| 4 | "fmt" | 5 | "fmt" |
| 6 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 5 | "gorm.io/driver/mysql" | 7 | "gorm.io/driver/mysql" |
| 6 | "gorm.io/driver/postgres" | 8 | "gorm.io/driver/postgres" |
| 7 | "gorm.io/gorm" | 9 | "gorm.io/gorm" |
| @@ -31,28 +33,52 @@ func OpenGormDB(source string) *gorm.DB { | @@ -31,28 +33,52 @@ func OpenGormDB(source string) *gorm.DB { | ||
| 31 | return db | 33 | return db |
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | -func OpenGormPGDB(source string) *gorm.DB { | ||
| 35 | - newLogger := logger.New( | ||
| 36 | - log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer | ||
| 37 | - logger.Config{ | ||
| 38 | - SlowThreshold: time.Second, // Slow SQL threshold | ||
| 39 | - LogLevel: logger.Info, // Log level | ||
| 40 | - IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger | ||
| 41 | - Colorful: false, // Disable color | ||
| 42 | - }, | ||
| 43 | - ) | ||
| 44 | - fmt.Println("starting db...") | ||
| 45 | - //db, err := gorm.Open(postgres.Open(source), &gorm.Config{ | ||
| 46 | - // Logger: newLogger, | ||
| 47 | - //}) | 36 | +func OpenGormPGDB(source string, logMode string) *gorm.DB { |
| 37 | + logx.Infof("starting db...") | ||
| 48 | db, err := gorm.Open(postgres.New(postgres.Config{ | 38 | db, err := gorm.Open(postgres.New(postgres.Config{ |
| 49 | DSN: source, | 39 | DSN: source, |
| 50 | PreferSimpleProtocol: true, // disables implicit prepared statement usage | 40 | PreferSimpleProtocol: true, // disables implicit prepared statement usage |
| 51 | }), &gorm.Config{ | 41 | }), &gorm.Config{ |
| 52 | - Logger: newLogger, | 42 | + Logger: NewLogger(logMode), //newLogger, |
| 53 | }) | 43 | }) |
| 54 | if err != nil { | 44 | if err != nil { |
| 55 | panic(err) | 45 | panic(err) |
| 56 | } | 46 | } |
| 57 | return db | 47 | return db |
| 58 | } | 48 | } |
| 49 | + | ||
| 50 | +func NewLogger(logType string) logger.Interface { | ||
| 51 | + if logType == "console" { | ||
| 52 | + return logger.New( | ||
| 53 | + log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer | ||
| 54 | + logger.Config{ | ||
| 55 | + SlowThreshold: time.Second, // Slow SQL threshold | ||
| 56 | + LogLevel: logger.Info, // Log level | ||
| 57 | + IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger | ||
| 58 | + Colorful: false, // Disable color | ||
| 59 | + }, | ||
| 60 | + ) | ||
| 61 | + } | ||
| 62 | + return ZeroLog{} | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +type ZeroLog struct { | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +func (l ZeroLog) LogMode(logger.LogLevel) logger.Interface { | ||
| 69 | + return l | ||
| 70 | +} | ||
| 71 | +func (l ZeroLog) Info(ctx context.Context, s string, values ...interface{}) { | ||
| 72 | + logx.Infof(s, values...) | ||
| 73 | +} | ||
| 74 | +func (l ZeroLog) Warn(ctx context.Context, s string, values ...interface{}) { | ||
| 75 | + logx.Errorf(s, values...) | ||
| 76 | +} | ||
| 77 | +func (l ZeroLog) Error(ctx context.Context, s string, values ...interface{}) { | ||
| 78 | + logx.Errorf(s, values...) | ||
| 79 | +} | ||
| 80 | +func (l ZeroLog) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) { | ||
| 81 | + now := time.Now() | ||
| 82 | + sql, rows := fc() | ||
| 83 | + logx.Infof("[%v] [rows:%v] %s", now.Sub(begin).String(), rows, sql) | ||
| 84 | +} |
-
请 注册 或 登录 后发表评论