Merge pull request #3 from integration-system/api-doc
add(document generation)
This commit is contained in:
9 files changed
+279
-20
No files matched your search
@@ -1,3 +1,5 @@
|
||||
### v1.1.2
|
||||
* add document generation
|
||||
### v1.1.1
|
||||
* update config description
|
||||
* update lib
|
||||
|
||||
Generated
+19
-19
@@ -63,7 +63,7 @@
|
||||
version = "v8.0.6"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:6bafc5f7351645dce4cd04ec4db791bdb421d43da13c3fcef8b90cca01ba7621"
|
||||
digest = "1:61a8ca58fee5891ccd5e9e0503d3cb0636fe15505a7b758d51fe38d38bfce32f"
|
||||
name = "github.com/go-redis/redis"
|
||||
packages = [
|
||||
".",
|
||||
@@ -75,8 +75,8 @@
|
||||
"internal/util",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "c5c4ad6a4cae24f3867af1a0513709fc944a87f3"
|
||||
version = "v6.15.4"
|
||||
revision = "17c058513b3e03c5e23136c18582fdd8ac8a3645"
|
||||
version = "v6.15.5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:07f4fafe81587b642166199f41c3edcca12929fcfcc0261b00be5dea2f968f44"
|
||||
@@ -154,7 +154,7 @@
|
||||
revision = "5959fcea049facd9441fff9de976191accd3cf9f"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:599d185ab2aead7369ede6a373627138866c6320337699fd58b8b8cb3bb031e6"
|
||||
digest = "1:ce525c04629add45b86c81172111ae0a770f841f4400082851d1e7dfe28dfc8d"
|
||||
name = "github.com/integration-system/isp-lib"
|
||||
packages = [
|
||||
"backend",
|
||||
@@ -173,8 +173,8 @@
|
||||
"utils",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "50b5d5bd59eaeacc2fd0b63a3b2daae4bbbca563"
|
||||
version = "v1.6.1"
|
||||
revision = "ec379c1305f381a22a2934d406f4e3c3e20ef0c2"
|
||||
version = "v1.6.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -212,8 +212,8 @@
|
||||
"zlib",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "7a422a2abf4b2f2905a961d3b6926e4e21dab4bb"
|
||||
version = "v1.8.0"
|
||||
revision = "fdc46f09595ea8241b9bfe291bbc868a7af19e10"
|
||||
version = "v1.8.2"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:923c4d7194b42e054b2eb8a6c62824ac55e23ececc1c7e48d4da69c971c55954"
|
||||
@@ -340,15 +340,15 @@
|
||||
revision = "cac0b30c2563378d434b5af411844adff8e32960"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f5139e9f4441369ffb5d44fa9fae62b921457d4dc09cd873ed0fd44511cc87ee"
|
||||
digest = "1:ab1672baf07ee80c988e369e5633bcac459342e8e00d0c38a799056395fe9dba"
|
||||
name = "github.com/shirou/gopsutil"
|
||||
packages = [
|
||||
"cpu",
|
||||
"internal/common",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "d80c43f9c984a48783daf22f4bd9278006ae483a"
|
||||
version = "v2.19.7"
|
||||
revision = "e4ec7b275ada47ca32799106c2dba142d96aaf93"
|
||||
version = "v2.19.8"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:04457f9f6f3ffc5fea48e71d62f2ca256637dee0a04d710288e27e05c8b41976"
|
||||
@@ -419,7 +419,7 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:30fe8021645a9d9966fcede2a59c2e2f498d433687fc5cddd7de85a6a0a44c28"
|
||||
digest = "1:b97ba937497c9b282245aa8f633212c96fcaa1b4cc30e9ab6ae41a0168e32c35"
|
||||
name = "github.com/valyala/fasthttp"
|
||||
packages = [
|
||||
".",
|
||||
@@ -427,7 +427,7 @@
|
||||
"stackless",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "1241ed7a910a835656961bf69fb8f1fa9cc8b88e"
|
||||
revision = "8713335f548d2c18effe36c9686f5a88b65eefce"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:39a425f98fb19427061a693fe6bf0683c9bddec4b25b17067e34fdb465e39cb9"
|
||||
@@ -446,11 +446,11 @@
|
||||
"ssh/terminal",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "60c769a6c58655dab1b9adac0d58967dd517cfba"
|
||||
revision = "9756ffdc24725223350eb3266ffb92590d28f278"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:082ed090a1aedec21b660263f98f72582e431b56e8e27b88cc00faa1510fde14"
|
||||
digest = "1:8c8471f63317e39731853a4f55d5d8ff43a142aa425a666a0554bdba0a8b7f8b"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"context",
|
||||
@@ -462,18 +462,18 @@
|
||||
"trace",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "74dc4d7220e7acc4e100824340f3e66577424772"
|
||||
revision = "ba9fcec4b297b415637633c5a6e8fa592e4a16c3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:13d49ebdcb9d09dd5b445e274059b59705e09327df54b221a853d6a8192182ad"
|
||||
digest = "1:4f9cc50343843f7c58c1a1aecf17c226ea0e855f4d3293e796701ae985111e0d"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "fb81701db80f1745f51259b1f286de3fe2ec80c8"
|
||||
revision = "749cb33beabd9aa6d3178e3de05bcc914f70b2bf"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8d8faad6b12a3a4c819a3f9618cb6ee1fa1cfc33253abeeea8b55336721e3405"
|
||||
@@ -509,7 +509,7 @@
|
||||
"googleapis/rpc/status",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "24fa4b261c55da65468f2abfdae2b024eef27dfb"
|
||||
revision = "92dd089d5514cecde7a465f807541f83dfd486d5"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:3b97661db2e5d4c87f7345e875ea28f911e54c715ba0a74be08e1649d67e05cd"
|
||||
|
||||
@@ -5,12 +5,23 @@ import (
|
||||
"isp-system-service/model"
|
||||
|
||||
"github.com/integration-system/isp-lib/database"
|
||||
_ "github.com/integration-system/isp-lib/structure"
|
||||
"github.com/integration-system/isp-lib/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// GetApplications godoc
|
||||
// @Tags application
|
||||
// @Summary Получить список приложений
|
||||
// @Description Возвращает массив приложений с токенами по их идентификаторам
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов приложений"
|
||||
// @Success 200 {array} controller.AppWithToken
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/get_applications [POST]
|
||||
func GetApplications(list []int32) ([]*AppWithToken, error) {
|
||||
res, err := model.AppRep.GetApplications(list)
|
||||
if err != nil {
|
||||
@@ -19,6 +30,16 @@ func GetApplications(list []int32) ([]*AppWithToken, error) {
|
||||
return enrichWithTokens(res...)
|
||||
}
|
||||
|
||||
// GetApplicationsByServiceId godoc
|
||||
// @Tags application
|
||||
// @Summary Получить список приложений по идентификатору сервиса
|
||||
// @Description Возвращает список приложений по запрошенныму идентификатору сервиса
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор серсиса"
|
||||
// @Success 200 {array} controller.AppWithToken
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/get_applications_by_service_id [POST]
|
||||
func GetApplicationsByServiceId(identity Identity) ([]*AppWithToken, error) {
|
||||
arr, err := model.AppRep.GetApplicationsByServiceId(identity.Id)
|
||||
if err != nil {
|
||||
@@ -27,6 +48,19 @@ func GetApplicationsByServiceId(identity Identity) ([]*AppWithToken, error) {
|
||||
return enrichWithTokens(arr...)
|
||||
}
|
||||
|
||||
// CreateUpdateApplication godoc
|
||||
// @Tags application
|
||||
// @Summary Создать/обновить приложение
|
||||
// @Description Если приложение с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body entity.Application true "Объект приложения"
|
||||
// @Success 200 {object} controller.AppWithToken
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 409 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/create_update_application [POST]
|
||||
func CreateUpdateApplication(app entity.Application) (*AppWithToken, error) {
|
||||
existed, err := model.AppRep.GetApplicationByNameAndServiceId(app.Name, app.ServiceId)
|
||||
if err != nil {
|
||||
@@ -69,6 +103,18 @@ func CreateUpdateApplication(app entity.Application) (*AppWithToken, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetApplicationById godoc
|
||||
// @Tags application
|
||||
// @Summary Получить приложение по идентификатору
|
||||
// @Description Возвращает описание приложения по его идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор приложения"
|
||||
// @Success 200 {object} controller.AppWithToken
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/get_application_by_id [POST]
|
||||
func GetApplicationById(identity Identity) (*AppWithToken, error) {
|
||||
application, err := model.AppRep.GetApplicationById(identity.Id)
|
||||
if err != nil {
|
||||
@@ -84,6 +130,17 @@ func GetApplicationById(identity Identity) (*AppWithToken, error) {
|
||||
return arr[0], nil
|
||||
}
|
||||
|
||||
// DeleteApplications godoc
|
||||
// @Tags application
|
||||
// @Summary Удалить приложения
|
||||
// @Description Удаляет приложения по списку их идентификаторов, возвращает количество удаленных приложений
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов приложений"
|
||||
// @Success 200 {object} controller.AppWithToken
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/delete_applications [POST]
|
||||
func DeleteApplications(list []int32) (DeleteResponse, error) {
|
||||
if len(list) == 0 {
|
||||
return DeleteResponse{}, status.Errorf(codes.InvalidArgument, "At least one id are required")
|
||||
@@ -109,6 +166,15 @@ func DeleteApplications(list []int32) (DeleteResponse, error) {
|
||||
return DeleteResponse{Deleted: count}, nil
|
||||
}
|
||||
|
||||
// GetSystemTree godoc
|
||||
// @Tags application
|
||||
// @Summary Метод получения системного дерева
|
||||
// @Description Возвращает описание взаимосвязей сервисов и приложений
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} controller.DomainWithServices
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /application/get_system_tree [POST]
|
||||
func GetSystemTree(md metadata.MD) ([]*DomainWithServices, error) {
|
||||
sysId, err := utils.ResolveMetadataIdentity(utils.SystemIdHeader, md)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"isp-system-service/entity"
|
||||
"isp-system-service/model"
|
||||
|
||||
_ "github.com/integration-system/isp-lib/structure"
|
||||
"github.com/integration-system/isp-lib/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
@@ -18,6 +19,16 @@ import (
|
||||
return res, nil
|
||||
}*/
|
||||
|
||||
// GetDomainsBySystemId godoc
|
||||
// @Tags domain
|
||||
// @Summary Получить домены по идентификатору системы
|
||||
// @Description Возвращает список доменов по системному идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body integer false "Идентификатор системы"
|
||||
// @Success 200 {array} entity.Domain
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /domain/get_domains_by_system_id [POST]
|
||||
func GetDomainsBySystemId(md metadata.MD) ([]entity.Domain, error) {
|
||||
sysId, err := utils.ResolveMetadataIdentity(utils.SystemIdHeader, md)
|
||||
if err != nil {
|
||||
@@ -26,6 +37,16 @@ func GetDomainsBySystemId(md metadata.MD) ([]entity.Domain, error) {
|
||||
return model.DomainRep.GetDomainsBySystemId(int32(sysId))
|
||||
}
|
||||
|
||||
// CreateUpdateDomain godoc
|
||||
// @Tags domain
|
||||
// @Summary Создать/обновить домен
|
||||
// @Description Если домен с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body entity.Domain true "Объект домена"
|
||||
// @Success 200 {object} entity.Domain
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /domain/create_update_domain [POST]
|
||||
func CreateUpdateDomain(domain entity.Domain, md metadata.MD) (*entity.Domain, error) {
|
||||
existed, err := model.DomainRep.GetDomainByNameAndSystemId(domain.Name, domain.SystemId)
|
||||
if err != nil {
|
||||
@@ -67,6 +88,17 @@ func CreateUpdateDomain(domain entity.Domain, md metadata.MD) (*entity.Domain, e
|
||||
}
|
||||
}
|
||||
|
||||
// GetDomainById godoc
|
||||
// @Tags domain
|
||||
// @Summary Получить домен по идентификатору
|
||||
// @Description Возвращает описание домена по его идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор домена"
|
||||
// @Success 200 {object} entity.Domain
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /domain/get_domain_by_id [POST]
|
||||
func GetDomainById(identity Identity) (*entity.Domain, error) {
|
||||
domain, err := model.DomainRep.GetDomainById(identity.Id)
|
||||
if err != nil {
|
||||
@@ -78,6 +110,17 @@ func GetDomainById(identity Identity) (*entity.Domain, error) {
|
||||
return domain, err
|
||||
}
|
||||
|
||||
// DeleteDomains godoc
|
||||
// @Tags domain
|
||||
// @Summary Удаление доменов
|
||||
// @Description Удаляет домены по списку их идентификаторов, возвращает количество удаленных доменов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов доменов"
|
||||
// @Success 200 {object} controller.DeleteResponse
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /domain/delete_domains [POST]
|
||||
func DeleteDomains(list []int32) (DeleteResponse, error) {
|
||||
if len(list) == 0 {
|
||||
return DeleteResponse{Deleted: 0}, status.Errorf(codes.InvalidArgument, "At least one id are required")
|
||||
|
||||
@@ -8,6 +8,16 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// GetService godoc
|
||||
// @Tags service
|
||||
// @Summary Получить список сервисов
|
||||
// @Description Возвращает список сервисов по их идентификаторам
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов сервисов"
|
||||
// @Success 200 {array} entity.Service
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /service/get_service [POST]
|
||||
func GetService(list []int32) ([]entity.Service, error) {
|
||||
res, err := model.ServiceRep.GetServices(list)
|
||||
if err != nil {
|
||||
@@ -16,10 +26,33 @@ func GetService(list []int32) ([]entity.Service, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// GetServicesByDomainId godoc
|
||||
// @Tags service
|
||||
// @Summary Получить список сервисов по идентификатору домена
|
||||
// @Description Возвращает список сервисов по идентификатору домена
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор домена"
|
||||
// @Success 200 {array} entity.Service
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /service/get_services_by_domain_id [POST]
|
||||
func GetServicesByDomainId(identity Identity) ([]entity.Service, error) {
|
||||
return model.ServiceRep.GetServicesByDomainId(identity.Id)
|
||||
}
|
||||
|
||||
// CreateUpdateService godoc
|
||||
// @Tags service
|
||||
// @Summary Создать/обновить сервис
|
||||
// @Description Если сервис с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body entity.Service true "Объект сервиса"
|
||||
// @Success 200 {object} entity.Service
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 409 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /service/create_update_service [POST]
|
||||
func CreateUpdateService(service entity.Service) (*entity.Service, error) {
|
||||
existed, err := model.ServiceRep.GetServiceByNameAndDomainId(service.Name, service.DomainId)
|
||||
if err != nil {
|
||||
@@ -54,6 +87,17 @@ func CreateUpdateService(service entity.Service) (*entity.Service, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetServiceById godoc
|
||||
// @Tags service
|
||||
// @Summary Получить сервис по идентификатору
|
||||
// @Description Возвращает описание сервиса по его идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор сервиса"
|
||||
// @Success 200 {object} entity.Service
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /service/get_service_by_id [POST]
|
||||
func GetServiceById(identity Identity) (*entity.Service, error) {
|
||||
service, err := model.ServiceRep.GetServiceById(identity.Id)
|
||||
if err != nil {
|
||||
@@ -65,6 +109,17 @@ func GetServiceById(identity Identity) (*entity.Service, error) {
|
||||
return service, err
|
||||
}
|
||||
|
||||
// DeleteService godoc
|
||||
// @Tags service
|
||||
// @Summary Удалить сервисы
|
||||
// @Description Удаляет сервисов по списку их идентификаторов, возвращает количество удаленных сервисов
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer true "Массив идентификаторов сервисов"
|
||||
// @Success 200 {object} controller.DeleteResponse
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /service/delete_service [POST]
|
||||
func DeleteService(list []int32) (DeleteResponse, error) {
|
||||
if len(list) == 0 {
|
||||
return DeleteResponse{Deleted: 0}, status.Error(codes.InvalidArgument, "At least one id are required")
|
||||
|
||||
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
_ "github.com/integration-system/isp-lib/structure"
|
||||
"isp-system-service/entity"
|
||||
"isp-system-service/model"
|
||||
|
||||
@@ -10,6 +11,16 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// GetSystems godoc
|
||||
// @Tags system
|
||||
// @Summary Получить список систем
|
||||
// @Description Возвращает список систем по их идентификаторам
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов систем"
|
||||
// @Success 200 {array} entity.System
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /system/get_systems [POST]
|
||||
func GetSystems(list []int32) ([]entity.System, error) {
|
||||
res, err := model.SystemRep.GetSystems(list)
|
||||
if err != nil {
|
||||
@@ -18,6 +29,18 @@ func GetSystems(list []int32) ([]entity.System, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// CreateUpdateSystem godoc
|
||||
// @Tags system
|
||||
// @Summary Создать/обновить систему
|
||||
// @Description Если система с такими идентификатором существует, то обновляет данные, если нет, то добавляет данные в базу
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body entity.System true "Объект системы"
|
||||
// @Success 200 {object} entity.System
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 409 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /system/create_update_system [POST]
|
||||
func CreateUpdateSystem(system entity.System) (*entity.System, error) {
|
||||
existed, err := model.SystemRep.GetSystemByName(system.Name)
|
||||
if err != nil {
|
||||
@@ -45,6 +68,17 @@ func CreateUpdateSystem(system entity.System) (*entity.System, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSystemById godoc
|
||||
// @Tags system
|
||||
// @Summary Получить систему по идентификатору
|
||||
// @Description Возвращает описание системы по ее идентификатору
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор системы"
|
||||
// @Success 200 {object} entity.System
|
||||
// @Failure 404 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /system/get_system_by_id [POST]
|
||||
func GetSystemById(identity Identity) (*entity.System, error) {
|
||||
sys, err := model.SystemRep.GetSystemById(identity.Id)
|
||||
if err != nil {
|
||||
@@ -56,6 +90,17 @@ func GetSystemById(identity Identity) (*entity.System, error) {
|
||||
return sys, err
|
||||
}
|
||||
|
||||
// DeleteSystems godoc
|
||||
// @Tags system
|
||||
// @Summary Удалить системы
|
||||
// @Description Удаляет системы по списку их идентификаторов, возвращает количество удаленных систем
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body []integer false "Массив идентификаторов систем"
|
||||
// @Success 200 {object} controller.DeleteResponse
|
||||
// @Failure 400 {object} structure.GrpcError
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /system/delete_systems [POST]
|
||||
func DeleteSystems(list []int32) (DeleteResponse, error) {
|
||||
if len(list) == 0 {
|
||||
return DeleteResponse{}, status.Error(codes.InvalidArgument, "At least one id are required")
|
||||
|
||||
@@ -31,6 +31,16 @@ type BoolResponse struct {
|
||||
Ok bool
|
||||
}
|
||||
|
||||
// CreateToken godoc
|
||||
// @Tags token
|
||||
// @Summary Создать токен
|
||||
// @Description Созддает токен и привязывает его к приложению
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.CreateTokenRequest true "Объект создания токена"
|
||||
// @Success 200 {object} controller.AppWithToken
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /token/create_token [POST]
|
||||
func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
m, err, app := GetIdMap(req.AppId)
|
||||
if err != nil {
|
||||
@@ -81,6 +91,16 @@ func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
return arr[0], nil
|
||||
}
|
||||
|
||||
// RevokeTokens godoc
|
||||
// @Tags token
|
||||
// @Summary Отозвать токены
|
||||
// @Description Отвязывает токены от приложений и удялет их
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.RevokeTokensRequest true "Объект отзыва токенов"
|
||||
// @Success 200 {object} controller.AppWithToken
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /token/revoke_tokens [POST]
|
||||
func RevokeTokens(req RevokeTokensRequest) (*AppWithToken, error) {
|
||||
app, err := model.AppRep.GetApplicationById(req.AppId)
|
||||
if err != nil {
|
||||
@@ -97,10 +117,30 @@ func RevokeTokens(req RevokeTokensRequest) (*AppWithToken, error) {
|
||||
return res[0], nil
|
||||
}
|
||||
|
||||
// RevokeTokensForApp godoc
|
||||
// @Tags token
|
||||
// @Summary Отозвать токены для приложения
|
||||
// @Description Отвязывает токены от приложений и удаляет их по идентификатору приложения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор приложения"
|
||||
// @Success 200 {object} controller.DeleteResponse
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /token/revoke_tokens_for_app [POST]
|
||||
func RevokeTokensForApp(identity Identity) (*DeleteResponse, error) {
|
||||
return revokeTokensForApp(identity, &model.TokenRep)
|
||||
}
|
||||
|
||||
// GetTokensByAppId godoc
|
||||
// @Tags token
|
||||
// @Summary Получить токены по идентификаотру приложения
|
||||
// @Description Возвращает список токенов, привязанных к приложению
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body controller.Identity true "Идентификатор приложения"
|
||||
// @Success 200 {array} entity.Token
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /token/get_tokens_by_app_id [POST]
|
||||
func GetTokensByAppId(identity Identity) ([]entity.Token, error) {
|
||||
return model.TokenRep.GetTokensByAppId(identity.Id)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,14 @@ var (
|
||||
date = "undefined"
|
||||
)
|
||||
|
||||
// @title ISP system service
|
||||
// @version 1.1.2
|
||||
// @description Сервис управления реестром внешних приложений и токенами аутентификации
|
||||
|
||||
// @license.name GNU GPL v3.0
|
||||
|
||||
// @host localhost:9003
|
||||
// @BasePath /api/system
|
||||
func main() {
|
||||
bootstrap.
|
||||
ServiceBootstrap(&conf.Configuration{}, &conf.RemoteConfig{}).
|
||||
|
||||
Reference in new issue
Block a user