add linter, update swagger doc
This commit is contained in:
1 parent
c4a34c6cd2
commit
091f3ed06e
25 files changed
+1893
-115
No files matched your search
@@ -1,11 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
"isp-system-service/entity"
|
||||
|
||||
"github.com/go-pg/pg/v9"
|
||||
"github.com/go-pg/pg/v9/orm"
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
)
|
||||
|
||||
var emptyApplication = (*entity.Application)(nil)
|
||||
@@ -22,17 +22,20 @@ func (r *AppRepository) GetApplications(list []int32) ([]entity.Application, err
|
||||
q = q.Where("id IN (?)", pg.In(list))
|
||||
}
|
||||
err := q.Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *AppRepository) GetApplicationsByServiceId(serviceId ...int32) ([]entity.Application, error) {
|
||||
res := make([]entity.Application, 0)
|
||||
err := r.getDb().Model(&res).Where("service_id IN (?)", pg.In(serviceId)).Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *AppRepository) CreateApplication(service entity.Application) (entity.Application, error) {
|
||||
_, err := r.getDb().Model(&service).Insert()
|
||||
|
||||
return service, err
|
||||
}
|
||||
|
||||
@@ -42,11 +45,13 @@ func (r *AppRepository) GetApplicationByNameAndServiceId(name string, serviceId
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return app, err
|
||||
}
|
||||
|
||||
func (r *AppRepository) UpdateApplication(app entity.Application) (entity.Application, error) {
|
||||
_, err := r.getDb().Model(&app).Column("name", "description").WherePK().Returning("*").Update()
|
||||
|
||||
return app, err
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ func (r *AppRepository) GetApplicationById(id int32) (*entity.Application, error
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return app, err
|
||||
}
|
||||
|
||||
@@ -64,6 +70,7 @@ func (r *AppRepository) DeleteApplications(list []int32) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.RowsAffected(), nil
|
||||
}
|
||||
|
||||
@@ -71,5 +78,6 @@ func (r *AppRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
Reference in new issue
Block a user