feat: update users request createdbyid

This commit is contained in:
hanif salafi 2024-11-07 11:31:28 +07:00
parent 5bcf5f97a4
commit 5e46b123a8
4 changed files with 49 additions and 68 deletions

View File

@ -53,10 +53,12 @@ type ArticlesUpdateRequest struct {
CategoryId int `json:"categoryId" validate:"required"` CategoryId int `json:"categoryId" validate:"required"`
TypeId int `json:"typeId" validate:"required"` TypeId int `json:"typeId" validate:"required"`
Tags string `json:"tags" validate:"required"` Tags string `json:"tags" validate:"required"`
CreatedById *uint `json:"createdById"`
StatusId *int `json:"statusId"` StatusId *int `json:"statusId"`
} }
func (req ArticlesUpdateRequest) ToEntity() *entity.Articles { func (req ArticlesUpdateRequest) ToEntity() *entity.Articles {
if req.CreatedById == nil {
return &entity.Articles{ return &entity.Articles{
Title: req.Title, Title: req.Title,
Slug: req.Slug, Slug: req.Slug,
@ -68,6 +70,20 @@ func (req ArticlesUpdateRequest) ToEntity() *entity.Articles {
StatusId: req.StatusId, StatusId: req.StatusId,
UpdatedAt: time.Now(), UpdatedAt: time.Now(),
} }
} else {
return &entity.Articles{
Title: req.Title,
Slug: req.Slug,
Description: req.Description,
HtmlDescription: req.HtmlDescription,
CategoryId: req.CategoryId,
TypeId: req.TypeId,
Tags: req.Tags,
StatusId: req.StatusId,
CreatedById: req.CreatedById,
UpdatedAt: time.Now(),
}
}
} }
type ArticlesQueryRequestContext struct { type ArticlesQueryRequestContext struct {

View File

@ -5402,6 +5402,9 @@ const docTemplate = `{
"categoryId": { "categoryId": {
"type": "integer" "type": "integer"
}, },
"createdById": {
"type": "integer"
},
"description": { "description": {
"type": "string" "type": "string"
}, },
@ -5765,22 +5768,13 @@ const docTemplate = `{
"request.UsersCreateRequest": { "request.UsersCreateRequest": {
"type": "object", "type": "object",
"required": [ "required": [
"address",
"dateOfBirth",
"email", "email",
"fullname", "fullname",
"genderType",
"identityGroup",
"identityGroupNumber",
"identityNumber",
"identityType",
"lastEducation",
"password", "password",
"phoneNumber", "phoneNumber",
"userLevelId", "userLevelId",
"userRoleId", "userRoleId",
"username", "username"
"workType"
], ],
"properties": { "properties": {
"address": { "address": {
@ -5836,21 +5830,13 @@ const docTemplate = `{
"request.UsersUpdateRequest": { "request.UsersUpdateRequest": {
"type": "object", "type": "object",
"required": [ "required": [
"address",
"dateOfBirth",
"email", "email",
"fullname", "fullname",
"genderType", "password",
"identityGroup",
"identityGroupNumber",
"identityNumber",
"identityType",
"lastEducation",
"phoneNumber", "phoneNumber",
"userLevelId", "userLevelId",
"userRoleId", "userRoleId",
"username", "username"
"workType"
], ],
"properties": { "properties": {
"address": { "address": {
@ -5883,6 +5869,9 @@ const docTemplate = `{
"lastEducation": { "lastEducation": {
"type": "string" "type": "string"
}, },
"password": {
"type": "string"
},
"phoneNumber": { "phoneNumber": {
"type": "string" "type": "string"
}, },

View File

@ -5391,6 +5391,9 @@
"categoryId": { "categoryId": {
"type": "integer" "type": "integer"
}, },
"createdById": {
"type": "integer"
},
"description": { "description": {
"type": "string" "type": "string"
}, },
@ -5754,22 +5757,13 @@
"request.UsersCreateRequest": { "request.UsersCreateRequest": {
"type": "object", "type": "object",
"required": [ "required": [
"address",
"dateOfBirth",
"email", "email",
"fullname", "fullname",
"genderType",
"identityGroup",
"identityGroupNumber",
"identityNumber",
"identityType",
"lastEducation",
"password", "password",
"phoneNumber", "phoneNumber",
"userLevelId", "userLevelId",
"userRoleId", "userRoleId",
"username", "username"
"workType"
], ],
"properties": { "properties": {
"address": { "address": {
@ -5825,21 +5819,13 @@
"request.UsersUpdateRequest": { "request.UsersUpdateRequest": {
"type": "object", "type": "object",
"required": [ "required": [
"address",
"dateOfBirth",
"email", "email",
"fullname", "fullname",
"genderType", "password",
"identityGroup",
"identityGroupNumber",
"identityNumber",
"identityType",
"lastEducation",
"phoneNumber", "phoneNumber",
"userLevelId", "userLevelId",
"userRoleId", "userRoleId",
"username", "username"
"workType"
], ],
"properties": { "properties": {
"address": { "address": {
@ -5872,6 +5858,9 @@
"lastEducation": { "lastEducation": {
"type": "string" "type": "string"
}, },
"password": {
"type": "string"
},
"phoneNumber": { "phoneNumber": {
"type": "string" "type": "string"
}, },

View File

@ -119,6 +119,8 @@ definitions:
properties: properties:
categoryId: categoryId:
type: integer type: integer
createdById:
type: integer
description: description:
type: string type: string
htmlDescription: htmlDescription:
@ -413,22 +415,13 @@ definitions:
workType: workType:
type: string type: string
required: required:
- address
- dateOfBirth
- email - email
- fullname - fullname
- genderType
- identityGroup
- identityGroupNumber
- identityNumber
- identityType
- lastEducation
- password - password
- phoneNumber - phoneNumber
- userLevelId - userLevelId
- userRoleId - userRoleId
- username - username
- workType
type: object type: object
request.UsersUpdateRequest: request.UsersUpdateRequest:
properties: properties:
@ -452,6 +445,8 @@ definitions:
type: string type: string
lastEducation: lastEducation:
type: string type: string
password:
type: string
phoneNumber: phoneNumber:
type: string type: string
statusId: statusId:
@ -465,21 +460,13 @@ definitions:
workType: workType:
type: string type: string
required: required:
- address
- dateOfBirth
- email - email
- fullname - fullname
- genderType - password
- identityGroup
- identityGroupNumber
- identityNumber
- identityType
- lastEducation
- phoneNumber - phoneNumber
- userLevelId - userLevelId
- userRoleId - userRoleId
- username - username
- workType
type: object type: object
response.BadRequestError: response.BadRequestError:
properties: properties: