Skip to content

Commit cd9eff1

Browse files
committed
fix: remove required binding from bio field in UserCreateRequest
1 parent ae1a4d6 commit cd9eff1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

dto/user_dto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type (
3535
UserCreateRequest struct {
3636
Name string `json:"name" form:"name" binding:"required"`
3737
UserName string `json:"username" form:"username" binding:"required"`
38-
Bio string `json:"bio" form:"bio" binding:"required"`
38+
Bio string `json:"bio" form:"bio"`
3939
Image *multipart.FileHeader `json:"image" form:"image"`
4040
Password string `json:"password" form:"password" binding:"required"`
4141
}

entity/user_entity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type User struct {
1010
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
1111
Name string `gorm:"not null" json:"name"`
1212
Username string `gorm:"not null" gorm:"unique" json:"username"`
13-
Bio string `gorm:"not null" json:"bio"`
13+
Bio *string `json:"bio"`
1414
Password string `gorm:"not null" json:"password"`
1515
ImageUrl *string `json:"image_url"`
1616

service/post_service.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *postService) CreatePost(ctx context.Context, userId string, req dto.Pos
6464
User: dto.UserResponse{
6565
ID: user.ID.String(),
6666
Name: user.Name,
67-
Bio: user.Bio,
67+
Bio: *user.Bio,
6868
UserName: user.Username,
6969
ImageUrl: user.ImageUrl,
7070
},
@@ -91,7 +91,7 @@ func (s *postService) GetPostById(ctx context.Context, postId uint64) (dto.PostR
9191
User: dto.UserResponse{
9292
ID: reply.UserID.String(),
9393
Name: reply.User.Name,
94-
Bio: reply.User.Bio,
94+
Bio: *reply.User.Bio,
9595
UserName: reply.User.Username,
9696
ImageUrl: reply.User.ImageUrl,
9797
},
@@ -108,7 +108,7 @@ func (s *postService) GetPostById(ctx context.Context, postId uint64) (dto.PostR
108108
User: dto.UserResponse{
109109
ID: post.UserID.String(),
110110
Name: post.User.Name,
111-
Bio: post.User.Bio,
111+
Bio: *post.User.Bio,
112112
UserName: post.User.Username,
113113
ImageUrl: post.User.ImageUrl,
114114
},
@@ -160,7 +160,7 @@ func (s *postService) UpdatePostById(ctx context.Context, userId string, postId
160160
User: dto.UserResponse{
161161
ID: result.UserID.String(),
162162
Name: result.User.Name,
163-
Bio: result.User.Bio,
163+
Bio: *result.User.Bio,
164164
UserName: result.User.Username,
165165
ImageUrl: result.User.ImageUrl,
166166
},
@@ -182,7 +182,7 @@ func (s *postService) GetAllPosts(ctx context.Context, req dto.PaginationRequest
182182
User: dto.UserResponse{
183183
ID: post.UserID.String(),
184184
Name: post.User.Name,
185-
Bio: post.User.Bio,
185+
Bio: *post.User.Bio,
186186
UserName: post.User.Username,
187187
ImageUrl: post.User.ImageUrl,
188188
},

service/user_service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (s *userService) Register(ctx context.Context, req dto.UserCreateRequest) (
5656
Name: req.Name,
5757
Username: req.UserName,
5858
ImageUrl: filenamePtr,
59-
Bio: req.Bio,
59+
Bio: &req.Bio,
6060
Password: req.Password,
6161
}
6262

@@ -69,7 +69,7 @@ func (s *userService) Register(ctx context.Context, req dto.UserCreateRequest) (
6969
ID: userReg.ID.String(),
7070
Name: userReg.Name,
7171
UserName: userReg.Username,
72-
Bio: userReg.Bio,
72+
Bio: *userReg.Bio,
7373
ImageUrl: userReg.ImageUrl,
7474
}, nil
7575
}
@@ -84,7 +84,7 @@ func (s *userService) GetUserById(ctx context.Context, userId string) (dto.UserR
8484
ID: user.ID.String(),
8585
Name: user.Name,
8686
UserName: user.Username,
87-
Bio: user.Bio,
87+
Bio: *user.Bio,
8888
ImageUrl: user.ImageUrl,
8989
}, nil
9090
}
@@ -117,7 +117,7 @@ func (s *userService) GetUserByUsername(ctx context.Context, username string) (d
117117
ID: user.ID.String(),
118118
Name: user.Name,
119119
UserName: user.Username,
120-
Bio: user.Bio,
120+
Bio: *user.Bio,
121121
ImageUrl: user.ImageUrl,
122122
}, nil
123123
}

0 commit comments

Comments
 (0)