作者 yangfu

fix: bug

... ... @@ -47,7 +47,7 @@ func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Cont
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if duplicateRule, e := mappingRuleRepository.FindOne(map[string]interface{}{"context": ctx, "name": cmd.Name}); e == nil && duplicateRule != nil {
if duplicateRule, e := mappingRuleRepository.FindOne(map[string]interface{}{"context": ctx, "name": cmd.Name, "tableId": cmd.TableId}); e == nil && duplicateRule != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "方案名称重复")
}
... ...
... ... @@ -81,6 +81,7 @@ func (ptr *PreviewDataTableService) CreateTemporaryFile(ctx *domain.Context, fil
return nil, fmt.Errorf("源文件/校验文件才可以创建临时文件")
}
file = file.CopyTo(domain.TemporaryFile, ctx)
file.FileInfo.TableId = 0
if file, err = fileRepository.Save(file); err != nil {
return nil, err
}
... ...
... ... @@ -114,6 +114,7 @@ func (repository *MappingRuleRepository) FindOne(queryOptions map[string]interfa
query := sqlbuilder.BuildQuery(tx.Model(mappingRuleModel), queryOptions)
WhereContext(query, queryOptions)
query.SetWhereByQueryOption("name = ?", "name")
query.SetWhereByQueryOption("table_id = ?", "tableId")
query.SetWhereByQueryOption("mapping_rule.mapping_rule_id = ?", "mappingRuleId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
... ...