generated from VLADIMIR/template
up
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"evening_detective_server/internal/services/task_service"
|
||||
proto "evening_detective_server/proto"
|
||||
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func taskInput(title, description, status string, assigneeID *int32, dueDate string) (task_service.Task, error) {
|
||||
date, err := task_service.ParseDueDate(dueDate)
|
||||
if err != nil {
|
||||
return task_service.Task{}, err
|
||||
}
|
||||
return task_service.Task{
|
||||
Title: title,
|
||||
Description: description,
|
||||
Status: status,
|
||||
AssigneeID: taskDomainID(assigneeID),
|
||||
DueDate: date,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func taskDomainID(value *int32) *int {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
result := int(*value)
|
||||
return &result
|
||||
}
|
||||
|
||||
func taskProtoID(value *int) *int32 {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
result := int32(*value)
|
||||
return &result
|
||||
}
|
||||
|
||||
func mapTask(task *task_service.Task) *proto.DeveloperTask {
|
||||
dueDate := ""
|
||||
if task.DueDate != nil {
|
||||
dueDate = task.DueDate.Format("2006-01-02")
|
||||
}
|
||||
return &proto.DeveloperTask{
|
||||
ID: int32(task.ID),
|
||||
Title: task.Title,
|
||||
Description: task.Description,
|
||||
Status: task.Status,
|
||||
AssigneeID: taskProtoID(task.AssigneeID),
|
||||
AssigneeName: task.AssigneeName,
|
||||
AuthorID: taskProtoID(task.AuthorID),
|
||||
DueDate: dueDate,
|
||||
CreatedAt: timestamppb.New(task.CreatedAt),
|
||||
UpdatedAt: timestamppb.New(task.UpdatedAt),
|
||||
Version: int32(task.Version),
|
||||
}
|
||||
}
|
||||
|
||||
func mapTaskAssignee(user task_service.Assignee) *proto.TaskAssignee {
|
||||
return &proto.TaskAssignee{
|
||||
ID: int32(user.ID),
|
||||
Name: user.Name,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user