package workflow

import (
	"server/dao"
	"server/model/common/request"
)

type ProcessService struct{}

func (ps *ProcessService) QueryAllProcess() ([]dao.Process, error) {
	return dao.QueryAllProcess()
}

func (ps *ProcessService) QueryProcessList(info request.PageInfo) (list interface{}, total int64, err error) {
	limit := info.PageSize
	offset := info.PageSize * (info.Page - 1)
	processes, total, err := dao.QueryProcessList(limit, offset)
	return processes, total, err
}

func (ps *ProcessService) CreateProcess(process request.CreateProcess) error {
	return dao.CreateProcess(process.Process, process.ProcessNodes)
}

func (ps *ProcessService) UpdateProcess(process request.CreateProcess) error {
	return dao.UpdateProcess(process.Process, process.ProcessNodes)
}

func (ps *ProcessService) DeleteProcess(process dao.Process) error {
	return process.DeleteProcess()
}
