65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package sys
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/api/admin/approval"
|
|
"hotgo/internal/model/input/sysin"
|
|
"hotgo/internal/service"
|
|
)
|
|
|
|
var Approval = cApproval{}
|
|
|
|
type cApproval struct{}
|
|
|
|
func (c *cApproval) List(ctx context.Context, req *approval.ListReq) (res *approval.ListRes, err error) {
|
|
list, totalCount, err := service.SysApproval().List(ctx, &req.ApprovalListInp)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if list == nil {
|
|
list = []*sysin.ApprovalListModel{}
|
|
}
|
|
res = new(approval.ListRes)
|
|
res.List = list
|
|
res.PageRes.Pack(req, totalCount)
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) View(ctx context.Context, req *approval.ViewReq) (res *approval.ViewRes, err error) {
|
|
data, err := service.SysApproval().View(ctx, &req.ApprovalViewInp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res = &approval.ViewRes{ApprovalViewModel: data}
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) Create(ctx context.Context, req *approval.CreateReq) (res *approval.CreateRes, err error) {
|
|
data, err := service.SysApproval().Create(ctx, &req.ApprovalCreateInp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res = &approval.CreateRes{ApprovalCreateModel: data}
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) Submit(ctx context.Context, req *approval.SubmitReq) (res *approval.SubmitRes, err error) {
|
|
err = service.SysApproval().Submit(ctx, &req.ApprovalSubmitInp)
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) Approve(ctx context.Context, req *approval.ApproveReq) (res *approval.ApproveRes, err error) {
|
|
err = service.SysApproval().Approve(ctx, &req.ApprovalDecisionInp)
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) Reject(ctx context.Context, req *approval.RejectReq) (res *approval.RejectRes, err error) {
|
|
err = service.SysApproval().Reject(ctx, &req.ApprovalDecisionInp)
|
|
return
|
|
}
|
|
|
|
func (c *cApproval) Cancel(ctx context.Context, req *approval.CancelReq) (res *approval.CancelRes, err error) {
|
|
err = service.SysApproval().Cancel(ctx, &req.ApprovalCancelInp)
|
|
return
|
|
}
|