feat: update ppid data categories for admin
This commit is contained in:
parent
9cf885d83a
commit
a17fd04a35
|
|
@ -10,6 +10,7 @@ type PpidDataCategories struct {
|
|||
ParentId *uint `json:"parent_id" gorm:"type:int4"`
|
||||
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
||||
LevelGroupId *uint `json:"level_group_id" gorm:"type:int4"`
|
||||
GroupBy *string `json:"group_by" gorm:"type:int4"`
|
||||
Position *int `json:"position" gorm:"type:int4"`
|
||||
ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"`
|
||||
ThumbnailUrl *string `json:"thumbnail_url" gorm:"type:varchar"`
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ func (_i *ppidDataCategoriesController) All(c *fiber.Ctx) error {
|
|||
Description: c.Query("description"),
|
||||
ParentId: c.Query("parentId"),
|
||||
IsOnlyTop: c.Query("isOnlyTop"),
|
||||
Group: c.Query("group"),
|
||||
LevelGroup: c.Query("levelGroup"),
|
||||
IsPpidDataIncluded: c.Query("isPpidDataIncluded"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ func PpidDataCategoriesResponseMapper(ppidDataCategoriesReq *entity.PpidDataCate
|
|||
Slug: ppidDataCategoriesReq.Slug,
|
||||
ParentId: ppidDataCategoriesReq.ParentId,
|
||||
Position: ppidDataCategoriesReq.Position,
|
||||
LevelGroupId: ppidDataCategoriesReq.LevelGroupId,
|
||||
GroupBy: ppidDataCategoriesReq.GroupBy,
|
||||
ThumbnailUrl: ppidDataCategoriesReq.ThumbnailUrl,
|
||||
IsActive: ppidDataCategoriesReq.IsActive,
|
||||
CreatedAt: ppidDataCategoriesReq.CreatedAt,
|
||||
|
|
@ -75,6 +77,8 @@ func PpidDataCategoriesWithPpidDataResponseMapper(
|
|||
Slug: ppidDataCategoriesReq.Slug,
|
||||
ParentId: ppidDataCategoriesReq.ParentId,
|
||||
Position: ppidDataCategoriesReq.Position,
|
||||
LevelGroupId: ppidDataCategoriesReq.LevelGroupId,
|
||||
GroupBy: ppidDataCategoriesReq.GroupBy,
|
||||
ThumbnailUrl: ppidDataCategoriesReq.ThumbnailUrl,
|
||||
IsActive: ppidDataCategoriesReq.IsActive,
|
||||
CreatedAt: ppidDataCategoriesReq.CreatedAt,
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ func (_i *ppidDataCategoriesRepository) GetAll(req request.PpidDataCategoriesQue
|
|||
if req.ParentId != nil {
|
||||
query = query.Where("parent_id = ?", req.ParentId)
|
||||
}
|
||||
if req.Group != nil {
|
||||
query = query.Where("group_by = ?", req.Group)
|
||||
}
|
||||
if req.LevelGroupId != nil {
|
||||
query = query.Where("level_group_id = ?", req.LevelGroupId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ type PpidDataCategoriesQueryRequest struct {
|
|||
IsOnlyTop *bool `json:"isOnlyTop"`
|
||||
IsPpidDataIncluded *bool `json:"isPpidDataIncluded"`
|
||||
ParentId *uint `json:"parentId"`
|
||||
Group *string `json:"group"`
|
||||
LevelGroup *string `json:"levelGroup"`
|
||||
LevelGroupId *uint `json:"levelGroupId"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
|
|
@ -79,6 +80,7 @@ type PpidDataCategoriesQueryRequestContext struct {
|
|||
Description string `json:"description"`
|
||||
IsOnlyTop string `json:"isOnlyTop"`
|
||||
IsPpidDataIncluded string `json:"isPpidDataIncluded"`
|
||||
Group string `json:"group"`
|
||||
LevelGroup string `json:"levelGroup"`
|
||||
LevelGroupId string `json:"levelGroupId"`
|
||||
ParentId string `json:"parentId"`
|
||||
|
|
@ -106,6 +108,9 @@ func (req PpidDataCategoriesQueryRequestContext) ToParamRequest() PpidDataCatego
|
|||
request.IsOnlyTop = &isOnlyTop
|
||||
}
|
||||
}
|
||||
if group := req.Group; group != "" {
|
||||
request.Group = &group
|
||||
}
|
||||
if levelGroup := req.LevelGroup; levelGroup != "" {
|
||||
request.LevelGroup = &levelGroup
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ type PpidDataCategoriesResponse struct {
|
|||
Slug string `json:"slug"`
|
||||
ParentId *uint `json:"parentId"`
|
||||
Position *int `json:"position"`
|
||||
LevelGroupId *uint `json:"levelGroupId"`
|
||||
GroupBy *string `json:"groupBy"`
|
||||
ThumbnailUrl *string `json:"thumbnailUrl"`
|
||||
IsActive *bool `json:"isActive"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
|
|
@ -27,6 +29,8 @@ type PpidDataCategoriesWithPpidDataResponse struct {
|
|||
Slug string `json:"slug"`
|
||||
ParentId *uint `json:"parentId"`
|
||||
Position *int `json:"position"`
|
||||
LevelGroupId *uint `json:"levelGroupId"`
|
||||
GroupBy *string `json:"groupBy"`
|
||||
ThumbnailUrl *string `json:"thumbnailUrl"`
|
||||
IsActive *bool `json:"isActive"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
|
|
|
|||
|
|
@ -105,13 +105,12 @@ func (_i *ppidDataCategoriesService) AllInPpidData(req request.PpidDataCategorie
|
|||
if findLevel != nil {
|
||||
req.LevelGroupId = &findLevel.ID
|
||||
}
|
||||
} else {
|
||||
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
if createdBy != nil {
|
||||
req.LevelGroupId = &createdBy.UserLevelId
|
||||
}
|
||||
}
|
||||
|
||||
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
if createdBy != nil {
|
||||
req.LevelGroupId = &createdBy.UserLevelId
|
||||
}
|
||||
|
||||
results, paging, err := _i.Repo.GetAll(req)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -174,8 +173,18 @@ func (_i *ppidDataCategoriesService) Save(req request.PpidDataCategoriesCreateRe
|
|||
newReq.Position = lastPosition
|
||||
|
||||
createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
newReq.CreatedById = &createdBy.ID
|
||||
newReq.LevelGroupId = &createdBy.UserLevelId
|
||||
if createdBy != nil {
|
||||
newReq.CreatedById = &createdBy.ID
|
||||
newReq.LevelGroupId = &createdBy.UserLevelId
|
||||
|
||||
userLevels, err := _i.UserLevelsRepo.FindOne(uint(createdBy.UserLevelId))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if userLevels != nil {
|
||||
newReq.GroupBy = userLevels.Group
|
||||
}
|
||||
}
|
||||
|
||||
return _i.Repo.Create(newReq)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3644,6 +3644,11 @@ const docTemplate = `{
|
|||
"name": "description",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "group",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isOnlyTop",
|
||||
|
|
|
|||
|
|
@ -3633,6 +3633,11 @@
|
|||
"name": "description",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "group",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isOnlyTop",
|
||||
|
|
|
|||
|
|
@ -3167,6 +3167,9 @@ paths:
|
|||
- in: query
|
||||
name: description
|
||||
type: string
|
||||
- in: query
|
||||
name: group
|
||||
type: string
|
||||
- in: query
|
||||
name: isOnlyTop
|
||||
type: boolean
|
||||
|
|
|
|||
Loading…
Reference in New Issue