Compare commits
No commits in common. "main" and "v0.1.5" have entirely different histories.
29 changed files with 147 additions and 755 deletions
51
docs/docs.go
51
docs/docs.go
|
|
@ -319,23 +319,31 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"/merch/labels/{uuid}": {
|
"/merch/labels/{uuid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Получить персональные данные. Запрос данных по gRPC у сервиса авторизации.",
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить метки товара по его uuid",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"User"
|
"Merch labels"
|
||||||
|
],
|
||||||
|
"summary": "Получить метки товара по его uuid",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "label uuid",
|
||||||
|
"name": "uuid",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"summary": "Получить персональные данные.",
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK"
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/common.PersonalDTO"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"204": {
|
|
||||||
"description": "No Content"
|
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
|
|
@ -881,6 +889,9 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "Marks merch and all its extra data as deleted by uuid.",
|
"description": "Marks merch and all its extra data as deleted by uuid.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1103,26 +1114,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"common.PersonalDTO": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"email": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"surname": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"username": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.DeleteZeroPrices": {
|
"merch.DeleteZeroPrices": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -312,23 +312,31 @@
|
||||||
},
|
},
|
||||||
"/merch/labels/{uuid}": {
|
"/merch/labels/{uuid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Получить персональные данные. Запрос данных по gRPC у сервиса авторизации.",
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Получить метки товара по его uuid",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"User"
|
"Merch labels"
|
||||||
|
],
|
||||||
|
"summary": "Получить метки товара по его uuid",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "label uuid",
|
||||||
|
"name": "uuid",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"summary": "Получить персональные данные.",
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK"
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/common.PersonalDTO"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"204": {
|
|
||||||
"description": "No Content"
|
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
|
|
@ -874,6 +882,9 @@
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "Marks merch and all its extra data as deleted by uuid.",
|
"description": "Marks merch and all its extra data as deleted by uuid.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch"
|
"Merch"
|
||||||
],
|
],
|
||||||
|
|
@ -1096,26 +1107,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"common.PersonalDTO": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"email": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"surname": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"username": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.DeleteZeroPrices": {
|
"merch.DeleteZeroPrices": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,5 @@
|
||||||
basePath: /api/v2
|
basePath: /api/v2
|
||||||
definitions:
|
definitions:
|
||||||
common.PersonalDTO:
|
|
||||||
properties:
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
surname:
|
|
||||||
type: string
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
uuid:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.DeleteZeroPrices:
|
merch.DeleteZeroPrices:
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
|
|
@ -213,6 +200,8 @@ info:
|
||||||
paths:
|
paths:
|
||||||
/merch/{uuid}:
|
/merch/{uuid}:
|
||||||
delete:
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
description: Marks merch and all its extra data as deleted by uuid.
|
description: Marks merch and all its extra data as deleted by uuid.
|
||||||
parameters:
|
parameters:
|
||||||
- description: merch uuid
|
- description: merch uuid
|
||||||
|
|
@ -467,16 +456,18 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Merch labels
|
- Merch labels
|
||||||
get:
|
get:
|
||||||
description: Получить персональные данные. Запрос данных по gRPC у сервиса авторизации.
|
description: Получить метки товара по его uuid
|
||||||
|
parameters:
|
||||||
|
- description: label uuid
|
||||||
|
in: path
|
||||||
|
name: uuid
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/common.PersonalDTO'
|
|
||||||
"204":
|
|
||||||
description: No Content
|
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
|
|
@ -489,9 +480,11 @@ paths:
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/responses.InternalServerError'
|
$ref: '#/definitions/responses.InternalServerError'
|
||||||
summary: Получить персональные данные.
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Получить метки товара по его uuid
|
||||||
tags:
|
tags:
|
||||||
- User
|
- Merch labels
|
||||||
put:
|
put:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
|
|
|
||||||
|
|
@ -58,14 +58,12 @@ func New(ctx context.Context, cfg config.Config) *App {
|
||||||
sessionCheckProvider := authCheck.New(authCheck.Deps{
|
sessionCheckProvider := authCheck.New(authCheck.Deps{
|
||||||
Addr: net.JoinHostPort(cfg.Auth.Host, cfg.Auth.Port),
|
Addr: net.JoinHostPort(cfg.Auth.Host, cfg.Auth.Port),
|
||||||
Timeout: cfg.Auth.Timeout,
|
Timeout: cfg.Auth.Timeout,
|
||||||
ServiceId: serviceId,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//providers with deps
|
//providers with deps
|
||||||
userProv := user.New(user.Deps{
|
userProv := user.New(user.Deps{
|
||||||
DB: dbPool,
|
DB: dbPool,
|
||||||
Utils: u,
|
Utils: u,
|
||||||
AuthDP: sessionCheckProvider,
|
|
||||||
})
|
})
|
||||||
newApp.modules = append(newApp.modules, userProv)
|
newApp.modules = append(newApp.modules, userProv)
|
||||||
|
|
||||||
|
|
@ -76,6 +74,7 @@ func New(ctx context.Context, cfg config.Config) *App {
|
||||||
GinMode: cfg.Http.GinMode,
|
GinMode: cfg.Http.GinMode,
|
||||||
UserProvider: userProv,
|
UserProvider: userProv,
|
||||||
AuthProvider: sessionCheckProvider,
|
AuthProvider: sessionCheckProvider,
|
||||||
|
ServiceId: serviceId,
|
||||||
})
|
})
|
||||||
|
|
||||||
m := merch.New(merch.Deps{
|
m := merch.New(merch.Deps{
|
||||||
|
|
@ -85,8 +84,7 @@ func New(ctx context.Context, cfg config.Config) *App {
|
||||||
newApp.modules = append(newApp.modules, m)
|
newApp.modules = append(newApp.modules, m)
|
||||||
|
|
||||||
newApp.tasker = task.New(task.Deps{
|
newApp.tasker = task.New(task.Deps{
|
||||||
Host: cfg.TasksSource.Host,
|
Addr: "",
|
||||||
Port: cfg.TasksSource.Port,
|
|
||||||
MerchProvider: m,
|
MerchProvider: m,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,20 +52,11 @@ func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
||||||
errVal = fmt.Sprintf("%v\n", errVal)
|
errVal = fmt.Sprintf("%v\n", errVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldsLine := "\n"
|
|
||||||
fields := entry.Data
|
|
||||||
if len(fields) > 0 {
|
|
||||||
fieldsLine = "| params: "
|
|
||||||
for key, val := range fields {
|
|
||||||
fieldsLine += fmt.Sprintf("\t%v=%v ", key, val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cyanCode := f.getLevelColor(logrus.TraceLevel)
|
cyanCode := f.getLevelColor(logrus.TraceLevel)
|
||||||
filename := fmt.Sprintf("%s[%s:%d]%s", cyanCode, file, line, resetCode)
|
filename := fmt.Sprintf("%s[%s:%d]%s", cyanCode, file, line, resetCode)
|
||||||
|
|
||||||
logLine := fmt.Sprintf("%s[%s]%v %s\t%v %v",
|
logLine := fmt.Sprintf("%s[%s]%v %s\t%v",
|
||||||
coloredLevel, timestamp, filename, msg, fieldsLine, errVal)
|
coloredLevel, timestamp, filename, msg, errVal)
|
||||||
|
|
||||||
return []byte(logLine), nil
|
return []byte(logLine), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,3 @@ type MerchProvider interface {
|
||||||
GetTasks(ctx context.Context) ([]Task, error)
|
GetTasks(ctx context.Context) ([]Task, error)
|
||||||
InsertPrices(ctx context.Context, rawPrices []Result) error
|
InsertPrices(ctx context.Context, rawPrices []Result) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthDataProvider interface {
|
|
||||||
GetPersonalData(ctx context.Context, userUuid string) (*PersonalDTO, error)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,3 @@ type Result struct {
|
||||||
OriginName string
|
OriginName string
|
||||||
Price int32
|
Price int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type PersonalDTO struct {
|
|
||||||
Uuid string `json:"uuid"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Surname string `json:"surname"`
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ func (co *controller) updateExtraData(c *gin.Context) {
|
||||||
// @Summary Delete merch
|
// @Summary Delete merch
|
||||||
// @Description Marks merch and all its extra data as deleted by uuid.
|
// @Description Marks merch and all its extra data as deleted by uuid.
|
||||||
// @Tags Merch
|
// @Tags Merch
|
||||||
|
// @Accept json
|
||||||
// @Param uuid path string true "merch uuid"
|
// @Param uuid path string true "merch uuid"
|
||||||
// @Success 204
|
// @Success 204
|
||||||
// @Failure 400 {object} responses.BadRequest
|
// @Failure 400 {object} responses.BadRequest
|
||||||
|
|
@ -380,7 +381,6 @@ func (co *controller) getChartsPrices(c *gin.Context) {
|
||||||
logErr(controllerLogHeader, err)
|
logErr(controllerLogHeader, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.WithField("response", response).Debugf("%v %v get chart prices success", pkgLogHeader, controllerLogHeader)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +419,6 @@ func (co *controller) getDistinctPrices(c *gin.Context) {
|
||||||
c.Status(http.StatusNoContent)
|
c.Status(http.StatusNoContent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.WithField("response", response).Debugf("%v %v get distinct prices success", pkgLogHeader, controllerLogHeader)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package merch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"merch-api/internal/common"
|
"merch-api/internal/common"
|
||||||
"merch-api/pkg/utils"
|
"merch-api/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
@ -31,7 +30,6 @@ func (p *provider) GetTasks(ctx context.Context) ([]common.Task, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *provider) InsertPrices(ctx context.Context, rawPrices []common.Result) error {
|
func (p *provider) InsertPrices(ctx context.Context, rawPrices []common.Result) error {
|
||||||
log.WithField("payload", rawPrices).Debugf("%v Inserting prices", providerLogHeader)
|
|
||||||
if rawPrices == nil || len(rawPrices) == 0 {
|
if rawPrices == nil || len(rawPrices) == 0 {
|
||||||
logDebug(providerLogHeader, "no prices given")
|
logDebug(providerLogHeader, "no prices given")
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -58,13 +56,15 @@ func (p *provider) InsertPrices(ctx context.Context, rawPrices []common.Result)
|
||||||
var insertPrices []Price
|
var insertPrices []Price
|
||||||
for _, rawPrice := range rawPrices {
|
for _, rawPrice := range rawPrices {
|
||||||
insertPrices = append(insertPrices, Price{
|
insertPrices = append(insertPrices, Price{
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: p.utils.NullTimeFromNow(now),
|
||||||
MerchId: uuidMap[rawPrice.MerchUuid],
|
MerchId: uuidMap[rawPrice.MerchUuid],
|
||||||
OriginId: originIds[rawPrice.OriginName],
|
OriginId: originIds[rawPrice.OriginName],
|
||||||
Price: int(rawPrice.Price),
|
Price: int(rawPrice.Price),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.service.repo.insertPrices(ctx, now, p.utils.NullTimeFromNow(now), insertPrices); err != nil {
|
if err = p.service.repo.insertPrices(ctx, insertPrices); err != nil {
|
||||||
logErr(serviceLogHeader, err)
|
logErr(serviceLogHeader, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ func (r *repo) getMerchUuidMap(ctx context.Context, merchUuids []string) (map[st
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
merchUuidMap := make(map[string]int64)
|
var merchUuidMap map[string]int64
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
uuid string
|
uuid string
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Prices interface {
|
type Prices interface {
|
||||||
insertPrices(ctx context.Context, now time.Time, updatedAt sql.NullTime, prices []Price) error
|
insertPrices(ctx context.Context, prices []Price) error
|
||||||
getPricesWithDays(ctx context.Context, userId int64, days time.Time) ([]Price, error)
|
getPricesWithDays(ctx context.Context, userId int64, days time.Time) ([]Price, error)
|
||||||
getDistinctPrices(ctx context.Context, userId int64, merchUuid string, days time.Time) ([]Price, error)
|
getDistinctPrices(ctx context.Context, userId int64, merchUuid string, days time.Time) ([]Price, error)
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ type Prices interface {
|
||||||
deleteZeroPrices(ctx context.Context, userId int64, now sql.NullTime, list []int64) error
|
deleteZeroPrices(ctx context.Context, userId int64, now sql.NullTime, list []int64) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repo) insertPrices(ctx context.Context, now time.Time, updatedAt sql.NullTime, prices []Price) error {
|
func (r *repo) insertPrices(ctx context.Context, prices []Price) error {
|
||||||
q := `
|
q := `
|
||||||
INSERT INTO merch_prices (created_at, updated_at, merch_id, origin_id, price)
|
INSERT INTO merch_prices (created_at, updated_at, merch_id, origin_id, price)
|
||||||
SELECT $1, $2, src.merch_id, src.origin_id, src.price
|
SELECT $1, $2, src.merch_id, src.origin_id, src.price
|
||||||
|
|
@ -40,7 +40,7 @@ func (r *repo) insertPrices(ctx context.Context, now time.Time, updatedAt sql.Nu
|
||||||
priceValues = append(priceValues, price.Price)
|
priceValues = append(priceValues, price.Price)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := r.db.Exec(ctx, q, now, updatedAt, merchIds, originIds, priceValues)
|
_, err := r.db.Exec(ctx, q, merchIds, originIds, priceValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -127,14 +127,14 @@ func (r *repo) getZeroPrices(ctx context.Context, userId int64) ([]ZeroPrice, er
|
||||||
q := `
|
q := `
|
||||||
WITH price_with_neighbors AS (
|
WITH price_with_neighbors AS (
|
||||||
SELECT
|
SELECT
|
||||||
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name, m.merch_uuid,
|
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name,
|
||||||
LAG(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS prev_price,
|
LAG(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS prev_price,
|
||||||
LEAD(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS next_price
|
LEAD(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS next_price
|
||||||
FROM merch_prices AS p
|
FROM merch_prices AS p
|
||||||
JOIN merch as m ON m.id = p.merch_id
|
JOIN merch as m ON m.id = p.merch_id
|
||||||
WHERE p.deleted_at IS NULL
|
WHERE p.deleted_at IS NULL
|
||||||
AND m.deleted_at IS NULL
|
AND m.deleted_at IS NULL
|
||||||
AND m.user_id = $1)
|
AND m.user_id = 3)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
pwn.id, pwn.created_at, pwn.merch_uuid, pwn.name, mo.name
|
pwn.id, pwn.created_at, pwn.merch_uuid, pwn.name, mo.name
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@ package merch
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *service) getPrices(ctx context.Context, userId int64, days int) ([]PricesResponse, error) {
|
func (s *service) getPrices(ctx context.Context, userId int64, days int) ([]PricesResponse, error) {
|
||||||
|
fmt.Println("Enter service")
|
||||||
merchList, err := s.repo.getAllUserMerch(ctx, userId)
|
merchList, err := s.repo.getAllUserMerch(ctx, userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logErr(serviceLogHeader, err)
|
logErr(serviceLogHeader, err)
|
||||||
|
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
package merch
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/mock"
|
|
||||||
"merch-api/pkg/utils"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test_service_getPrices(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
repo Repository
|
|
||||||
utils utils.Utils
|
|
||||||
}
|
|
||||||
type args struct {
|
|
||||||
ctx context.Context
|
|
||||||
userId int64
|
|
||||||
days int
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
args args
|
|
||||||
want []PricesResponse
|
|
||||||
wantErr assert.ErrorAssertionFunc
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
{name: "success",
|
|
||||||
fields: fields{
|
|
||||||
repo: nil,
|
|
||||||
utils: utils.New(),
|
|
||||||
},
|
|
||||||
args: args{
|
|
||||||
ctx: context.Background(),
|
|
||||||
userId: 4,
|
|
||||||
days: 180,
|
|
||||||
},
|
|
||||||
want: []PricesResponse{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
mockMerch := []Merch{
|
|
||||||
{Id: 1532, MerchUuid: "019cd7f4-e491-7dd5-a327-ea0b4c3800d6", Name: "Momo (darkness ver.)"},
|
|
||||||
{Id: 1534, MerchUuid: "019cd7f4-e491-7dd7-a81f-1160db34da2d", Name: "Sairenji Haruna 1/4"},
|
|
||||||
}
|
|
||||||
|
|
||||||
mockPrices := []Price{
|
|
||||||
{CreatedAt: timeFromString("2026-02-01 15:43:25.375677+00"), MerchId: 1532, Price: 1231, OriginId: 2},
|
|
||||||
{CreatedAt: timeFromString("2026-02-02 15:43:25.375677+00"), MerchId: 1532, Price: 1232, OriginId: 2},
|
|
||||||
{CreatedAt: timeFromString("2026-02-03 15:43:25.375677+00"), MerchId: 1532, Price: 1233, OriginId: 2},
|
|
||||||
{CreatedAt: timeFromString("2026-02-04 15:43:25.375677+00"), MerchId: 1532, Price: 1234, OriginId: 2},
|
|
||||||
{CreatedAt: timeFromString("2026-02-05 15:43:25.375677+00"), MerchId: 1532, Price: 1235, OriginId: 2},
|
|
||||||
{CreatedAt: timeFromString("2026-02-06 15:43:25.375677+00"), MerchId: 1532, Price: 1231, OriginId: 2},
|
|
||||||
//
|
|
||||||
{CreatedAt: timeFromString("2026-02-01 15:43:25.375677+00"), MerchId: 1534, Price: 5231, OriginId: 1},
|
|
||||||
{CreatedAt: timeFromString("2026-02-02 15:43:25.375677+00"), MerchId: 1534, Price: 5232, OriginId: 1},
|
|
||||||
{CreatedAt: timeFromString("2026-02-03 15:43:25.375677+00"), MerchId: 1534, Price: 5233, OriginId: 1},
|
|
||||||
{CreatedAt: timeFromString("2026-02-04 15:43:25.375677+00"), MerchId: 1534, Price: 5234, OriginId: 1},
|
|
||||||
{CreatedAt: timeFromString("2026-02-05 15:43:25.375677+00"), MerchId: 1534, Price: 5235, OriginId: 1},
|
|
||||||
{CreatedAt: timeFromString("2026-02-06 15:43:25.375677+00"), MerchId: 1534, Price: 5231, OriginId: 1},
|
|
||||||
}
|
|
||||||
|
|
||||||
mockOrigins := []Origin{
|
|
||||||
{Id: 1, Name: "surugaya"},
|
|
||||||
{Id: 2, Name: "mandarake"},
|
|
||||||
}
|
|
||||||
|
|
||||||
mockRepo := new(MockRepository)
|
|
||||||
mockRepo.On("getAllUserMerch", mock.Anything, tt.args.userId).Return(mockMerch, nil)
|
|
||||||
|
|
||||||
mockRepo.On("getPricesWithDays", mock.Anything, tt.args.userId, mock.Anything).Return(mockPrices, nil)
|
|
||||||
mockRepo.On("getOrigins", mock.Anything).Return(mockOrigins, nil)
|
|
||||||
|
|
||||||
s := &service{
|
|
||||||
repo: mockRepo,
|
|
||||||
utils: tt.fields.utils,
|
|
||||||
}
|
|
||||||
got, _ := s.getPrices(tt.args.ctx, tt.args.userId, tt.args.days)
|
|
||||||
//if !tt.wantErr(t, err, fmt.Sprintf("getPrices(%v, %v, %v)", tt.args.ctx, tt.args.userId, tt.args.days)) {
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
for _, item := range got {
|
|
||||||
fmt.Printf("name: %v, merch_uuid: %v, origins: %v\n", item.Name, item.MerchUuid, item.Origins)
|
|
||||||
}
|
|
||||||
//assert.Equalf(t, tt.want, got, "getPrices(%v, %v, %v)", tt.args.ctx, tt.args.userId, tt.args.days)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func timeFromString(s string) time.Time {
|
|
||||||
t, _ := time.Parse("2006-01-02 15:04:05", s)
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
@ -17,8 +17,7 @@ type Handler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Host string
|
Addr string
|
||||||
Port string
|
|
||||||
MerchProvider common.MerchProvider
|
MerchProvider common.MerchProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +25,7 @@ func New(deps Deps) *Handler {
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
|
|
||||||
handler := &Handler{
|
handler := &Handler{
|
||||||
addr: net.JoinHostPort(deps.Host, deps.Port),
|
addr: deps.Addr,
|
||||||
service: newService(deps.MerchProvider),
|
service: newService(deps.MerchProvider),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +36,6 @@ func New(deps Deps) *Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) Serve() error {
|
func (h *Handler) Serve() error {
|
||||||
log.WithField("addr", h.addr).Debugf("%v Serving tasks", pkgLogHeader)
|
|
||||||
listener, err := net.Listen("tcp", h.addr)
|
listener, err := net.Listen("tcp", h.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("%v Listner failure", pkgLogHeader)
|
log.WithError(err).Errorf("%v Listner failure", pkgLogHeader)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"io"
|
"io"
|
||||||
"merch-api/internal/common"
|
"merch-api/internal/common"
|
||||||
tt "merch-api/pkg/taskTransport/v1"
|
tt "merch-api/pkg/taskTransport/v1"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -23,12 +21,9 @@ func newService(mp common.MerchProvider) *service {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) RequestTasks(_ *emptypb.Empty, stream tt.TaskProcessor_RequestTasksServer) error {
|
func (s *service) RequestTasks(_ *emptypb.Empty, stream tt.TaskProcessor_RequestTasksServer) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
tasks, err := s.merchProvider.GetTasks(stream.Context())
|
||||||
|
|
||||||
tasks, err := s.merchProvider.GetTasks(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("%v Failed to get tasks", pkgLogHeader)
|
log.WithError(err).Errorf("%v Failed to get tasks", pkgLogHeader)
|
||||||
cancel()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,49 +33,34 @@ func (s *service) RequestTasks(_ *emptypb.Empty, stream tt.TaskProcessor_Request
|
||||||
Origins: task.Origins,
|
Origins: task.Origins,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.WithError(err).Errorf("%v Failed to send tasks", pkgLogHeader)
|
log.WithError(err).Errorf("%v Failed to send tasks", pkgLogHeader)
|
||||||
cancel()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancel()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) SendResults(stream tt.TaskProcessor_SendResultsServer) error {
|
func (s *service) SendResults(stream tt.TaskProcessor_SendResultsServer) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
|
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
mu := &sync.Mutex{}
|
|
||||||
batch := make([]common.Result, 0)
|
batch := make([]common.Result, 0)
|
||||||
|
done := make(chan struct{})
|
||||||
stop := make(chan struct{})
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
wg.Add(1)
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-done:
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
mu.Lock()
|
if len(batch) > 0 {
|
||||||
if len(batch) == 0 {
|
err := s.merchProvider.InsertPrices(stream.Context(), batch)
|
||||||
mu.Unlock()
|
if err != nil {
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
toInsert := make([]common.Result, len(batch))
|
|
||||||
copy(toInsert, batch)
|
|
||||||
batch = batch[:0]
|
|
||||||
mu.Unlock()
|
|
||||||
|
|
||||||
if err := s.merchProvider.InsertPrices(ctx, toInsert); err != nil {
|
|
||||||
log.WithError(err).Errorf("%v Failed to batch insert result", pkgLogHeader)
|
log.WithError(err).Errorf("%v Failed to batch insert result", pkgLogHeader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
@ -92,36 +72,28 @@ func (s *service) SendResults(stream tt.TaskProcessor_SendResultsServer) error {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("%v Failed to receive", pkgLogHeader)
|
log.WithError(err).Errorf("%v Failed to receive", pkgLogHeader)
|
||||||
cancel()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mu.Lock()
|
|
||||||
batch = append(batch, common.Result{
|
batch = append(batch, common.Result{
|
||||||
MerchUuid: response.MerchUuid,
|
MerchUuid: response.MerchUuid,
|
||||||
OriginName: response.OriginName,
|
OriginName: response.OriginName,
|
||||||
Price: response.Price,
|
Price: response.Price,
|
||||||
})
|
})
|
||||||
mu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(stop)
|
close(done)
|
||||||
wg.Wait()
|
if len(batch) > 0 {
|
||||||
|
err := s.merchProvider.InsertPrices(stream.Context(), batch)
|
||||||
mu.Lock()
|
|
||||||
finalBatch := make([]common.Result, len(batch))
|
|
||||||
copy(finalBatch, batch)
|
|
||||||
mu.Unlock()
|
|
||||||
|
|
||||||
if len(finalBatch) > 0 {
|
|
||||||
err := s.merchProvider.InsertPrices(ctx, finalBatch)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("%v Failed to batch insert last data", pkgLogHeader)
|
log.WithError(err).Errorf("%v Failed to batch insert last data", pkgLogHeader)
|
||||||
cancel()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel()
|
if err := stream.SendAndClose(&emptypb.Empty{}); err != nil {
|
||||||
return stream.SendAndClose(&emptypb.Empty{})
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,7 @@ func (h *Handler) RegisterRoutes(r *gin.RouterGroup, mw *router.Middlewares) {
|
||||||
|
|
||||||
userGroup.POST("", mw.RegMW, h.controller.create)
|
userGroup.POST("", mw.RegMW, h.controller.create)
|
||||||
userGroup.DELETE("", mw.AuthMW, h.controller.delete)
|
userGroup.DELETE("", mw.AuthMW, h.controller.delete)
|
||||||
userGroup.GET("/me", mw.AuthMW, h.controller.me)
|
userGroup.GET("/me", h.controller.me)
|
||||||
userGroup.GET("/personal", mw.AuthMW, h.controller.getPersonalData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create godoc
|
// create godoc
|
||||||
|
|
@ -122,38 +121,3 @@ func (co *controller) me(c *gin.Context) {
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPersonalData godoc
|
|
||||||
//
|
|
||||||
// @Summary Получить персональные данные.
|
|
||||||
// @Description Получить персональные данные. Запрос данных по gRPC у сервиса авторизации.
|
|
||||||
// @Tags User
|
|
||||||
// @Produce json
|
|
||||||
// @Success 200 {object} common.PersonalDTO
|
|
||||||
// @Success 204
|
|
||||||
// @Failure 400 {object} responses.BadRequest
|
|
||||||
// @Failure 401 {object} responses.Unauthorized
|
|
||||||
// @Failure 500 {object} responses.InternalServerError
|
|
||||||
// @Router /merch/labels/{uuid} [get]
|
|
||||||
func (co *controller) getPersonalData(c *gin.Context) {
|
|
||||||
u, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, responses.BadRequest{Error: err.Error()})
|
|
||||||
appLog.LogErr(pkgLogHeader, controllerLogHeader, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := co.service.getPersonalData(c, u)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.InternalServerError{Error: err.Error()})
|
|
||||||
appLog.LogErr(pkgLogHeader, controllerLogHeader, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if response == nil {
|
|
||||||
c.Status(http.StatusNoContent)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, response)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
"merch-api/internal/common"
|
|
||||||
"merch-api/pkg/utils"
|
"merch-api/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -16,12 +15,11 @@ type Handler struct {
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
DB *pgxpool.Pool
|
DB *pgxpool.Pool
|
||||||
Utils utils.Utils
|
Utils utils.Utils
|
||||||
AuthDP common.AuthDataProvider
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(deps Deps) *Handler {
|
func New(deps Deps) *Handler {
|
||||||
r := newRepository(deps.DB)
|
r := newRepository(deps.DB)
|
||||||
s := newService(r, deps.Utils, deps.AuthDP)
|
s := newService(r, deps.Utils)
|
||||||
c := newController(s, deps.Utils)
|
c := newController(s, deps.Utils)
|
||||||
|
|
||||||
return &Handler{
|
return &Handler{
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,18 @@ package user
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"merch-api/internal/common"
|
|
||||||
"merch-api/pkg/utils"
|
"merch-api/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const serviceLogHeader string = "service |"
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
repo Repository
|
repo Repository
|
||||||
utils utils.Utils
|
utils utils.Utils
|
||||||
authDP common.AuthDataProvider
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newService(repo Repository, utils utils.Utils, adp common.AuthDataProvider) *service {
|
func newService(repo Repository, utils utils.Utils) *service {
|
||||||
return &service{
|
return &service{
|
||||||
repo: repo,
|
repo: repo,
|
||||||
utils: utils,
|
utils: utils,
|
||||||
authDP: adp,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,12 +48,3 @@ func (s *service) getUser(ctx context.Context, userUuid string) (*MeDTO, error)
|
||||||
|
|
||||||
return s.repo.getUser(ctx, userUuid)
|
return s.repo.getUser(ctx, userUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) getPersonalData(ctx context.Context, userUuid string) (*common.PersonalDTO, error) {
|
|
||||||
if userUuid == "" {
|
|
||||||
return nil, errors.New("user uuid is empty")
|
|
||||||
}
|
|
||||||
log.WithField("user_uuid", userUuid).Debugf("%v %v get personal data", pkgLogHeader, serviceLogHeader)
|
|
||||||
|
|
||||||
return s.authDP.GetPersonalData(ctx, userUuid)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ type Handler struct {
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Addr string
|
Addr string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
ServiceId int32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(deps Deps) *Handler {
|
func New(deps Deps) *Handler {
|
||||||
|
|
@ -36,6 +35,6 @@ func New(deps Deps) *Handler {
|
||||||
|
|
||||||
return &Handler{
|
return &Handler{
|
||||||
client: client,
|
client: client,
|
||||||
service: newService(client, deps.Timeout, deps.ServiceId),
|
service: newService(client, deps.Timeout),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,35 +3,29 @@ package authCheck
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"merch-api/internal/common"
|
|
||||||
verifyV1 "merch-api/pkg/verify/v1"
|
verifyV1 "merch-api/pkg/verify/v1"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const serviceLogHeader = "service |"
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
client verifyV1.AuthServiceClient
|
client verifyV1.AuthServiceClient
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
serviceId int32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newService(c verifyV1.AuthServiceClient, timeout time.Duration, sid int32) *service {
|
func newService(c verifyV1.AuthServiceClient, timeout time.Duration) *service {
|
||||||
return &service{
|
return &service{
|
||||||
client: c,
|
client: c,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
serviceId: sid,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) VerifySession(ctx context.Context, sessionUuid string) (string, error) {
|
func (s *service) VerifySession(ctx context.Context, sessionUuid string, serviceId int32) (string, error) {
|
||||||
runCtx, cancel := context.WithTimeout(ctx, s.timeout)
|
runCtx, cancel := context.WithTimeout(ctx, s.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
response, err := s.client.VerifyToken(runCtx, &verifyV1.VerifyTokenRequest{
|
response, err := s.client.VerifyToken(runCtx, &verifyV1.VerifyTokenRequest{
|
||||||
SessionToken: sessionUuid,
|
SessionToken: sessionUuid,
|
||||||
ServiceId: s.serviceId,
|
ServiceId: serviceId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
@ -47,33 +41,3 @@ func (s *service) VerifySession(ctx context.Context, sessionUuid string) (string
|
||||||
|
|
||||||
return response.UserUuid, nil
|
return response.UserUuid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) GetPersonalData(ctx context.Context, userUuid string) (*common.PersonalDTO, error) {
|
|
||||||
runCtx, cancel := context.WithTimeout(ctx, s.timeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"userUuid": userUuid,
|
|
||||||
"serviceId": s.serviceId,
|
|
||||||
}).Debugf("%v %v get personal data")
|
|
||||||
|
|
||||||
response, err := s.client.GetPersonalInfo(runCtx, &verifyV1.PersonalRequest{
|
|
||||||
UserUuid: userUuid,
|
|
||||||
ServiceId: s.serviceId,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if response == nil {
|
|
||||||
return nil, errors.New("no data")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &common.PersonalDTO{
|
|
||||||
Uuid: userUuid,
|
|
||||||
Email: response.Email,
|
|
||||||
Username: response.Username,
|
|
||||||
Name: response.Name,
|
|
||||||
Surname: response.Surname,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ package externalRegV1
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
unsafe "unsafe"
|
||||||
|
|
@ -30,7 +29,6 @@ type RegistrationRequest struct {
|
||||||
ServiceEndCode int32 `protobuf:"varint,4,opt,name=service_end_code,json=serviceEndCode,proto3" json:"service_end_code,omitempty"`
|
ServiceEndCode int32 `protobuf:"varint,4,opt,name=service_end_code,json=serviceEndCode,proto3" json:"service_end_code,omitempty"`
|
||||||
Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"`
|
Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"`
|
||||||
Status string `protobuf:"bytes,6,opt,name=status,proto3" json:"status,omitempty"`
|
Status string `protobuf:"bytes,6,opt,name=status,proto3" json:"status,omitempty"`
|
||||||
ServiceUrl string `protobuf:"bytes,7,opt,name=service_url,json=serviceUrl,proto3" json:"service_url,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
|
|
@ -107,18 +105,10 @@ func (x *RegistrationRequest) GetStatus() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RegistrationRequest) GetServiceUrl() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceUrl
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegistrationResponse struct {
|
type RegistrationResponse struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
ServiceId int32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"`
|
ServiceId int32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"`
|
||||||
AlreadyRegistered bool `protobuf:"varint,2,opt,name=already_registered,json=alreadyRegistered,proto3" json:"already_registered,omitempty"`
|
AlreadyRegistered bool `protobuf:"varint,2,opt,name=already_registered,json=alreadyRegistered,proto3" json:"already_registered,omitempty"`
|
||||||
ServiceUrl string `protobuf:"bytes,3,opt,name=service_url,json=serviceUrl,proto3" json:"service_url,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
|
|
@ -167,119 +157,24 @@ func (x *RegistrationResponse) GetAlreadyRegistered() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RegistrationResponse) GetServiceUrl() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceUrl
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
|
||||||
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
|
|
||||||
Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
|
|
||||||
ServiceUrl string `protobuf:"bytes,4,opt,name=service_url,json=serviceUrl,proto3" json:"service_url,omitempty"`
|
|
||||||
ServiceCode int32 `protobuf:"varint,5,opt,name=service_code,json=serviceCode,proto3" json:"service_code,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) Reset() {
|
|
||||||
*x = UpdateRequest{}
|
|
||||||
mi := &file_proto_serviceRegistration_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UpdateRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_proto_serviceRegistration_proto_msgTypes[2]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use UpdateRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*UpdateRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_proto_serviceRegistration_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) GetName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Name
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) GetDescription() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Description
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) GetStatus() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Status
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) GetServiceUrl() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceUrl
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UpdateRequest) GetServiceCode() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceCode
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_proto_serviceRegistration_proto protoreflect.FileDescriptor
|
var File_proto_serviceRegistration_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_proto_serviceRegistration_proto_rawDesc = "" +
|
const file_proto_serviceRegistration_proto_rawDesc = "" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\x1fproto/serviceRegistration.proto\x12\x11auth.registration\x1a\x1bgoogle/protobuf/empty.proto\"\xe9\x01\n" +
|
"\x1fproto/serviceRegistration.proto\x12\x11auth.registration\"\xc8\x01\n" +
|
||||||
"\x13RegistrationRequest\x12\x12\n" +
|
"\x13RegistrationRequest\x12\x12\n" +
|
||||||
"\x04name\x18\x01 \x01(\tR\x04name\x12 \n" +
|
"\x04name\x18\x01 \x01(\tR\x04name\x12 \n" +
|
||||||
"\vdescription\x18\x02 \x01(\tR\vdescription\x12!\n" +
|
"\vdescription\x18\x02 \x01(\tR\vdescription\x12!\n" +
|
||||||
"\fservice_code\x18\x03 \x01(\x05R\vserviceCode\x12(\n" +
|
"\fservice_code\x18\x03 \x01(\x05R\vserviceCode\x12(\n" +
|
||||||
"\x10service_end_code\x18\x04 \x01(\x05R\x0eserviceEndCode\x12\x16\n" +
|
"\x10service_end_code\x18\x04 \x01(\x05R\x0eserviceEndCode\x12\x16\n" +
|
||||||
"\x06secret\x18\x05 \x01(\tR\x06secret\x12\x16\n" +
|
"\x06secret\x18\x05 \x01(\tR\x06secret\x12\x16\n" +
|
||||||
"\x06status\x18\x06 \x01(\tR\x06status\x12\x1f\n" +
|
"\x06status\x18\x06 \x01(\tR\x06status\"d\n" +
|
||||||
"\vservice_url\x18\a \x01(\tR\n" +
|
|
||||||
"serviceUrl\"\x85\x01\n" +
|
|
||||||
"\x14RegistrationResponse\x12\x1d\n" +
|
"\x14RegistrationResponse\x12\x1d\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"service_id\x18\x01 \x01(\x05R\tserviceId\x12-\n" +
|
"service_id\x18\x01 \x01(\x05R\tserviceId\x12-\n" +
|
||||||
"\x12already_registered\x18\x02 \x01(\bR\x11alreadyRegistered\x12\x1f\n" +
|
"\x12already_registered\x18\x02 \x01(\bR\x11alreadyRegistered2\x81\x01\n" +
|
||||||
"\vservice_url\x18\x03 \x01(\tR\n" +
|
|
||||||
"serviceUrl\"\xa1\x01\n" +
|
|
||||||
"\rUpdateRequest\x12\x12\n" +
|
|
||||||
"\x04name\x18\x01 \x01(\tR\x04name\x12 \n" +
|
|
||||||
"\vdescription\x18\x02 \x01(\tR\vdescription\x12\x16\n" +
|
|
||||||
"\x06status\x18\x03 \x01(\tR\x06status\x12\x1f\n" +
|
|
||||||
"\vservice_url\x18\x04 \x01(\tR\n" +
|
|
||||||
"serviceUrl\x12!\n" +
|
|
||||||
"\fservice_code\x18\x05 \x01(\x05R\vserviceCode2\xc5\x01\n" +
|
|
||||||
"\x14ExternalRegistration\x12i\n" +
|
"\x14ExternalRegistration\x12i\n" +
|
||||||
"\x16AuthenticateOrRegister\x12&.auth.registration.RegistrationRequest\x1a'.auth.registration.RegistrationResponse\x12B\n" +
|
"\x16AuthenticateOrRegister\x12&.auth.registration.RegistrationRequest\x1a'.auth.registration.RegistrationResponseB,Z*/pkg/externalRegistration/v1;externalRegV1b\x06proto3"
|
||||||
"\x06Update\x12 .auth.registration.UpdateRequest\x1a\x16.google.protobuf.EmptyB,Z*/pkg/externalRegistration/v1;externalRegV1b\x06proto3"
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_proto_serviceRegistration_proto_rawDescOnce sync.Once
|
file_proto_serviceRegistration_proto_rawDescOnce sync.Once
|
||||||
|
|
@ -293,20 +188,16 @@ func file_proto_serviceRegistration_proto_rawDescGZIP() []byte {
|
||||||
return file_proto_serviceRegistration_proto_rawDescData
|
return file_proto_serviceRegistration_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_proto_serviceRegistration_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
var file_proto_serviceRegistration_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
var file_proto_serviceRegistration_proto_goTypes = []any{
|
var file_proto_serviceRegistration_proto_goTypes = []any{
|
||||||
(*RegistrationRequest)(nil), // 0: auth.registration.RegistrationRequest
|
(*RegistrationRequest)(nil), // 0: auth.registration.RegistrationRequest
|
||||||
(*RegistrationResponse)(nil), // 1: auth.registration.RegistrationResponse
|
(*RegistrationResponse)(nil), // 1: auth.registration.RegistrationResponse
|
||||||
(*UpdateRequest)(nil), // 2: auth.registration.UpdateRequest
|
|
||||||
(*emptypb.Empty)(nil), // 3: google.protobuf.Empty
|
|
||||||
}
|
}
|
||||||
var file_proto_serviceRegistration_proto_depIdxs = []int32{
|
var file_proto_serviceRegistration_proto_depIdxs = []int32{
|
||||||
0, // 0: auth.registration.ExternalRegistration.AuthenticateOrRegister:input_type -> auth.registration.RegistrationRequest
|
0, // 0: auth.registration.ExternalRegistration.AuthenticateOrRegister:input_type -> auth.registration.RegistrationRequest
|
||||||
2, // 1: auth.registration.ExternalRegistration.Update:input_type -> auth.registration.UpdateRequest
|
1, // 1: auth.registration.ExternalRegistration.AuthenticateOrRegister:output_type -> auth.registration.RegistrationResponse
|
||||||
1, // 2: auth.registration.ExternalRegistration.AuthenticateOrRegister:output_type -> auth.registration.RegistrationResponse
|
1, // [1:2] is the sub-list for method output_type
|
||||||
3, // 3: auth.registration.ExternalRegistration.Update:output_type -> google.protobuf.Empty
|
0, // [0:1] is the sub-list for method input_type
|
||||||
2, // [2:4] is the sub-list for method output_type
|
|
||||||
0, // [0:2] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
|
|
@ -323,7 +214,7 @@ func file_proto_serviceRegistration_proto_init() {
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_serviceRegistration_proto_rawDesc), len(file_proto_serviceRegistration_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_serviceRegistration_proto_rawDesc), len(file_proto_serviceRegistration_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 3,
|
NumMessages: 2,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
|
@ -21,7 +20,6 @@ const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ExternalRegistration_AuthenticateOrRegister_FullMethodName = "/auth.registration.ExternalRegistration/AuthenticateOrRegister"
|
ExternalRegistration_AuthenticateOrRegister_FullMethodName = "/auth.registration.ExternalRegistration/AuthenticateOrRegister"
|
||||||
ExternalRegistration_Update_FullMethodName = "/auth.registration.ExternalRegistration/Update"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExternalRegistrationClient is the client API for ExternalRegistration service.
|
// ExternalRegistrationClient is the client API for ExternalRegistration service.
|
||||||
|
|
@ -29,7 +27,6 @@ const (
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
type ExternalRegistrationClient interface {
|
type ExternalRegistrationClient interface {
|
||||||
AuthenticateOrRegister(ctx context.Context, in *RegistrationRequest, opts ...grpc.CallOption) (*RegistrationResponse, error)
|
AuthenticateOrRegister(ctx context.Context, in *RegistrationRequest, opts ...grpc.CallOption) (*RegistrationResponse, error)
|
||||||
Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type externalRegistrationClient struct {
|
type externalRegistrationClient struct {
|
||||||
|
|
@ -50,22 +47,11 @@ func (c *externalRegistrationClient) AuthenticateOrRegister(ctx context.Context,
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *externalRegistrationClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(emptypb.Empty)
|
|
||||||
err := c.cc.Invoke(ctx, ExternalRegistration_Update_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExternalRegistrationServer is the server API for ExternalRegistration service.
|
// ExternalRegistrationServer is the server API for ExternalRegistration service.
|
||||||
// All implementations must embed UnimplementedExternalRegistrationServer
|
// All implementations must embed UnimplementedExternalRegistrationServer
|
||||||
// for forward compatibility.
|
// for forward compatibility.
|
||||||
type ExternalRegistrationServer interface {
|
type ExternalRegistrationServer interface {
|
||||||
AuthenticateOrRegister(context.Context, *RegistrationRequest) (*RegistrationResponse, error)
|
AuthenticateOrRegister(context.Context, *RegistrationRequest) (*RegistrationResponse, error)
|
||||||
Update(context.Context, *UpdateRequest) (*emptypb.Empty, error)
|
|
||||||
mustEmbedUnimplementedExternalRegistrationServer()
|
mustEmbedUnimplementedExternalRegistrationServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,9 +65,6 @@ type UnimplementedExternalRegistrationServer struct{}
|
||||||
func (UnimplementedExternalRegistrationServer) AuthenticateOrRegister(context.Context, *RegistrationRequest) (*RegistrationResponse, error) {
|
func (UnimplementedExternalRegistrationServer) AuthenticateOrRegister(context.Context, *RegistrationRequest) (*RegistrationResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method AuthenticateOrRegister not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method AuthenticateOrRegister not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedExternalRegistrationServer) Update(context.Context, *UpdateRequest) (*emptypb.Empty, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedExternalRegistrationServer) mustEmbedUnimplementedExternalRegistrationServer() {}
|
func (UnimplementedExternalRegistrationServer) mustEmbedUnimplementedExternalRegistrationServer() {}
|
||||||
func (UnimplementedExternalRegistrationServer) testEmbeddedByValue() {}
|
func (UnimplementedExternalRegistrationServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
|
@ -121,24 +104,6 @@ func _ExternalRegistration_AuthenticateOrRegister_Handler(srv interface{}, ctx c
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ExternalRegistration_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(UpdateRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ExternalRegistrationServer).Update(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: ExternalRegistration_Update_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ExternalRegistrationServer).Update(ctx, req.(*UpdateRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExternalRegistration_ServiceDesc is the grpc.ServiceDesc for ExternalRegistration service.
|
// ExternalRegistration_ServiceDesc is the grpc.ServiceDesc for ExternalRegistration service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
|
@ -150,10 +115,6 @@ var ExternalRegistration_ServiceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "AuthenticateOrRegister",
|
MethodName: "AuthenticateOrRegister",
|
||||||
Handler: _ExternalRegistration_AuthenticateOrRegister_Handler,
|
Handler: _ExternalRegistration_AuthenticateOrRegister_Handler,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
MethodName: "Update",
|
|
||||||
Handler: _ExternalRegistration_Update_Handler,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "proto/serviceRegistration.proto",
|
Metadata: "proto/serviceRegistration.proto",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ type Deps struct {
|
||||||
GinMode string
|
GinMode string
|
||||||
UserProvider UserProvider
|
UserProvider UserProvider
|
||||||
AuthProvider AuthChecker
|
AuthProvider AuthChecker
|
||||||
|
ServiceId int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Router struct {
|
type Router struct {
|
||||||
|
|
@ -36,6 +37,7 @@ type Router struct {
|
||||||
type providers struct {
|
type providers struct {
|
||||||
userProvider UserProvider
|
userProvider UserProvider
|
||||||
authChecker AuthChecker
|
authChecker AuthChecker
|
||||||
|
serviceId int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(deps Deps) *Router {
|
func NewRouter(deps Deps) *Router {
|
||||||
|
|
@ -73,6 +75,7 @@ func NewRouter(deps Deps) *Router {
|
||||||
providers: providers{
|
providers: providers{
|
||||||
userProvider: deps.UserProvider,
|
userProvider: deps.UserProvider,
|
||||||
authChecker: deps.AuthProvider,
|
authChecker: deps.AuthProvider,
|
||||||
|
serviceId: deps.ServiceId,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +96,7 @@ func (r *Router) BaseGroup() *gin.RouterGroup {
|
||||||
|
|
||||||
func (r *Router) MWSet() *Middlewares {
|
func (r *Router) MWSet() *Middlewares {
|
||||||
return &Middlewares{
|
return &Middlewares{
|
||||||
AuthMW: AuthMW(r.providers.userProvider, r.providers.authChecker),
|
AuthMW: AuthMW(r.providers.userProvider, r.providers.authChecker, r.providers.serviceId),
|
||||||
RegMW: RegisterMW(r.providers.authChecker),
|
RegMW: RegisterMW(r.providers.authChecker, r.providers.serviceId),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ type UserProvider interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthChecker interface {
|
type AuthChecker interface {
|
||||||
VerifySession(ctx context.Context, sessionUuid string) (string, error)
|
VerifySession(ctx context.Context, sessionUuid string, serviceId int32) (string, error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
type DepsMW struct {
|
type DepsMW struct {
|
||||||
UserProv UserProvider
|
UserProv UserProvider
|
||||||
AuthProv AuthChecker
|
AuthProv AuthChecker
|
||||||
|
ServiceId int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Middlewares struct {
|
type Middlewares struct {
|
||||||
|
|
@ -17,21 +18,18 @@ type Middlewares struct {
|
||||||
RegMW gin.HandlerFunc
|
RegMW gin.HandlerFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func AuthMW(up UserProvider, ap AuthChecker) gin.HandlerFunc {
|
func AuthMW(up UserProvider, ap AuthChecker, sid int32) gin.HandlerFunc {
|
||||||
const funcHeader string = "Auth Middleware |"
|
const funcHeader string = "Auth Middleware |"
|
||||||
log.Debugf("%v %v begin", pkgLogHeader, funcHeader)
|
log.Debugf("%v %v begin", pkgLogHeader, funcHeader)
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
cookie, err := c.Cookie(tokenCookieName)
|
cookie, err := c.Cookie(tokenCookieName)
|
||||||
log.WithFields(log.Fields{
|
log.WithField("value", cookie).Debugf("%v %v get session token from cookie", pkgLogHeader, funcHeader)
|
||||||
"value": cookie,
|
|
||||||
"len": len(cookie),
|
|
||||||
}).Debugf("%v %v get session token from cookie", pkgLogHeader, funcHeader)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
userUuid, err := ap.VerifySession(c, cookie)
|
userUuid, err := ap.VerifySession(c, cookie, sid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
|
@ -52,7 +50,7 @@ func AuthMW(up UserProvider, ap AuthChecker) gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterMW(ap AuthChecker) gin.HandlerFunc {
|
func RegisterMW(ap AuthChecker, sid int32) gin.HandlerFunc {
|
||||||
log.Debug("Auth Middlewares enabled")
|
log.Debug("Auth Middlewares enabled")
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
cookie, err := c.Cookie(tokenCookieName)
|
cookie, err := c.Cookie(tokenCookieName)
|
||||||
|
|
@ -62,7 +60,7 @@ func RegisterMW(ap AuthChecker) gin.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userUuid, err := ap.VerifySession(c, cookie)
|
userUuid, err := ap.VerifySession(c, cookie, sid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
|
|
||||||
|
|
@ -133,126 +133,6 @@ func (x *VerifyTokenResponse) GetAccessCode() int32 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type PersonalRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
UserUuid string `protobuf:"bytes,1,opt,name=userUuid,proto3" json:"userUuid,omitempty"`
|
|
||||||
ServiceId int32 `protobuf:"varint,2,opt,name=serviceId,proto3" json:"serviceId,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalRequest) Reset() {
|
|
||||||
*x = PersonalRequest{}
|
|
||||||
mi := &file_proto_verify_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*PersonalRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *PersonalRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_proto_verify_proto_msgTypes[2]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use PersonalRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*PersonalRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_proto_verify_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalRequest) GetUserUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalRequest) GetServiceId() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.ServiceId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type PersonalResponse struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
|
||||||
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
|
|
||||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
|
||||||
Surname string `protobuf:"bytes,4,opt,name=surname,proto3" json:"surname,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) Reset() {
|
|
||||||
*x = PersonalResponse{}
|
|
||||||
mi := &file_proto_verify_proto_msgTypes[3]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*PersonalResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_proto_verify_proto_msgTypes[3]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use PersonalResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*PersonalResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_proto_verify_proto_rawDescGZIP(), []int{3}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) GetEmail() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Email
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) GetUsername() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Username
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) GetName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Name
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PersonalResponse) GetSurname() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Surname
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_proto_verify_proto protoreflect.FileDescriptor
|
var File_proto_verify_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_proto_verify_proto_rawDesc = "" +
|
const file_proto_verify_proto_rawDesc = "" +
|
||||||
|
|
@ -266,18 +146,9 @@ const file_proto_verify_proto_rawDesc = "" +
|
||||||
"\aisValid\x18\x02 \x01(\bR\aisValid\x12\x1e\n" +
|
"\aisValid\x18\x02 \x01(\bR\aisValid\x12\x1e\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"accessCode\x18\x03 \x01(\x05R\n" +
|
"accessCode\x18\x03 \x01(\x05R\n" +
|
||||||
"accessCode\"K\n" +
|
"accessCode2c\n" +
|
||||||
"\x0fPersonalRequest\x12\x1a\n" +
|
|
||||||
"\buserUuid\x18\x01 \x01(\tR\buserUuid\x12\x1c\n" +
|
|
||||||
"\tserviceId\x18\x02 \x01(\x05R\tserviceId\"r\n" +
|
|
||||||
"\x10PersonalResponse\x12\x14\n" +
|
|
||||||
"\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" +
|
|
||||||
"\busername\x18\x02 \x01(\tR\busername\x12\x12\n" +
|
|
||||||
"\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" +
|
|
||||||
"\asurname\x18\x04 \x01(\tR\asurname2\xb7\x01\n" +
|
|
||||||
"\vAuthService\x12T\n" +
|
"\vAuthService\x12T\n" +
|
||||||
"\vVerifyToken\x12!.verifyAuth.v1.VerifyTokenRequest\x1a\".verifyAuth.v1.VerifyTokenResponse\x12R\n" +
|
"\vVerifyToken\x12!.verifyAuth.v1.VerifyTokenRequest\x1a\".verifyAuth.v1.VerifyTokenResponseB\x19Z\x17/pkg/verify/v1;verifyV1b\x06proto3"
|
||||||
"\x0fGetPersonalInfo\x12\x1e.verifyAuth.v1.PersonalRequest\x1a\x1f.verifyAuth.v1.PersonalResponseB\x19Z\x17/pkg/verify/v1;verifyV1b\x06proto3"
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_proto_verify_proto_rawDescOnce sync.Once
|
file_proto_verify_proto_rawDescOnce sync.Once
|
||||||
|
|
@ -291,20 +162,16 @@ func file_proto_verify_proto_rawDescGZIP() []byte {
|
||||||
return file_proto_verify_proto_rawDescData
|
return file_proto_verify_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_proto_verify_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_proto_verify_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
var file_proto_verify_proto_goTypes = []any{
|
var file_proto_verify_proto_goTypes = []any{
|
||||||
(*VerifyTokenRequest)(nil), // 0: verifyAuth.v1.VerifyTokenRequest
|
(*VerifyTokenRequest)(nil), // 0: verifyAuth.v1.VerifyTokenRequest
|
||||||
(*VerifyTokenResponse)(nil), // 1: verifyAuth.v1.VerifyTokenResponse
|
(*VerifyTokenResponse)(nil), // 1: verifyAuth.v1.VerifyTokenResponse
|
||||||
(*PersonalRequest)(nil), // 2: verifyAuth.v1.PersonalRequest
|
|
||||||
(*PersonalResponse)(nil), // 3: verifyAuth.v1.PersonalResponse
|
|
||||||
}
|
}
|
||||||
var file_proto_verify_proto_depIdxs = []int32{
|
var file_proto_verify_proto_depIdxs = []int32{
|
||||||
0, // 0: verifyAuth.v1.AuthService.VerifyToken:input_type -> verifyAuth.v1.VerifyTokenRequest
|
0, // 0: verifyAuth.v1.AuthService.VerifyToken:input_type -> verifyAuth.v1.VerifyTokenRequest
|
||||||
2, // 1: verifyAuth.v1.AuthService.GetPersonalInfo:input_type -> verifyAuth.v1.PersonalRequest
|
1, // 1: verifyAuth.v1.AuthService.VerifyToken:output_type -> verifyAuth.v1.VerifyTokenResponse
|
||||||
1, // 2: verifyAuth.v1.AuthService.VerifyToken:output_type -> verifyAuth.v1.VerifyTokenResponse
|
1, // [1:2] is the sub-list for method output_type
|
||||||
3, // 3: verifyAuth.v1.AuthService.GetPersonalInfo:output_type -> verifyAuth.v1.PersonalResponse
|
0, // [0:1] is the sub-list for method input_type
|
||||||
2, // [2:4] is the sub-list for method output_type
|
|
||||||
0, // [0:2] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
|
|
@ -321,7 +188,7 @@ func file_proto_verify_proto_init() {
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_verify_proto_rawDesc), len(file_proto_verify_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_verify_proto_rawDesc), len(file_proto_verify_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 4,
|
NumMessages: 2,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AuthService_VerifyToken_FullMethodName = "/verifyAuth.v1.AuthService/VerifyToken"
|
AuthService_VerifyToken_FullMethodName = "/verifyAuth.v1.AuthService/VerifyToken"
|
||||||
AuthService_GetPersonalInfo_FullMethodName = "/verifyAuth.v1.AuthService/GetPersonalInfo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthServiceClient is the client API for AuthService service.
|
// AuthServiceClient is the client API for AuthService service.
|
||||||
|
|
@ -28,7 +27,6 @@ const (
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
type AuthServiceClient interface {
|
type AuthServiceClient interface {
|
||||||
VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...grpc.CallOption) (*VerifyTokenResponse, error)
|
VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...grpc.CallOption) (*VerifyTokenResponse, error)
|
||||||
GetPersonalInfo(ctx context.Context, in *PersonalRequest, opts ...grpc.CallOption) (*PersonalResponse, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type authServiceClient struct {
|
type authServiceClient struct {
|
||||||
|
|
@ -49,22 +47,11 @@ func (c *authServiceClient) VerifyToken(ctx context.Context, in *VerifyTokenRequ
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *authServiceClient) GetPersonalInfo(ctx context.Context, in *PersonalRequest, opts ...grpc.CallOption) (*PersonalResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(PersonalResponse)
|
|
||||||
err := c.cc.Invoke(ctx, AuthService_GetPersonalInfo_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AuthServiceServer is the server API for AuthService service.
|
// AuthServiceServer is the server API for AuthService service.
|
||||||
// All implementations must embed UnimplementedAuthServiceServer
|
// All implementations must embed UnimplementedAuthServiceServer
|
||||||
// for forward compatibility.
|
// for forward compatibility.
|
||||||
type AuthServiceServer interface {
|
type AuthServiceServer interface {
|
||||||
VerifyToken(context.Context, *VerifyTokenRequest) (*VerifyTokenResponse, error)
|
VerifyToken(context.Context, *VerifyTokenRequest) (*VerifyTokenResponse, error)
|
||||||
GetPersonalInfo(context.Context, *PersonalRequest) (*PersonalResponse, error)
|
|
||||||
mustEmbedUnimplementedAuthServiceServer()
|
mustEmbedUnimplementedAuthServiceServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,9 +65,6 @@ type UnimplementedAuthServiceServer struct{}
|
||||||
func (UnimplementedAuthServiceServer) VerifyToken(context.Context, *VerifyTokenRequest) (*VerifyTokenResponse, error) {
|
func (UnimplementedAuthServiceServer) VerifyToken(context.Context, *VerifyTokenRequest) (*VerifyTokenResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method VerifyToken not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method VerifyToken not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedAuthServiceServer) GetPersonalInfo(context.Context, *PersonalRequest) (*PersonalResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetPersonalInfo not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
|
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
|
||||||
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
|
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
|
@ -120,24 +104,6 @@ func _AuthService_VerifyToken_Handler(srv interface{}, ctx context.Context, dec
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _AuthService_GetPersonalInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(PersonalRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(AuthServiceServer).GetPersonalInfo(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: AuthService_GetPersonalInfo_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(AuthServiceServer).GetPersonalInfo(ctx, req.(*PersonalRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
|
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
|
@ -149,10 +115,6 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "VerifyToken",
|
MethodName: "VerifyToken",
|
||||||
Handler: _AuthService_VerifyToken_Handler,
|
Handler: _AuthService_VerifyToken_Handler,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
MethodName: "GetPersonalInfo",
|
|
||||||
Handler: _AuthService_GetPersonalInfo_Handler,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "proto/verify.proto",
|
Metadata: "proto/verify.proto",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
package auth.registration;
|
package auth.registration;
|
||||||
option go_package = "/pkg/externalRegistration/v1;externalRegV1";
|
option go_package = "/pkg/externalRegistration/v1;externalRegV1";
|
||||||
|
|
@ -11,24 +10,13 @@ message RegistrationRequest {
|
||||||
int32 service_end_code = 4;
|
int32 service_end_code = 4;
|
||||||
string secret = 5;
|
string secret = 5;
|
||||||
string status = 6;
|
string status = 6;
|
||||||
string service_url = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message RegistrationResponse {
|
message RegistrationResponse {
|
||||||
int32 service_id = 1;
|
int32 service_id = 1;
|
||||||
bool already_registered = 2;
|
bool already_registered = 2;
|
||||||
string service_url = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateRequest {
|
|
||||||
string name = 1;
|
|
||||||
string description = 2;
|
|
||||||
string status = 3;
|
|
||||||
string service_url = 4;
|
|
||||||
int32 service_code = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service ExternalRegistration {
|
service ExternalRegistration {
|
||||||
rpc AuthenticateOrRegister (RegistrationRequest) returns (RegistrationResponse);
|
rpc AuthenticateOrRegister (RegistrationRequest) returns (RegistrationResponse);
|
||||||
rpc Update (UpdateRequest) returns (google.protobuf.Empty);
|
|
||||||
}
|
}
|
||||||
|
|
@ -14,19 +14,6 @@ message VerifyTokenResponse {
|
||||||
int32 accessCode = 3;
|
int32 accessCode = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PersonalRequest {
|
|
||||||
string userUuid = 1;
|
|
||||||
int32 serviceId = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PersonalResponse {
|
|
||||||
string email = 1;
|
|
||||||
string username = 2;
|
|
||||||
string name = 3;
|
|
||||||
string surname = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
service AuthService {
|
service AuthService {
|
||||||
rpc VerifyToken(VerifyTokenRequest) returns (VerifyTokenResponse);
|
rpc VerifyToken(VerifyTokenRequest) returns (VerifyTokenResponse);
|
||||||
rpc GetPersonalInfo(PersonalRequest) returns (PersonalResponse);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue