notice_personal.go 5.0 KB
package service

import (
	"github.com/linmadan/egglib-go/core/application"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/query"
)

// 个人消息通知
type NoticePersonalService struct {
}

// 设置消息:共创申请审核通过
func (noticePersonalService *NoticePersonalService) AgreeJoinCreationProject(agreeJoinCreationProjectCommand *command.AgreeJoinCreationProjectCommand) (interface{}, error) {
	if err := agreeJoinCreationProjectCommand.ValidateCommand(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	defer func() {
		transactionContext.RollbackTransaction()
	}()
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	return nil, nil
}

// 获取消息列表
func (noticePersonalService *NoticePersonalService) GetNoticePersonalList(getNoticePersonalListQuery *query.GetNoticePersonalListQuery) (interface{}, error) {
	if err := getNoticePersonalListQuery.ValidateQuery(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	defer func() {
		transactionContext.RollbackTransaction()
	}()
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	return nil, nil
}

// 设置消息:分红预算消息
func (noticePersonalService *NoticePersonalService) InformExpectedDividends(informExpectedDividendsCommand *command.InformExpectedDividendsCommand) (interface{}, error) {
	if err := informExpectedDividendsCommand.ValidateCommand(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	defer func() {
		transactionContext.RollbackTransaction()
	}()
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	return nil, nil
}

// 设置消息:共创确认
func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(informJoinCreationContractCommand *command.InformJoinCreationContractCommand) (interface{}, error) {
	if err := informJoinCreationContractCommand.ValidateCommand(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	defer func() {
		transactionContext.RollbackTransaction()
	}()
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	return nil, nil
}

// 设置消息:共创申请审核拒绝
func (noticePersonalService *NoticePersonalService) RefuseJoinCreationProject(refuseJoinCreationProjectCommand *command.RefuseJoinCreationProjectCommand) (interface{}, error) {
	if err := refuseJoinCreationProjectCommand.ValidateCommand(); err != nil {
		return nil, application.ThrowError(application.ARG_ERROR, err.Error())
	}
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	defer func() {
		transactionContext.RollbackTransaction()
	}()
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
	}
	return nil, nil
}

func NewNoticePersonalService(options map[string]interface{}) *NoticePersonalService {
	newNoticePersonalService := &NoticePersonalService{}
	return newNoticePersonalService
}