add(document generation)
This commit is contained in:
1 parent
ff84d68b72
commit
9f76e76e55
9 files changed
+279
-20
No files matched your search
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user