正在显示
16 个修改的文件
包含
105 行增加
和
10 行删除
| @@ -5,7 +5,7 @@ Verbose: true | @@ -5,7 +5,7 @@ Verbose: true | ||
| 5 | HostName: http://sumifcc-bchart-dev.sumifcc.com | 5 | HostName: http://sumifcc-bchart-dev.sumifcc.com |
| 6 | 6 | ||
| 7 | Log: | 7 | Log: |
| 8 | - Mode: file | 8 | + #Mode: file |
| 9 | Encoding: plain | 9 | Encoding: plain |
| 10 | Level: debug # info | 10 | Level: debug # info |
| 11 | MaxSize: 1 # 2MB | 11 | MaxSize: 1 # 2MB |
| @@ -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 |
| @@ -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 | ) |
| @@ -39,6 +39,9 @@ func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *typ | @@ -39,6 +39,9 @@ func (l *SaveAppPageLogic) SaveAppPage(req *types.AppPageSaveRequest) (resp *typ | ||
| 39 | TenantId: tenantId, | 39 | TenantId: tenantId, |
| 40 | Cover: req.Cover, | 40 | Cover: req.Cover, |
| 41 | } | 41 | } |
| 42 | + if total, _, _ := l.svcCtx.AppPageRepository.FindByName(l.ctx, conn, tenantId, req.Name); total > 0 { | ||
| 43 | + return nil, xerr.NewErrMsgErr("页面名字重复", nil) | ||
| 44 | + } | ||
| 42 | 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 { |
| 43 | 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 { |
| 44 | return err | 47 | return err |
| @@ -54,7 +54,8 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM | @@ -54,7 +54,8 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM | ||
| 54 | Token: req.Token, | 54 | Token: req.Token, |
| 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: false, |
| 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, |
| @@ -145,7 +145,9 @@ type Title struct { | @@ -145,7 +145,9 @@ type Title struct { | ||
| 145 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 145 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 146 | FileName string `json:"fileName,optional"` // 文件名 | 146 | FileName string `json:"fileName,optional"` // 文件名 |
| 147 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 147 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 148 | - 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 | ||
| 149 | } | 151 | } |
| 150 | 152 | ||
| 151 | type TableAbility struct { | 153 | type TableAbility struct { |
| @@ -211,7 +213,7 @@ type GetTableDetailResponse struct { | @@ -211,7 +213,7 @@ type GetTableDetailResponse struct { | ||
| 211 | 213 | ||
| 212 | type SearchTableDataRequest struct { | 214 | type SearchTableDataRequest struct { |
| 213 | Token string `header:"x-mmm-accesstoken,optional"` | 215 | Token string `header:"x-mmm-accesstoken,optional"` |
| 214 | - ObjectId int `json:"objectId"` // 对象ID | 216 | + ObjectId int `json:"objectId,optional"` // 对象ID |
| 215 | PageNumber int `json:"page,optional"` // 分页数 | 217 | PageNumber int `json:"page,optional"` // 分页数 |
| 216 | PageSize int `json:"size,optional"` // 页码 | 218 | PageSize int `json:"size,optional"` // 页码 |
| 217 | Condition []*Condition `json:"conditions,optional"` // 条件 | 219 | Condition []*Condition `json:"conditions,optional"` // 条件 |
| @@ -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 |
| @@ -27,6 +27,7 @@ type AppPageRepository interface { | @@ -27,6 +27,7 @@ type AppPageRepository interface { | ||
| 27 | FindOneByKey(ctx context.Context, conn transaction.Conn, key string) (*AppPage, error) | 27 | FindOneByKey(ctx context.Context, conn transaction.Conn, key string) (*AppPage, error) |
| 28 | 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) |
| 29 | 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) | ||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | 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 | /*************** 索引函数 开始****************/ |
| @@ -55,7 +55,9 @@ type Title struct { | @@ -55,7 +55,9 @@ type Title struct { | ||
| 55 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 55 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 56 | FileName string `json:"fileName,optional"` // 文件名 | 56 | FileName string `json:"fileName,optional"` // 文件名 |
| 57 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 | 57 | FileUrl string `json:"fileUrl,optional"` // 组件图片/视频 |
| 58 | - 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 | ||
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | 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 | } |
| @@ -183,7 +183,9 @@ type( | @@ -183,7 +183,9 @@ type( | ||
| 183 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 | 183 | ExplainTxt string `json:"explainTxt,optional"` // 文字说明 |
| 184 | FileName string `json:"fileName,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"` // 表筛选功能开关 |
| @@ -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 太大无法显示。
-
请 注册 或 登录 后发表评论