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,10 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"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"
|
||||
"isp-system-service/entity"
|
||||
)
|
||||
|
||||
type AccessListRepository struct {
|
||||
@@ -18,8 +19,10 @@ func (r *AccessListRepository) GetByAppId(appId int32) ([]entity.AccessList, err
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return model, nil
|
||||
}
|
||||
|
||||
@@ -29,8 +32,10 @@ func (r *AccessListRepository) GetByAppIdList(list []int32) ([]entity.AccessList
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return model, nil
|
||||
}
|
||||
|
||||
@@ -40,6 +45,7 @@ func (r *AccessListRepository) DeleteById(id int32) ([]entity.AccessList, error)
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
} else {
|
||||
return model, nil
|
||||
@@ -52,6 +58,7 @@ func (r *AccessListRepository) DeleteByIdList(list []int32) ([]entity.AccessList
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
} else {
|
||||
return model, nil
|
||||
@@ -79,5 +86,6 @@ func (r *AccessListRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"isp-system-service/log_code"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-system-service/log_code"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+9
-1
@@ -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 emptyDomain = (*entity.Domain)(nil)
|
||||
@@ -22,17 +22,20 @@ func (r *DomainRepository) GetDomains(list []int32) ([]entity.Domain, error) {
|
||||
q = q.Where("id IN (?)", pg.In(list))
|
||||
}
|
||||
err := q.Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *DomainRepository) GetDomainsBySystemId(systemId int32) ([]entity.Domain, error) {
|
||||
res := make([]entity.Domain, 0)
|
||||
err := r.getDb().Model(&res).Where("system_id = ?", systemId).Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *DomainRepository) CreateDomain(domain entity.Domain) (entity.Domain, error) {
|
||||
_, err := r.getDb().Model(&domain).Insert()
|
||||
|
||||
return domain, err
|
||||
}
|
||||
|
||||
@@ -42,11 +45,13 @@ func (r *DomainRepository) GetDomainByNameAndSystemId(name string, systemId int3
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return domain, err
|
||||
}
|
||||
|
||||
func (r *DomainRepository) UpdateDomain(domain entity.Domain) (entity.Domain, error) {
|
||||
_, err := r.getDb().Model(&domain).Column("name", "description").WherePK().Returning("*").Update()
|
||||
|
||||
return domain, err
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ func (r *DomainRepository) GetDomainById(id int32) (*entity.Domain, error) {
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return domain, err
|
||||
}
|
||||
|
||||
@@ -64,6 +70,7 @@ func (r *DomainRepository) DeleteDomains(list []int32) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.RowsAffected(), nil
|
||||
}
|
||||
|
||||
@@ -71,5 +78,6 @@ func (r *DomainRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
+9
-1
@@ -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 emptyService = (*entity.Service)(nil)
|
||||
@@ -22,17 +22,20 @@ func (r *ServiceRepository) GetServices(list []int32) ([]entity.Service, error)
|
||||
q = q.Where("id IN (?)", pg.In(list))
|
||||
}
|
||||
err := q.Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *ServiceRepository) GetServicesByDomainId(domainId ...int32) ([]entity.Service, error) {
|
||||
res := make([]entity.Service, 0)
|
||||
err := r.getDb().Model(&res).Where("domain_id IN (?)", pg.In(domainId)).Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *ServiceRepository) CreateService(service entity.Service) (entity.Service, error) {
|
||||
_, err := r.getDb().Model(&service).Insert()
|
||||
|
||||
return service, err
|
||||
}
|
||||
|
||||
@@ -42,11 +45,13 @@ func (r *ServiceRepository) GetServiceByNameAndDomainId(name string, domainId in
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return service, err
|
||||
}
|
||||
|
||||
func (r *ServiceRepository) UpdateService(service entity.Service) (entity.Service, error) {
|
||||
_, err := r.getDb().Model(&service).Column("name", "description").WherePK().Returning("*").Update()
|
||||
|
||||
return service, err
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ func (r *ServiceRepository) GetServiceById(id int32) (*entity.Service, error) {
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return service, err
|
||||
}
|
||||
|
||||
@@ -64,6 +70,7 @@ func (r *ServiceRepository) DeleteServices(list []int32) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.RowsAffected(), nil
|
||||
}
|
||||
|
||||
@@ -71,5 +78,6 @@ func (r *ServiceRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
+8
-1
@@ -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 emptySystem = (*entity.System)(nil)
|
||||
@@ -22,11 +22,13 @@ func (r *SystemRepository) GetSystems(list []int32) ([]entity.System, error) {
|
||||
q = q.Where("id IN (?)", pg.In(list))
|
||||
}
|
||||
err := q.Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *SystemRepository) CreateSystem(system entity.System) (entity.System, error) {
|
||||
_, err := r.getDb().Model(&system).Insert()
|
||||
|
||||
return system, err
|
||||
}
|
||||
|
||||
@@ -36,11 +38,13 @@ func (r *SystemRepository) GetSystemByName(name string) (*entity.System, error)
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return sys, err
|
||||
}
|
||||
|
||||
func (r *SystemRepository) UpdateSystem(system entity.System) (entity.System, error) {
|
||||
_, err := r.getDb().Model(&system).Column("name", "description").WherePK().Returning("*").Update()
|
||||
|
||||
return system, err
|
||||
}
|
||||
|
||||
@@ -50,6 +54,7 @@ func (r *SystemRepository) GetSystemById(id int32) (*entity.System, error) {
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return sys, err
|
||||
}
|
||||
|
||||
@@ -58,6 +63,7 @@ func (r *SystemRepository) DeleteSystems(list []int32) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.RowsAffected(), nil
|
||||
}
|
||||
|
||||
@@ -65,5 +71,6 @@ func (r *SystemRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
+6
-1
@@ -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 emptyToken = (*entity.Token)(nil)
|
||||
@@ -17,6 +17,7 @@ type TokenRepository struct {
|
||||
|
||||
func (r *TokenRepository) SaveToken(token entity.Token) (entity.Token, error) {
|
||||
_, err := r.getDb().Model(&token).Insert()
|
||||
|
||||
return token, err
|
||||
}
|
||||
|
||||
@@ -26,12 +27,14 @@ func (r *TokenRepository) GetTokenById(id string) (*entity.Token, error) {
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return token, err
|
||||
}
|
||||
|
||||
func (r *TokenRepository) GetTokensByAppId(appId ...int32) ([]entity.Token, error) {
|
||||
res := make([]entity.Token, 0)
|
||||
err := r.getDb().Model(&res).Where("app_id IN (?)", pg.In(appId)).Order("created_at DESC").Select()
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -40,6 +43,7 @@ func (r *TokenRepository) DeleteTokens(tokens []string) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.RowsAffected(), nil
|
||||
}
|
||||
|
||||
@@ -47,5 +51,6 @@ func (r *TokenRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
Reference in new issue
Block a user