作者 tangxvhui

员工确认 分数

package command
// 员工确认 周期评估 分数
type ConfirmScore struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
UserId int `json:"-"`
}
... ...
package service
//定时扫描评估项目表,确认是否下发评估任务
func SendSummaryEvaluationTask() {}
... ...
... ... @@ -1142,3 +1142,45 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
}
return result, nil
}
// 员工确认综评考核结果
func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command.ConfirmScore) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
"id": param.SummaryEvaluationId,
})
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if evaluationData.Types != domain.EvaluationSuper {
return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误")
}
if evaluationData.TargetUser.UserId != param.UserId {
return application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限")
}
if evaluationData.Status == domain.EvaluationUncompleted {
return application.ThrowError(application.TRANSACTION_ERROR, "上级还未正式提交评估内容")
}
evaluationData.CheckResult = domain.EvaluationCheckCompleted
err = evaluationRepo.Save(evaluationData)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -26,3 +26,7 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) {
CreatedAt: time.Now(),
}
}
type LogSmsRepository interface {
Insert(param *LogSms) error
}
... ...
... ... @@ -50,6 +50,7 @@ func init() {
&models.SummaryEvaluation{},
&models.SummaryEvaluationValue{},
&models.Permission{},
&models.LogSms{},
}
for _, model := range tables {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
... ...
... ... @@ -5,9 +5,9 @@ import "time"
type LogSms struct {
tableName struct{} `comment:"记录短信消息" pg:"log_sms"`
Id int `pg:",pk"`
Phone string ``
TemplateId string ``
Template string ``
Value map[string]string ``
CreatedAt time.Time ``
Phone string `pg:"phone"`
TemplateId string `pg:"template_id"`
Template string `pg:"template"`
Value map[string]string `pg:"value"`
CreatedAt time.Time `pg:"createdAt"`
}
... ...
package repository
import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
)
type LogSmsRepository struct {
transactionContext *pgTransaction.TransactionContext
}
func NewLogSmsRepository(transactionContext *pgTransaction.TransactionContext) *LogSmsRepository {
return &LogSmsRepository{transactionContext: transactionContext}
}
var _ domain.LogSmsRepository = (*LogSmsRepository)(nil)
func (repo *LogSmsRepository) Insert(param *domain.LogSms) error {
m := models.LogSms{
Id: param.Id,
Phone: param.Phone,
TemplateId: param.TemplateId,
Template: param.Template,
Value: param.Value,
CreatedAt: param.CreatedAt,
}
tx := repo.transactionContext.PgTx
_, err := tx.Model(&m).Insert()
if err != nil {
return err
}
return nil
}
... ...
... ... @@ -67,11 +67,14 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
_, err := db.Model(&m).Insert()
if err != nil {
return err
}
} else {
m.UpdatedAt = time.Now()
_, err := db.Model(&m).Update()
if err != nil {
return err
... ...
... ... @@ -51,11 +51,14 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
_, err := db.Model(&m).Insert()
if err != nil {
return err
}
} else {
m.UpdatedAt = time.Now()
_, err := db.Model(&m).Update()
if err != nil {
return err
... ...