mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat(BE): approval_workflow, adjusment project_flocks, common, and migration
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
utils "gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||
approvalutils "gitlab.com/mbugroup/lti-api.git/internal/utils/approvals"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -26,6 +30,50 @@ func (r *ConstantRepositoryImpl) GetConstants() map[string]interface{} {
|
||||
for f := range utils.AllFlagTypes() {
|
||||
flagList = append(flagList, string(f))
|
||||
}
|
||||
sort.Strings(flagList)
|
||||
|
||||
type approvalStepConstant struct {
|
||||
StepNumber uint16 `json:"step_number"`
|
||||
StepName string `json:"step_name"`
|
||||
}
|
||||
|
||||
workflowConstants := approvalutils.WorkflowConstants()
|
||||
workflowKeys := make([]string, 0, len(workflowConstants))
|
||||
for key := range workflowConstants {
|
||||
workflowKeys = append(workflowKeys, key)
|
||||
}
|
||||
sort.Strings(workflowKeys)
|
||||
|
||||
approvalWorkflows := make([]map[string]interface{}, 0, len(workflowKeys))
|
||||
for _, key := range workflowKeys {
|
||||
stepMap := workflowConstants[key]
|
||||
if len(stepMap) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
stepList := make([]approvalStepConstant, 0, len(stepMap))
|
||||
for stepStr, label := range stepMap {
|
||||
stepNum, err := strconv.ParseUint(stepStr, 10, 16)
|
||||
if err != nil || stepNum == 0 {
|
||||
continue
|
||||
}
|
||||
stepList = append(stepList, approvalStepConstant{
|
||||
StepNumber: uint16(stepNum),
|
||||
StepName: label,
|
||||
})
|
||||
}
|
||||
if len(stepList) == 0 {
|
||||
continue
|
||||
}
|
||||
sort.Slice(stepList, func(i, j int) bool {
|
||||
return stepList[i].StepNumber < stepList[j].StepNumber
|
||||
})
|
||||
|
||||
approvalWorkflows = append(approvalWorkflows, map[string]interface{}{
|
||||
"key": key,
|
||||
"steps": stepList,
|
||||
})
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
"flags": flagList,
|
||||
@@ -42,5 +90,6 @@ func (r *ConstantRepositoryImpl) GetConstants() map[string]interface{} {
|
||||
"BISNIS",
|
||||
"INDIVIDUAL",
|
||||
},
|
||||
"approval_workflows": approvalWorkflows,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user