Skip to content

Commit 2823d95

Browse files
committed
front
2 parents b6ae249 + 70b4934 commit 2823d95

File tree

24 files changed

+355
-216
lines changed

24 files changed

+355
-216
lines changed

aiplan.go/internal/aiplan/business/issue.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import (
99
"github.com/aisa-it/aiplan/aiplan.go/internal/aiplan/dao"
1010
errStack "github.com/aisa-it/aiplan/aiplan.go/internal/aiplan/stack-error"
1111
"github.com/aisa-it/aiplan/aiplan.go/internal/aiplan/types"
12+
"github.com/gofrs/uuid"
1213
)
1314

1415
// CreateIssueComment создает новый комментарий к задаче. Метод принимает задачу, пользователя, текст комментария, комментарий для базы данных, ID для ответа на комментарий и дополнительные метаданные. Возвращает ошибку, если произошла ошибка.
15-
func (b *Business) CreateIssueComment(issue dao.Issue, user dao.User, text string, replyToId *string, fromTg bool, meta ...string) error {
16+
func (b *Business) CreateIssueComment(issue dao.Issue, user dao.User, text string, replyToId uuid.UUID, fromTg bool, meta ...string) error {
1617
// Check rights
1718
var permitted bool
1819
if err := b.db.Model(&dao.ProjectMember{}).
@@ -32,7 +33,7 @@ func (b *Business) CreateIssueComment(issue dao.Issue, user dao.User, text strin
3233

3334
issueId := issue.ID.String()
3435
comment := dao.IssueComment{
35-
Id: dao.GenID(),
36+
Id: dao.GenUUID(),
3637
WorkspaceId: issue.WorkspaceId,
3738
ProjectId: issue.ProjectId,
3839
IssueId: issueId,
@@ -42,8 +43,8 @@ func (b *Business) CreateIssueComment(issue dao.Issue, user dao.User, text strin
4243
if len(meta) > 0 {
4344
comment.IntegrationMeta = strings.Join(meta, ",")
4445
}
45-
if replyToId != nil {
46-
comment.ReplyToCommentId = replyToId
46+
if !replyToId.IsNil() {
47+
comment.ReplyToCommentId = uuid.NullUUID{UUID: replyToId, Valid: true}
4748
}
4849
if err := b.db.Create(&comment).Error; err != nil {
4950
return err

aiplan.go/internal/aiplan/dao/aiplan.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func GenID() string {
3535
return u2.String()
3636
}
3737

38-
// GenUUID генерирует уникальный идентификатор в формате UUID. Не принимает параметров и возвращает строку, представляющую собой UUID.
38+
// GenUUID генерирует уникальный идентификатор в формате UUID. Не принимает параметров и возвращает UUID.
3939
//
4040
// Возвращает:
41-
// - uuid.UUID: сгенерированный UUID.
41+
// - uuid.UUID: UUID, представляющий собой уникальный идентификатор.
4242
func GenUUID() uuid.UUID {
4343
u2, _ := uuid.NewV4()
4444
return u2
@@ -83,13 +83,13 @@ type FileAsset struct {
8383
CreatedById *string `json:"created_by,omitempty" extensions:"x-nullable"`
8484

8585
WorkspaceId *string `json:"workspace,omitempty"`
86-
IssueId uuid.NullUUID `json:"issue,omitempty" gorm:"foreignKey:ID"`
87-
CommentId *string `json:"comment,omitempty" gorm:"foreignKey:IdActivity" extensions:"x-nullable"`
86+
IssueId uuid.NullUUID `json:"issue" gorm:"foreignKey:ID"`
87+
CommentId *uuid.UUID `json:"comment,omitempty" gorm:"foreignKey:IdActivity" extensions:"x-nullable"`
8888

89-
DocId uuid.NullUUID `json:"doc,omitempty" gorm:"foreignKey:ID;type:uuid"`
90-
DocCommentId uuid.NullUUID `json:"doc_comment,omitempty" gorm:"type:uuid"`
89+
DocId uuid.NullUUID `json:"doc" gorm:"foreignKey:ID;type:uuid"`
90+
DocCommentId uuid.NullUUID `json:"doc_comment" gorm:"type:uuid"`
9191

92-
FormId uuid.NullUUID `json:"form,omitempty" gorm:"foreignKey:ID;type:uuid"`
92+
FormId uuid.NullUUID `json:"form" gorm:"foreignKey:ID;type:uuid"`
9393

9494
Name string `json:"name" gorm:"index"`
9595
FileSize int `json:"size"`

aiplan.go/internal/aiplan/dao/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ type DocComment struct {
381381
// comment_json jsonb IS_NULL:NO
382382
CommentType int `json:"comment_type" gorm:"default:1"`
383383
IntegrationMeta string `json:"-" gorm:"index:integration_doc,priority:2"`
384-
ReplyToCommentId uuid.NullUUID `json:"reply_to_comment_id,omitempty"`
384+
ReplyToCommentId uuid.NullUUID `json:"reply_to_comment_id"`
385385
OriginalComment *DocComment `json:"original_comment,omitempty" gorm:"foreignKey:ReplyToCommentId" extensions:"x-nullable"`
386386

387387
Workspace *Workspace `json:"-" gorm:"foreignKey:WorkspaceId" extensions:"x-nullable"`

aiplan.go/internal/aiplan/dao/issue.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ func (issue *Issue) BeforeDelete(tx *gorm.DB) error {
585585
return err
586586
}
587587

588-
var commentId []string
588+
var commentId []uuid.UUID
589589

590590
for _, comment := range comments {
591591
commentId = append(commentId, comment.Id)
@@ -1281,7 +1281,7 @@ type IssueLabel struct {
12811281
func (IssueLabel) TableName() string { return "issue_labels" }
12821282

12831283
type IssueComment struct {
1284-
Id string `json:"id" gorm:"primaryKey"`
1284+
Id uuid.UUID `json:"id" gorm:"primaryKey"`
12851285
CreatedAt time.Time `json:"created_at"`
12861286
UpdatedAt time.Time `json:"updated_at"`
12871287
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
@@ -1299,7 +1299,7 @@ type IssueComment struct {
12991299
CommentStripped string `json:"comment_stripped"`
13001300

13011301
IntegrationMeta string `json:"-" gorm:"index:integration,priority:2"`
1302-
ReplyToCommentId *string `json:"reply_to_comment_id,omitempty" extensions:"x-nullable"`
1302+
ReplyToCommentId uuid.NullUUID `json:"reply_to_comment_id" extensions:"x-nullable"`
13031303
OriginalComment *IssueComment `json:"original_comment,omitempty" gorm:"foreignKey:ReplyToCommentId" extensions:"x-nullable"`
13041304

13051305
// Id in system, from that comment was imported
@@ -1333,7 +1333,7 @@ type IssueCommentExtendFields struct {
13331333
}
13341334

13351335
func (i IssueComment) GetId() string {
1336-
return i.Id
1336+
return i.Id.String()
13371337
}
13381338

13391339
func (i IssueComment) GetString() string {
@@ -1369,7 +1369,7 @@ func (i *IssueComment) ToLightDTO() *dto.IssueCommentLight {
13691369
}
13701370
i.SetUrl()
13711371
return &dto.IssueCommentLight{
1372-
Id: i.Id,
1372+
Id: i.Id.String(),
13731373
CommentStripped: i.CommentStripped,
13741374
CommentHtml: i.CommentHtml.Body,
13751375
URL: types.JsonURL{i.URL},
@@ -1416,7 +1416,7 @@ type CommentReaction struct {
14161416
CreatedAt time.Time `json:"created_at"`
14171417
UpdatedAt time.Time `json:"updated_at"`
14181418
UserId string `json:"user_id"`
1419-
CommentId string `json:"comment_id" gorm:"index"`
1419+
CommentId uuid.UUID `json:"comment_id" gorm:"index"`
14201420
Reaction string `json:"reaction"`
14211421

14221422
User *User `json:"-" gorm:"foreignKey:UserId" extensions:"x-nullable"`
@@ -1445,7 +1445,7 @@ func (cr CommentReaction) ToDTO() *dto.CommentReaction {
14451445
Id: cr.Id,
14461446
CreatedAt: cr.CreatedAt,
14471447
UpdatedAt: cr.UpdatedAt,
1448-
CommentId: cr.CommentId,
1448+
CommentId: cr.CommentId.String(),
14491449
UserId: cr.UserId,
14501450
Reaction: cr.Reaction,
14511451
}

aiplan.go/internal/aiplan/dao/user.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ type UserNotifications struct {
345345
EntityActivityId *string `json:"entity_activity,omitempty"`
346346
EntityActivity *EntityActivity `json:"entity_activity_detail,omitempty" gorm:"foreignKey:EntityActivityId" extensions:"x-nullable"`
347347

348-
CommentId *string `json:"comment_id,omitempty"`
348+
CommentId *uuid.UUID `json:"comment_id,omitempty"`
349349
Comment *IssueComment `json:"comment,omitempty" gorm:"foreignKey:CommentId" extensions:"x-nullable"`
350350

351351
WorkspaceId *string `json:"workspace_id,omitempty"`
@@ -399,7 +399,7 @@ func (un *UserNotifications) ToLightDTO() *dto.UserNotificationsLight {
399399
Msg: un.Msg,
400400
AuthorId: un.AuthorId,
401401
EntityActivityId: un.EntityActivityId,
402-
CommentId: un.CommentId,
402+
CommentId: convertUUIDToStringPtr(un.CommentId),
403403
WorkspaceId: un.WorkspaceId,
404404
IssueId: un.IssueId,
405405
}
@@ -452,6 +452,16 @@ func (un *UserNotifications) AfterFind(tx *gorm.DB) (err error) {
452452
Filter *SearchFilter `json:"filter" gorm:"foreignKey:FilterId"`
453453
}*/
454454

455+
// convertUUIDToStringPtr преобразует *uuid.UUID в *string.
456+
// Если входной указатель nil, возвращает nil.
457+
func convertUUIDToStringPtr(uuidPtr *uuid.UUID) *string {
458+
if uuidPtr == nil {
459+
return nil
460+
}
461+
str := uuidPtr.String()
462+
return &str
463+
}
464+
455465
func GetUsers(db *gorm.DB) []User {
456466
var res []User
457467
db.Find(&res)

aiplan.go/internal/aiplan/docs/docs.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,53 @@ const docTemplate = `{
17421742
}
17431743
}
17441744
},
1745+
"/api/auth/file/{fileName}": {
1746+
"get": {
1747+
"security": [
1748+
{
1749+
"ApiKeyAuth": []
1750+
}
1751+
],
1752+
"description": "Эндпоинт для получения файла из MinIO хранилища. Проверяет права доступа пользователя к файлу и возвращает файл по его имени или идентификатору",
1753+
"consumes": [
1754+
"*/*"
1755+
],
1756+
"produces": [
1757+
"*/*"
1758+
],
1759+
"tags": [
1760+
"Integrations"
1761+
],
1762+
"summary": "Получение файла",
1763+
"operationId": "assetsHandler",
1764+
"parameters": [
1765+
{
1766+
"type": "string",
1767+
"description": "Имя файла или ID файла",
1768+
"name": "fileName",
1769+
"in": "path",
1770+
"required": true
1771+
}
1772+
],
1773+
"responses": {
1774+
"200": {
1775+
"description": "Успешный ответ с содержимым файла"
1776+
},
1777+
"404": {
1778+
"description": "Файл не найден",
1779+
"schema": {
1780+
"$ref": "#/definitions/apierrors.DefinedError"
1781+
}
1782+
},
1783+
"500": {
1784+
"description": "Внутренняя ошибка сервера",
1785+
"schema": {
1786+
"$ref": "#/definitions/apierrors.DefinedError"
1787+
}
1788+
}
1789+
}
1790+
}
1791+
},
17451792
"/api/auth/filters/": {
17461793
"get": {
17471794
"security": [
@@ -15554,53 +15601,6 @@ const docTemplate = `{
1555415601
}
1555515602
}
1555615603
},
15557-
"/api/file/{fileName}": {
15558-
"get": {
15559-
"security": [
15560-
{
15561-
"ApiKeyAuth": []
15562-
}
15563-
],
15564-
"description": "Перенаправляет пользователя на файл, хранящийся в MinIO, по имени файла или ID",
15565-
"consumes": [
15566-
"*/*"
15567-
],
15568-
"produces": [
15569-
"*/*"
15570-
],
15571-
"tags": [
15572-
"Integrations"
15573-
],
15574-
"summary": "Интеграции: перенаправление на файл в MinIO",
15575-
"operationId": "redirectToMinioFile",
15576-
"parameters": [
15577-
{
15578-
"type": "string",
15579-
"description": "Имя файла или ID файла",
15580-
"name": "fileName",
15581-
"in": "path",
15582-
"required": true
15583-
}
15584-
],
15585-
"responses": {
15586-
"307": {
15587-
"description": "Перенаправление на URL файла в MinIO"
15588-
},
15589-
"404": {
15590-
"description": "Файл не найден",
15591-
"schema": {
15592-
"$ref": "#/definitions/apierrors.DefinedError"
15593-
}
15594-
},
15595-
"500": {
15596-
"description": "Внутренняя ошибка сервера",
15597-
"schema": {
15598-
"$ref": "#/definitions/apierrors.DefinedError"
15599-
}
15600-
}
15601-
}
15602-
}
15603-
},
1560415604
"/api/forms/{formSlug}/": {
1560515605
"get": {
1560615606
"description": "Получает информацию о форме, без аутентификации",

aiplan.go/internal/aiplan/docs/swagger.json

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,53 @@
17341734
}
17351735
}
17361736
},
1737+
"/api/auth/file/{fileName}": {
1738+
"get": {
1739+
"security": [
1740+
{
1741+
"ApiKeyAuth": []
1742+
}
1743+
],
1744+
"description": "Эндпоинт для получения файла из MinIO хранилища. Проверяет права доступа пользователя к файлу и возвращает файл по его имени или идентификатору",
1745+
"consumes": [
1746+
"*/*"
1747+
],
1748+
"produces": [
1749+
"*/*"
1750+
],
1751+
"tags": [
1752+
"Integrations"
1753+
],
1754+
"summary": "Получение файла",
1755+
"operationId": "assetsHandler",
1756+
"parameters": [
1757+
{
1758+
"type": "string",
1759+
"description": "Имя файла или ID файла",
1760+
"name": "fileName",
1761+
"in": "path",
1762+
"required": true
1763+
}
1764+
],
1765+
"responses": {
1766+
"200": {
1767+
"description": "Успешный ответ с содержимым файла"
1768+
},
1769+
"404": {
1770+
"description": "Файл не найден",
1771+
"schema": {
1772+
"$ref": "#/definitions/apierrors.DefinedError"
1773+
}
1774+
},
1775+
"500": {
1776+
"description": "Внутренняя ошибка сервера",
1777+
"schema": {
1778+
"$ref": "#/definitions/apierrors.DefinedError"
1779+
}
1780+
}
1781+
}
1782+
}
1783+
},
17371784
"/api/auth/filters/": {
17381785
"get": {
17391786
"security": [
@@ -15546,53 +15593,6 @@
1554615593
}
1554715594
}
1554815595
},
15549-
"/api/file/{fileName}": {
15550-
"get": {
15551-
"security": [
15552-
{
15553-
"ApiKeyAuth": []
15554-
}
15555-
],
15556-
"description": "Перенаправляет пользователя на файл, хранящийся в MinIO, по имени файла или ID",
15557-
"consumes": [
15558-
"*/*"
15559-
],
15560-
"produces": [
15561-
"*/*"
15562-
],
15563-
"tags": [
15564-
"Integrations"
15565-
],
15566-
"summary": "Интеграции: перенаправление на файл в MinIO",
15567-
"operationId": "redirectToMinioFile",
15568-
"parameters": [
15569-
{
15570-
"type": "string",
15571-
"description": "Имя файла или ID файла",
15572-
"name": "fileName",
15573-
"in": "path",
15574-
"required": true
15575-
}
15576-
],
15577-
"responses": {
15578-
"307": {
15579-
"description": "Перенаправление на URL файла в MinIO"
15580-
},
15581-
"404": {
15582-
"description": "Файл не найден",
15583-
"schema": {
15584-
"$ref": "#/definitions/apierrors.DefinedError"
15585-
}
15586-
},
15587-
"500": {
15588-
"description": "Внутренняя ошибка сервера",
15589-
"schema": {
15590-
"$ref": "#/definitions/apierrors.DefinedError"
15591-
}
15592-
}
15593-
}
15594-
}
15595-
},
1559615596
"/api/forms/{formSlug}/": {
1559715597
"get": {
1559815598
"description": "Получает информацию о форме, без аутентификации",

0 commit comments

Comments
 (0)