message_personal.go 1.6 KB
package notify

import (
	"time"

	"github.com/linmadan/egglib-go/core/application"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)

// 个人信息提示

type MessagePersonalService struct {
}

func NewMessagePersonalService() *MessagePersonalService {
	newService := &MessagePersonalService{}
	return newService
}

// 获取今天的周期综合自评消息提示
func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *command.GetUserMessageCommand) (interface{}, 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()
	}()

	nowTime := time.Now()
	evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
		"transactionContext": transactionContext,
	})
	_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
		"targetUserId": param.UserId,
		"types":        domain.EvaluationSelf,
		"beginTime":    nowTime,
		"endTime":      nowTime,
		"limit":        20,
	})
	_ = evaluationList
	if err := transactionContext.CommitTransaction(); err != nil {
		return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
	}
	return nil, nil
}