58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package serializer
|
|
|
|
import (
|
|
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
|
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
|
)
|
|
|
|
//BuildApproval 处理单个detail返回
|
|
func BuildApproval(entity *model.Approval, userId uint64) *approval.CreateRequest {
|
|
var work *approval.Work
|
|
var show *approval.Show
|
|
var exhibition *approval.Exhibition
|
|
var bundle *approval.Bundle
|
|
isViewed := false
|
|
|
|
copyUsers := model.FormatToResponse(entity.CopyUsers)
|
|
|
|
for _, cu := range copyUsers {
|
|
if userId != 0 && cu.ID == userId && cu.IsViewed == true {
|
|
isViewed = true
|
|
}
|
|
}
|
|
|
|
response := &approval.CreateRequest{
|
|
ID: entity.ID,
|
|
Domain: *entity.Domain,
|
|
Status: uint64(entity.Status),
|
|
Type: entity.Type,
|
|
ApproverID: entity.ApproverID,
|
|
ApproverName: entity.ApproverName,
|
|
CopyUsers: copyUsers,
|
|
SubmitterID: entity.SubmitterID,
|
|
SubmitterName: entity.SubmitterName,
|
|
Content: entity.Content,
|
|
IsViewed: isViewed,
|
|
Reply: entity.Reply,
|
|
Work: work,
|
|
Show: show,
|
|
Exhibition: exhibition,
|
|
Bundle: bundle,
|
|
}
|
|
|
|
_ = entity.SetResContent(response)
|
|
|
|
return response
|
|
}
|
|
|
|
//BuildApprovals 处理单个detail返回
|
|
func BuildApprovals(list []*model.Approval, userId uint64) (details []*approval.CreateRequest) {
|
|
|
|
for _, item := range list {
|
|
temp := BuildApproval(item, userId)
|
|
details = append(details, temp)
|
|
}
|
|
|
|
return details
|
|
}
|