feat: fixing ppid data, users, master menu, etc
This commit is contained in:
parent
b85349e9d8
commit
bdc5b02c07
|
|
@ -7,8 +7,9 @@ type MasterMenus struct {
|
||||||
Name string `json:"name" gorm:"type:varchar"`
|
Name string `json:"name" gorm:"type:varchar"`
|
||||||
Description string `json:"description" gorm:"type:varchar"`
|
Description string `json:"description" gorm:"type:varchar"`
|
||||||
ModuleId int `json:"module_id" gorm:"type:int4"`
|
ModuleId int `json:"module_id" gorm:"type:int4"`
|
||||||
ParentMenuId int `json:"parent_menu_id" gorm:"type:int4"`
|
ParentMenuId *int `json:"parent_menu_id" gorm:"type:int4"`
|
||||||
Icon string `json:"icon" gorm:"type:varchar"`
|
Icon *string `json:"icon" gorm:"type:varchar"`
|
||||||
|
Group string `json:"group" gorm:"type:varchar"`
|
||||||
Position *int `json:"position" gorm:"type:int4"`
|
Position *int `json:"position" gorm:"type:int4"`
|
||||||
StatusId int `json:"status_id" gorm:"type:int4"`
|
StatusId int `json:"status_id" gorm:"type:int4"`
|
||||||
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ type PpidDatas struct {
|
||||||
Slug string `json:"slug" gorm:"type:varchar"`
|
Slug string `json:"slug" gorm:"type:varchar"`
|
||||||
CategoryId uint `json:"category_id" gorm:"type:int4"`
|
CategoryId uint `json:"category_id" gorm:"type:int4"`
|
||||||
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
||||||
LevelGroupId *int `json:"level_group_id" gorm:"type:int4"`
|
LevelGroupId *uint `json:"level_group_id" gorm:"type:int4"`
|
||||||
Group *string `json:"group" gorm:"type:varchar"`
|
Group *string `json:"group" gorm:"type:varchar"`
|
||||||
NeedApprovalFromUserRole *string `json:"need_approval_from_user_role" gorm:"type:varchar"`
|
NeedApprovalFromUserRole *string `json:"need_approval_from_user_role" gorm:"type:varchar"`
|
||||||
NeedApprovalFromUserLevel *string `json:"need_approval_from_user_level" gorm:"type:varchar"`
|
NeedApprovalFromUserLevel *string `json:"need_approval_from_user_level" gorm:"type:varchar"`
|
||||||
BackApprovalToUserRole *int `json:"back_approval_to_user_role" gorm:"type:varchar"`
|
BackApprovalToUserRole *string `json:"back_approval_to_user_role" gorm:"type:varchar"`
|
||||||
BackApprovalToUserLevel *int `json:"back_approval_to_user_level" gorm:"type:varchar"`
|
BackApprovalToUserLevel *string `json:"back_approval_to_user_level" gorm:"type:varchar"`
|
||||||
IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"`
|
IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"`
|
||||||
PublishLevel *int `json:"publish_level" gorm:"type:int4"`
|
PublishLevel *int `json:"publish_level" gorm:"type:int4"`
|
||||||
PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"`
|
PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"`
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ type Users struct {
|
||||||
IdentityNumber string `json:"identity_number" gorm:"type:varchar"`
|
IdentityNumber string `json:"identity_number" gorm:"type:varchar"`
|
||||||
DateOfBirth string `json:"date_of_birth" gorm:"type:varchar"`
|
DateOfBirth string `json:"date_of_birth" gorm:"type:varchar"`
|
||||||
LastEducation string `json:"last_education" gorm:"type:varchar"`
|
LastEducation string `json:"last_education" gorm:"type:varchar"`
|
||||||
UserRoleId int `json:"user_role_id" gorm:"type:int4"`
|
UserRoleId uint `json:"user_role_id" gorm:"type:int4"`
|
||||||
UserLevelId int `json:"user_level_id" gorm:"type:int4"`
|
UserLevelId uint `json:"user_level_id" gorm:"type:int4"`
|
||||||
KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"`
|
KeycloakId *string `json:"keycloak_id" gorm:"type:varchar"`
|
||||||
StatusId *int `json:"status_id" gorm:"type:int4;default:1"`
|
StatusId *int `json:"status_id" gorm:"type:int4;default:1"`
|
||||||
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type masterMenusRepository struct {
|
||||||
type MasterMenusRepository interface {
|
type MasterMenusRepository interface {
|
||||||
GetAll(req request.MasterMenusQueryRequest) (masterMenuss []*entity.MasterMenus, paging paginator.Pagination, err error)
|
GetAll(req request.MasterMenusQueryRequest) (masterMenuss []*entity.MasterMenus, paging paginator.Pagination, err error)
|
||||||
FindOne(id uint) (masterMenus *entity.MasterMenus, err error)
|
FindOne(id uint) (masterMenus *entity.MasterMenus, err error)
|
||||||
|
FindLastMenuPosition() (position *int, err error)
|
||||||
Create(masterMenus *entity.MasterMenus) (err error)
|
Create(masterMenus *entity.MasterMenus) (err error)
|
||||||
Update(id uint, masterMenus *entity.MasterMenus) (err error)
|
Update(id uint, masterMenus *entity.MasterMenus) (err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
|
|
@ -83,6 +84,15 @@ func (_i *masterMenusRepository) FindOne(id uint) (masterMenus *entity.MasterMen
|
||||||
return masterMenus, nil
|
return masterMenus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_i *masterMenusRepository) FindLastMenuPosition() (position *int, err error) {
|
||||||
|
var masterMenus *entity.MasterMenus
|
||||||
|
if err := _i.DB.DB.Where("position IS NOT NULL").Order(fmt.Sprintf("%s %s", "position", "DESC")).First(&masterMenus).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return masterMenus.Position, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *masterMenusRepository) Create(masterMenus *entity.MasterMenus) (err error) {
|
func (_i *masterMenusRepository) Create(masterMenus *entity.MasterMenus) (err error) {
|
||||||
return _i.DB.DB.Create(masterMenus).Error
|
return _i.DB.DB.Create(masterMenus).Error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ type MasterMenusCreateRequest struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
ModuleId int `json:"moduleId" validate:"required"`
|
ModuleId int `json:"moduleId" validate:"required"`
|
||||||
ParentMenuId int `json:"parentMenuId" validate:"required"`
|
Group string `json:"group" validate:"required"`
|
||||||
Icon string `json:"icon" validate:"required"`
|
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
Position *int `json:"position"`
|
ParentMenuId *int `json:"parentMenuId"`
|
||||||
|
Icon *string `json:"icon"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req MasterMenusCreateRequest) ToEntity() *entity.MasterMenus {
|
func (req MasterMenusCreateRequest) ToEntity() *entity.MasterMenus {
|
||||||
|
|
@ -37,7 +37,7 @@ func (req MasterMenusCreateRequest) ToEntity() *entity.MasterMenus {
|
||||||
ModuleId: req.ModuleId,
|
ModuleId: req.ModuleId,
|
||||||
ParentMenuId: req.ParentMenuId,
|
ParentMenuId: req.ParentMenuId,
|
||||||
Icon: req.Icon,
|
Icon: req.Icon,
|
||||||
Position: req.Position,
|
Group: req.Group,
|
||||||
StatusId: req.StatusId,
|
StatusId: req.StatusId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,10 +47,10 @@ type MasterMenusUpdateRequest struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
ModuleId int `json:"moduleId" validate:"required"`
|
ModuleId int `json:"moduleId" validate:"required"`
|
||||||
ParentMenuId int `json:"parentMenuId" validate:"required"`
|
Group string `json:"group" validate:"required"`
|
||||||
Icon string `json:"icon" validate:"required"`
|
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
Position *int `json:"position"`
|
ParentMenuId *int `json:"parentMenuId"`
|
||||||
|
Icon *string `json:"icon"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (req MasterMenusUpdateRequest) ToEntity() *entity.MasterMenus {
|
||||||
ModuleId: req.ModuleId,
|
ModuleId: req.ModuleId,
|
||||||
ParentMenuId: req.ParentMenuId,
|
ParentMenuId: req.ParentMenuId,
|
||||||
Icon: req.Icon,
|
Icon: req.Icon,
|
||||||
Position: req.Position,
|
Group: req.Group,
|
||||||
StatusId: req.StatusId,
|
StatusId: req.StatusId,
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ type MasterMenusResponse struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
ModuleId int `json:"module_id"`
|
ModuleId int `json:"module_id"`
|
||||||
ParentMenuId int `json:"parent_menu_id"`
|
ParentMenuId *int `json:"parent_menu_id"`
|
||||||
Icon string `json:"icon"`
|
Icon *string `json:"icon"`
|
||||||
Position *int `json:"position"`
|
Position *int `json:"position"`
|
||||||
StatusId int `json:"status_id"`
|
StatusId int `json:"status_id"`
|
||||||
IsActive *bool `json:"is_active"`
|
IsActive *bool `json:"is_active"`
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,18 @@ func (_i *masterMenusService) Show(id uint) (masterMenus *response.MasterMenusRe
|
||||||
func (_i *masterMenusService) Save(req request.MasterMenusCreateRequest) (err error) {
|
func (_i *masterMenusService) Save(req request.MasterMenusCreateRequest) (err error) {
|
||||||
_i.Log.Info().Interface("data", req).Msg("")
|
_i.Log.Info().Interface("data", req).Msg("")
|
||||||
|
|
||||||
return _i.Repo.Create(req.ToEntity())
|
newReq := req.ToEntity()
|
||||||
|
var latestPosition, _ = _i.Repo.FindLastMenuPosition()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*latestPosition = *latestPosition + 1
|
||||||
|
|
||||||
|
if latestPosition != nil {
|
||||||
|
newReq.Position = latestPosition
|
||||||
|
}
|
||||||
|
|
||||||
|
return _i.Repo.Create(newReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *masterMenusService) Update(id uint, req request.MasterMenusUpdateRequest) (err error) {
|
func (_i *masterMenusService) Update(id uint, req request.MasterMenusUpdateRequest) (err error) {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ func NewPpidDatasController(ppidDatasService service.PpidDatasService) PpidDatas
|
||||||
// @Description API for getting all PpidDatas
|
// @Description API for getting all PpidDatas
|
||||||
// @Tags PPID Data
|
// @Tags PPID Data
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
|
// @Param Authorization header string true "Insert your access token" default(Bearer <Add access token here>)
|
||||||
// @Param req query request.PpidDatasQueryRequest false "query parameters"
|
// @Param req query request.PpidDatasQueryRequest false "query parameters"
|
||||||
// @Param req query paginator.Pagination false "pagination parameters"
|
// @Param req query paginator.Pagination false "pagination parameters"
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
|
|
@ -49,11 +50,15 @@ func (_i *ppidDatasController) All(c *fiber.Ctx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authToken := c.Get("Authorization")
|
||||||
|
|
||||||
reqContext := request.PpidDatasQueryRequestContext{
|
reqContext := request.PpidDatasQueryRequestContext{
|
||||||
Title: c.Query("title"),
|
Title: c.Query("title"),
|
||||||
Description: c.Query("description"),
|
Description: c.Query("description"),
|
||||||
CategoryId: c.Query("categoryId"),
|
CategoryId: c.Query("categoryId"),
|
||||||
CreatedById: c.Query("createdById"),
|
UserId: c.Query("userId"),
|
||||||
|
UserRoleId: c.Query("userRoleId"),
|
||||||
|
UserLevelId: c.Query("userLevelId"),
|
||||||
StatusId: c.Query("statusId"),
|
StatusId: c.Query("statusId"),
|
||||||
IsPublish: c.Query("isPublish"),
|
IsPublish: c.Query("isPublish"),
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +66,7 @@ func (_i *ppidDatasController) All(c *fiber.Ctx) error {
|
||||||
req := reqContext.ToParamRequest()
|
req := reqContext.ToParamRequest()
|
||||||
req.Pagination = paginate
|
req.Pagination = paginate
|
||||||
|
|
||||||
ppidDatasData, paging, err := _i.ppidDatasService.All(req)
|
ppidDatasData, paging, err := _i.ppidDatasService.All(req, authToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"go-humas-be/app/database/entity"
|
"go-humas-be/app/database/entity"
|
||||||
"go-humas-be/app/module/ppid_datas/request"
|
"go-humas-be/app/module/ppid_datas/request"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -61,8 +62,15 @@ func (_i *ppidDatasRepository) GetAll(req request.PpidDatasQueryRequest) (ppidDa
|
||||||
if req.StatusId != nil {
|
if req.StatusId != nil {
|
||||||
query = query.Where("status_id = ?", req.StatusId)
|
query = query.Where("status_id = ?", req.StatusId)
|
||||||
}
|
}
|
||||||
if req.CreatedById != nil {
|
if req.UserId != nil {
|
||||||
query = query.Where("created_by_id = ?", req.CreatedById)
|
userRoleIdStr := strconv.Itoa(int(*req.UserRoleId))
|
||||||
|
userLevelIdStr := strconv.Itoa(int(*req.UserLevelId))
|
||||||
|
query = query.
|
||||||
|
Where("created_by_id = ?", req.UserId).
|
||||||
|
Or("need_approval_from_user_role LIKE ?", ":"+userRoleIdStr+":").
|
||||||
|
Or("need_approval_from_user_level LIKE ?", userLevelIdStr).
|
||||||
|
Or("back_approval_to_user_role = ?", userRoleIdStr).
|
||||||
|
Or("back_approval_to_user_level = ?", userLevelIdStr)
|
||||||
}
|
}
|
||||||
query.Count(&count)
|
query.Count(&count)
|
||||||
|
|
||||||
|
|
@ -77,7 +85,11 @@ func (_i *ppidDatasRepository) GetAll(req request.PpidDatasQueryRequest) (ppidDa
|
||||||
req.Pagination.Count = count
|
req.Pagination.Count = count
|
||||||
req.Pagination = paginator.Paging(req.Pagination)
|
req.Pagination = paginator.Paging(req.Pagination)
|
||||||
|
|
||||||
err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&ppidDatass).Error
|
if req.Pagination.Limit == 0 {
|
||||||
|
query.Limit(req.Pagination.Limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = query.Offset(req.Pagination.Offset).Find(&ppidDatass).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ type PpidDatasQueryRequest struct {
|
||||||
CategoryId *int `json:"categoryId"`
|
CategoryId *int `json:"categoryId"`
|
||||||
LevelGroupId *int `json:"levelGroupId"`
|
LevelGroupId *int `json:"levelGroupId"`
|
||||||
Group *string `json:"group"`
|
Group *string `json:"group"`
|
||||||
CreatedById *int `json:"createdById"`
|
UserId *uint `json:"userId"`
|
||||||
|
UserRoleId *uint `json:"userRoleId"`
|
||||||
|
UserLevelId *uint `json:"userLevelId"`
|
||||||
StatusId *int `json:"statusId"`
|
StatusId *int `json:"statusId"`
|
||||||
IsPublish *bool `json:"isPublish"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
Pagination *paginator.Pagination `json:"pagination"`
|
Pagination *paginator.Pagination `json:"pagination"`
|
||||||
|
|
@ -29,7 +31,7 @@ type PpidDatasCreateRequest struct {
|
||||||
Slug string `json:"slug" validate:"required"`
|
Slug string `json:"slug" validate:"required"`
|
||||||
CategoryId uint `json:"categoryId" validate:"required"`
|
CategoryId uint `json:"categoryId" validate:"required"`
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
LevelGroupId *int `json:"levelGroupId"`
|
LevelGroupId *uint `json:"levelGroupId"`
|
||||||
Group *string `json:"group"`
|
Group *string `json:"group"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,12 +56,12 @@ type PpidDatasUpdateRequest struct {
|
||||||
StatusId int `json:"statusId" validate:"required"`
|
StatusId int `json:"statusId" validate:"required"`
|
||||||
NeedApprovalFromUserRole *string `json:"needApprovalFrom"`
|
NeedApprovalFromUserRole *string `json:"needApprovalFrom"`
|
||||||
NeedApprovalFromUserLevel *string `json:"needApprovalFromUserLevel"`
|
NeedApprovalFromUserLevel *string `json:"needApprovalFromUserLevel"`
|
||||||
BackApprovalToUserRole *int `json:"backApprovalToUserRole"`
|
BackApprovalToUserRole *string `json:"backApprovalToUserRole"`
|
||||||
BackApprovalToUserLevel *int `json:"backApprovalToUserLevel"`
|
BackApprovalToUserLevel *string `json:"backApprovalToUserLevel"`
|
||||||
IsPublish *bool `json:"isPublish"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
PublishLevel *int `json:"publishLevel"`
|
PublishLevel *int `json:"publishLevel"`
|
||||||
PublishedAt *time.Time `json:"publishedAt"`
|
PublishedAt *time.Time `json:"publishedAt"`
|
||||||
LevelGroupId *int `json:"levelGroupId"`
|
LevelGroupId *uint `json:"levelGroupId"`
|
||||||
Group *string `json:"group"`
|
Group *string `json:"group"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,6 +91,9 @@ type PpidDatasQueryRequestContext struct {
|
||||||
CategoryId string `json:"categoryId"`
|
CategoryId string `json:"categoryId"`
|
||||||
Group string `json:"group"`
|
Group string `json:"group"`
|
||||||
CreatedById string `json:"createdById"`
|
CreatedById string `json:"createdById"`
|
||||||
|
UserId string `json:"userId"`
|
||||||
|
UserRoleId string `json:"userRoleId"`
|
||||||
|
UserLevelId string `json:"userLevelId"`
|
||||||
StatusId string `json:"statusId"`
|
StatusId string `json:"statusId"`
|
||||||
IsPublish string `json:"isPublish"`
|
IsPublish string `json:"isPublish"`
|
||||||
}
|
}
|
||||||
|
|
@ -123,10 +128,25 @@ func (req PpidDatasQueryRequestContext) ToParamRequest() PpidDatasQueryRequest {
|
||||||
request.StatusId = &statusId
|
request.StatusId = &statusId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if createdByIdStr := req.CreatedById; createdByIdStr != "" {
|
if userIdStr := req.UserId; userIdStr != "" {
|
||||||
createdById, err := strconv.Atoi(createdByIdStr)
|
userId, err := strconv.Atoi(userIdStr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
request.CreatedById = &createdById
|
userIdUint := uint(userId)
|
||||||
|
request.UserId = &userIdUint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if userRoleIdStr := req.UserRoleId; userRoleIdStr != "" {
|
||||||
|
userRoleId, err := strconv.Atoi(userRoleIdStr)
|
||||||
|
if err == nil {
|
||||||
|
userRoleIdUint := uint(userRoleId)
|
||||||
|
request.UserRoleId = &userRoleIdUint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if userLevelIdStr := req.UserLevelId; userLevelIdStr != "" {
|
||||||
|
userLevelId, err := strconv.Atoi(userLevelIdStr)
|
||||||
|
if err == nil {
|
||||||
|
userLevelIdUint := uint(userLevelId)
|
||||||
|
request.UserLevelId = &userLevelIdUint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ type ppidDatasService struct {
|
||||||
|
|
||||||
// PpidDatasService define interface of IPpidDatasService
|
// PpidDatasService define interface of IPpidDatasService
|
||||||
type PpidDatasService interface {
|
type PpidDatasService interface {
|
||||||
All(req request.PpidDatasQueryRequest) (ppidDatas []*response.PpidDatasResponse, paging paginator.Pagination, err error)
|
All(req request.PpidDatasQueryRequest, authToken string) (ppidDatas []*response.PpidDatasResponse, paging paginator.Pagination, err error)
|
||||||
Show(id string) (ppidDatas *response.PpidDatasResponse, err error)
|
Show(id string) (ppidDatas *response.PpidDatasResponse, err error)
|
||||||
Save(req request.PpidDatasCreateRequest, authToken string) (ppidDatas *entity.PpidDatas, err error)
|
Save(req request.PpidDatasCreateRequest, authToken string) (ppidDatas *entity.PpidDatas, err error)
|
||||||
Update(id uint, req request.PpidDatasUpdateRequest) (err error)
|
Update(id uint, req request.PpidDatasUpdateRequest) (err error)
|
||||||
|
|
@ -64,7 +64,13 @@ func NewPpidDatasService(
|
||||||
}
|
}
|
||||||
|
|
||||||
// All implement interface of PpidDatasService
|
// All implement interface of PpidDatasService
|
||||||
func (_i *ppidDatasService) All(req request.PpidDatasQueryRequest) (ppidDatass []*response.PpidDatasResponse, paging paginator.Pagination, err error) {
|
func (_i *ppidDatasService) All(req request.PpidDatasQueryRequest, authToken string) (ppidDatass []*response.PpidDatasResponse, paging paginator.Pagination, err error) {
|
||||||
|
|
||||||
|
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||||
|
req.UserId = &user.ID
|
||||||
|
req.UserRoleId = &user.UserRoleId
|
||||||
|
req.UserLevelId = &user.UserLevelId
|
||||||
|
|
||||||
results, paging, err := _i.Repo.GetAll(req)
|
results, paging, err := _i.Repo.GetAll(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -170,17 +176,17 @@ func (_i *ppidDatasService) UpdateApprovalStatus(req requestPpidApproval.PpidDat
|
||||||
roleId := strconv.FormatUint(uint64(role.UserRoleId), 10)
|
roleId := strconv.FormatUint(uint64(role.UserRoleId), 10)
|
||||||
needApprovalFromUserRole = append(needApprovalFromUserRole, roleId)
|
needApprovalFromUserRole = append(needApprovalFromUserRole, roleId)
|
||||||
}
|
}
|
||||||
needApprovalFromUserRoleStr := strings.Join(needApprovalFromUserRole, "/")
|
needApprovalFromUserRoleStr := strings.Join(needApprovalFromUserRole, ":")
|
||||||
ppidData.NeedApprovalFromUserRole = &needApprovalFromUserRoleStr
|
*ppidData.NeedApprovalFromUserRole = ":" + needApprovalFromUserRoleStr + ":"
|
||||||
}
|
}
|
||||||
} else if req.ApprovalStatusId == 2 {
|
} else if req.ApprovalStatusId == 2 {
|
||||||
createdBy, _ := _i.UsersRepo.FindOne(*ppidData.CreatedById)
|
createdBy, _ := _i.UsersRepo.FindOne(*ppidData.CreatedById)
|
||||||
if createdBy != nil {
|
if createdBy != nil {
|
||||||
needApprovalFromUserLevel := strconv.FormatUint(uint64(createdBy.UserLevelId), 10)
|
backApprovalFromUserRole := strconv.FormatUint(uint64(createdBy.UserRoleId), 10)
|
||||||
ppidData.NeedApprovalFromUserLevel = &needApprovalFromUserLevel
|
ppidData.BackApprovalToUserRole = &backApprovalFromUserRole
|
||||||
|
|
||||||
needApprovalFromUserRole := strconv.FormatUint(uint64(createdBy.UserRoleId), 10)
|
needApprovalFromUserLevel := strconv.FormatUint(uint64(createdBy.UserLevelId), 10)
|
||||||
ppidData.NeedApprovalFromUserRole = &needApprovalFromUserRole
|
ppidData.BackApprovalToUserLevel = &needApprovalFromUserLevel
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isPublish := false
|
isPublish := false
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ type UsersCreateRequest struct {
|
||||||
IdentityNumber string `json:"identityNumber" validate:"required"`
|
IdentityNumber string `json:"identityNumber" validate:"required"`
|
||||||
DateOfBirth string `json:"dateOfBirth" validate:"required"`
|
DateOfBirth string `json:"dateOfBirth" validate:"required"`
|
||||||
LastEducation string `json:"lastEducation" validate:"required"`
|
LastEducation string `json:"lastEducation" validate:"required"`
|
||||||
UserRoleId int `json:"userRoleId" validate:"required"`
|
UserRoleId uint `json:"userRoleId" validate:"required"`
|
||||||
UserLevelId int `json:"userLevelId" validate:"required"`
|
UserLevelId uint `json:"userLevelId" validate:"required"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,8 +69,8 @@ type UsersUpdateRequest struct {
|
||||||
IdentityNumber string `json:"identityNumber" validate:"required"`
|
IdentityNumber string `json:"identityNumber" validate:"required"`
|
||||||
DateOfBirth string `json:"dateOfBirth" validate:"required"`
|
DateOfBirth string `json:"dateOfBirth" validate:"required"`
|
||||||
LastEducation string `json:"lastEducation" validate:"required"`
|
LastEducation string `json:"lastEducation" validate:"required"`
|
||||||
UserRoleId int `json:"userRoleId" validate:"required"`
|
UserRoleId uint `json:"userRoleId" validate:"required"`
|
||||||
UserLevelId int `json:"userLevelId" validate:"required"`
|
UserLevelId uint `json:"userLevelId" validate:"required"`
|
||||||
StatusId *int `json:"statusId"`
|
StatusId *int `json:"statusId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ type UsersResponse struct {
|
||||||
DateOfBirth string `json:"dateOfBirth"`
|
DateOfBirth string `json:"dateOfBirth"`
|
||||||
LastEducation string `json:"lastEducation"`
|
LastEducation string `json:"lastEducation"`
|
||||||
KeycloakId *string `json:"keycloakId"`
|
KeycloakId *string `json:"keycloakId"`
|
||||||
UserRoleId int `json:"userRoleId"`
|
UserRoleId uint `json:"userRoleId"`
|
||||||
StatusId *int `json:"status_id"`
|
UserLevelId uint `json:"userLevelId"`
|
||||||
UserLevelId int `json:"userLevelId"`
|
StatusId *int `json:"statusId"`
|
||||||
CreatedById *uint `json:"createdById"`
|
CreatedById *uint `json:"createdById"`
|
||||||
ProfilePicturePath *string `json:"profilePicturePath"`
|
ProfilePicturePath *string `json:"profilePicturePath"`
|
||||||
IsActive *bool `json:"isActive"`
|
IsActive *bool `json:"isActive"`
|
||||||
|
|
|
||||||
|
|
@ -4471,13 +4471,16 @@ const docTemplate = `{
|
||||||
"summary": "Get all PpidDatas",
|
"summary": "Get all PpidDatas",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "string",
|
||||||
"name": "categoryId",
|
"default": "Bearer \u003cAdd access token here\u003e",
|
||||||
"in": "query"
|
"description": "Insert your access token",
|
||||||
|
"name": "Authorization",
|
||||||
|
"in": "header",
|
||||||
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"name": "createdById",
|
"name": "categoryId",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -4510,6 +4513,21 @@ const docTemplate = `{
|
||||||
"name": "title",
|
"name": "title",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userLevelId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userRoleId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"name": "count",
|
"name": "count",
|
||||||
|
|
@ -6859,16 +6877,18 @@ const docTemplate = `{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"description",
|
"description",
|
||||||
"icon",
|
"group",
|
||||||
"moduleId",
|
"moduleId",
|
||||||
"name",
|
"name",
|
||||||
"parentMenuId",
|
|
||||||
"statusId"
|
"statusId"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"group": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -6881,9 +6901,6 @@ const docTemplate = `{
|
||||||
"parentMenuId": {
|
"parentMenuId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"position": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"statusId": {
|
"statusId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4460,13 +4460,16 @@
|
||||||
"summary": "Get all PpidDatas",
|
"summary": "Get all PpidDatas",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "string",
|
||||||
"name": "categoryId",
|
"default": "Bearer \u003cAdd access token here\u003e",
|
||||||
"in": "query"
|
"description": "Insert your access token",
|
||||||
|
"name": "Authorization",
|
||||||
|
"in": "header",
|
||||||
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"name": "createdById",
|
"name": "categoryId",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -4499,6 +4502,21 @@
|
||||||
"name": "title",
|
"name": "title",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userLevelId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"name": "userRoleId",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"name": "count",
|
"name": "count",
|
||||||
|
|
@ -6848,16 +6866,18 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"description",
|
"description",
|
||||||
"icon",
|
"group",
|
||||||
"moduleId",
|
"moduleId",
|
||||||
"name",
|
"name",
|
||||||
"parentMenuId",
|
|
||||||
"statusId"
|
"statusId"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"group": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -6870,9 +6890,6 @@
|
||||||
"parentMenuId": {
|
"parentMenuId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"position": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"statusId": {
|
"statusId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,8 @@ definitions:
|
||||||
properties:
|
properties:
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
|
group:
|
||||||
|
type: string
|
||||||
icon:
|
icon:
|
||||||
type: string
|
type: string
|
||||||
moduleId:
|
moduleId:
|
||||||
|
|
@ -177,16 +179,13 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
parentMenuId:
|
parentMenuId:
|
||||||
type: integer
|
type: integer
|
||||||
position:
|
|
||||||
type: integer
|
|
||||||
statusId:
|
statusId:
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- description
|
- description
|
||||||
- icon
|
- group
|
||||||
- moduleId
|
- moduleId
|
||||||
- name
|
- name
|
||||||
- parentMenuId
|
|
||||||
- statusId
|
- statusId
|
||||||
type: object
|
type: object
|
||||||
request.MasterModulesCreateRequest:
|
request.MasterModulesCreateRequest:
|
||||||
|
|
@ -3435,12 +3434,15 @@ paths:
|
||||||
get:
|
get:
|
||||||
description: API for getting all PpidDatas
|
description: API for getting all PpidDatas
|
||||||
parameters:
|
parameters:
|
||||||
|
- default: Bearer <Add access token here>
|
||||||
|
description: Insert your access token
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: categoryId
|
name: categoryId
|
||||||
type: integer
|
type: integer
|
||||||
- in: query
|
|
||||||
name: createdById
|
|
||||||
type: integer
|
|
||||||
- in: query
|
- in: query
|
||||||
name: description
|
name: description
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -3459,6 +3461,15 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: title
|
name: title
|
||||||
type: string
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: userId
|
||||||
|
type: integer
|
||||||
|
- in: query
|
||||||
|
name: userLevelId
|
||||||
|
type: integer
|
||||||
|
- in: query
|
||||||
|
name: userRoleId
|
||||||
|
type: integer
|
||||||
- in: query
|
- in: query
|
||||||
name: count
|
name: count
|
||||||
type: integer
|
type: integer
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue