作者 yangfu

cover

@@ -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 }
@@ -37,6 +37,7 @@ func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *typ @@ -37,6 +37,7 @@ 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,
40 } 41 }
41 if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { 42 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 { 43 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 }
@@ -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
@@ -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 }
@@ -228,8 +228,9 @@ type AppPageGetResponse struct { @@ -228,8 +228,9 @@ type AppPageGetResponse struct {
228 } 228 }
229 229
230 type AppPageSaveRequest struct { 230 type AppPageSaveRequest struct {
231 - Name string `json:"name"` // 名称  
232 - Charts []int64 `json:"charts"` // 图表 231 + Name string `json:"name"` // 名称
  232 + Charts []int64 `json:"charts"` // 图表
  233 + Cover string `json:"cover,optional"` // 封面
233 } 234 }
234 235
235 type AppPageSaveResponse struct { 236 type AppPageSaveResponse struct {
@@ -264,8 +265,9 @@ type AppPageDeleteResponse struct { @@ -264,8 +265,9 @@ type AppPageDeleteResponse struct {
264 265
265 type AppPageUpdateRequest struct { 266 type AppPageUpdateRequest struct {
266 Id int64 `path:"id"` 267 Id int64 `path:"id"`
267 - Name string `json:"name"` // 名称  
268 - Charts []int64 `json:"charts"` // 图表 268 + Name string `json:"name,optional"` // 名称
  269 + Charts []int64 `json:"charts"` // 图表
  270 + Cover string `json:"cover,optional"` // 封面
269 } 271 }
270 272
271 type AppPageUpdateResponse struct { 273 type AppPageUpdateResponse struct {
@@ -284,13 +286,15 @@ type AppPageSearchResponse struct { @@ -284,13 +286,15 @@ type AppPageSearchResponse struct {
284 type AppPageItem struct { 286 type AppPageItem struct {
285 Id int64 `json:"id,optional"` // 唯一标识 287 Id int64 `json:"id,optional"` // 唯一标识
286 Name string `json:"name,optional"` // 名称 288 Name string `json:"name,optional"` // 名称
  289 + Cover string `json:"cover,optional"` // 封面
287 Charts []AppPageChartItem `json:"charts,optional"` // 图表 290 Charts []AppPageChartItem `json:"charts,optional"` // 图表
288 } 291 }
289 292
290 type AppPageChartItem struct { 293 type AppPageChartItem struct {
291 - ChartId int64 `json:"chartId"` // 图表ID  
292 - Name string `json:"name"` // 图表名称  
293 - Cover string `json:"cover"` // 图表封面 294 + ChartId int64 `json:"chartId"` // 图表ID
  295 + Name string `json:"name"` // 图表名称
  296 + Cover string `json:"cover"` // 图表封面
  297 + ChartType string `json:"chartType,optional"` // 图表类型
294 } 298 }
295 299
296 type GetAppPageShareDetailRequest struct { 300 type GetAppPageShareDetailRequest struct {
@@ -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"`
@@ -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"`
@@ -48,8 +48,9 @@ type ( @@ -48,8 +48,9 @@ type (
48 } 48 }
49 49
50 AppPageSaveRequest struct{ 50 AppPageSaveRequest struct{
51 - Name string `json:"name"` // 名称  
52 - Charts []int64 `json:"charts"`// 图表 51 + Name string `json:"name"` // 名称
  52 + Charts []int64 `json:"charts"`// 图表
  53 + Cover string `json:"cover,optional"` // 封面
53 } 54 }
54 AppPageSaveResponse struct{ 55 AppPageSaveResponse struct{
55 Id int64 `json:"id"` 56 Id int64 `json:"id"`
@@ -77,8 +78,9 @@ type ( @@ -77,8 +78,9 @@ type (
77 78
78 AppPageUpdateRequest struct{ 79 AppPageUpdateRequest struct{
79 Id int64 `path:"id"` 80 Id int64 `path:"id"`
80 - Name string `json:"name"` // 名称 81 + Name string `json:"name,optional"` // 名称
81 Charts []int64 `json:"charts"`// 图表 82 Charts []int64 `json:"charts"`// 图表
  83 + Cover string `json:"cover,optional"` // 封面
82 } 84 }
83 AppPageUpdateResponse struct{} 85 AppPageUpdateResponse struct{}
84 86
@@ -93,12 +95,14 @@ type ( @@ -93,12 +95,14 @@ type (
93 AppPageItem struct{ 95 AppPageItem struct{
94 Id int64 `json:"id,optional"` // 唯一标识 96 Id int64 `json:"id,optional"` // 唯一标识
95 Name string `json:"name,optional"` // 名称 97 Name string `json:"name,optional"` // 名称
  98 + Cover string `json:"cover,optional"` // 封面
96 Charts []AppPageChartItem `json:"charts,optional"`// 图表 99 Charts []AppPageChartItem `json:"charts,optional"`// 图表
97 } 100 }
98 AppPageChartItem struct{ 101 AppPageChartItem struct{
99 - ChartId int64 `json:"chartId"` // 图表ID  
100 - Name string `json:"name"` // 图表名称  
101 - Cover string `json:"cover"` // 图表封面 102 + ChartId int64 `json:"chartId"` // 图表ID
  103 + Name string `json:"name"` // 图表名称
  104 + Cover string `json:"cover"` // 图表封面
  105 + ChartType string `json:"chartType,optional"` // 图表类型
102 } 106 }
103 ) 107 )
104 108