Commit f20f4d13 by utkarshcmu

Pulled out the common code

parent 3af4b1ff
...@@ -52,24 +52,9 @@ func GetDataSourceById(c *middleware.Context) Response { ...@@ -52,24 +52,9 @@ func GetDataSourceById(c *middleware.Context) Response {
} }
ds := query.Result ds := query.Result
dtos := convertModelToDtos(ds)
return Json(200, &dtos.DataSource{ return Json(200, &dtos)
Id: ds.Id,
OrgId: ds.OrgId,
Name: ds.Name,
Url: ds.Url,
Type: ds.Type,
Access: ds.Access,
Password: ds.Password,
Database: ds.Database,
User: ds.User,
BasicAuth: ds.BasicAuth,
BasicAuthUser: ds.BasicAuthUser,
BasicAuthPassword: ds.BasicAuthPassword,
WithCredentials: ds.WithCredentials,
IsDefault: ds.IsDefault,
JsonData: ds.JsonData,
})
} }
func DeleteDataSource(c *middleware.Context) { func DeleteDataSource(c *middleware.Context) {
...@@ -145,8 +130,13 @@ func GetDataSourceByName(c *middleware.Context) Response { ...@@ -145,8 +130,13 @@ func GetDataSourceByName(c *middleware.Context) Response {
} }
ds := query.Result ds := query.Result
dtos := convertModelToDtos(ds)
return Json(200, &dtos)
}
return Json(200, &dtos.DataSource{ func convertModelToDtos(ds m.DataSource) dtos.DataSource {
return dtos.DataSource{
Id: ds.Id, Id: ds.Id,
OrgId: ds.OrgId, OrgId: ds.OrgId,
Name: ds.Name, Name: ds.Name,
...@@ -162,5 +152,5 @@ func GetDataSourceByName(c *middleware.Context) Response { ...@@ -162,5 +152,5 @@ func GetDataSourceByName(c *middleware.Context) Response {
WithCredentials: ds.WithCredentials, WithCredentials: ds.WithCredentials,
IsDefault: ds.IsDefault, IsDefault: ds.IsDefault,
JsonData: ds.JsonData, JsonData: ds.JsonData,
}) }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment