正在显示
9 个修改的文件
包含
103 行增加
和
5 行删除
| @@ -1142,3 +1142,45 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | @@ -1142,3 +1142,45 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | ||
| 1142 | } | 1142 | } |
| 1143 | return result, nil | 1143 | return result, nil |
| 1144 | } | 1144 | } |
| 1145 | + | ||
| 1146 | +// 员工确认综评考核结果 | ||
| 1147 | +func (srv *SummaryEvaluationService) ConfirmScoreSuperEvaluation(param *command.ConfirmScore) error { | ||
| 1148 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1149 | + if err != nil { | ||
| 1150 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1151 | + } | ||
| 1152 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 1153 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1154 | + } | ||
| 1155 | + defer func() { | ||
| 1156 | + _ = transactionContext.RollbackTransaction() | ||
| 1157 | + }() | ||
| 1158 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
| 1159 | + "transactionContext": transactionContext, | ||
| 1160 | + }) | ||
| 1161 | + | ||
| 1162 | + evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | ||
| 1163 | + "id": param.SummaryEvaluationId, | ||
| 1164 | + }) | ||
| 1165 | + if err != nil { | ||
| 1166 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1167 | + } | ||
| 1168 | + if evaluationData.Types != domain.EvaluationSuper { | ||
| 1169 | + return application.ThrowError(application.TRANSACTION_ERROR, "操作方式错误") | ||
| 1170 | + } | ||
| 1171 | + if evaluationData.TargetUser.UserId != param.UserId { | ||
| 1172 | + return application.ThrowError(application.TRANSACTION_ERROR, "没有操作权限") | ||
| 1173 | + } | ||
| 1174 | + if evaluationData.Status == domain.EvaluationUncompleted { | ||
| 1175 | + return application.ThrowError(application.TRANSACTION_ERROR, "上级还未正式提交评估内容") | ||
| 1176 | + } | ||
| 1177 | + evaluationData.CheckResult = domain.EvaluationCheckCompleted | ||
| 1178 | + err = evaluationRepo.Save(evaluationData) | ||
| 1179 | + if err != nil { | ||
| 1180 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1181 | + } | ||
| 1182 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1183 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1184 | + } | ||
| 1185 | + return nil | ||
| 1186 | +} |
| @@ -26,3 +26,7 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | @@ -26,3 +26,7 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) { | ||
| 26 | CreatedAt: time.Now(), | 26 | CreatedAt: time.Now(), |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | + | ||
| 30 | +type LogSmsRepository interface { | ||
| 31 | + Insert(param *LogSms) error | ||
| 32 | +} |
| @@ -50,6 +50,7 @@ func init() { | @@ -50,6 +50,7 @@ func init() { | ||
| 50 | &models.SummaryEvaluation{}, | 50 | &models.SummaryEvaluation{}, |
| 51 | &models.SummaryEvaluationValue{}, | 51 | &models.SummaryEvaluationValue{}, |
| 52 | &models.Permission{}, | 52 | &models.Permission{}, |
| 53 | + &models.LogSms{}, | ||
| 53 | } | 54 | } |
| 54 | for _, model := range tables { | 55 | for _, model := range tables { |
| 55 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 56 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
| @@ -5,9 +5,9 @@ import "time" | @@ -5,9 +5,9 @@ import "time" | ||
| 5 | type LogSms struct { | 5 | type LogSms struct { |
| 6 | tableName struct{} `comment:"记录短信消息" pg:"log_sms"` | 6 | tableName struct{} `comment:"记录短信消息" pg:"log_sms"` |
| 7 | Id int `pg:",pk"` | 7 | Id int `pg:",pk"` |
| 8 | - Phone string `` | ||
| 9 | - TemplateId string `` | ||
| 10 | - Template string `` | ||
| 11 | - Value map[string]string `` | ||
| 12 | - CreatedAt time.Time `` | 8 | + Phone string `pg:"phone"` |
| 9 | + TemplateId string `pg:"template_id"` | ||
| 10 | + Template string `pg:"template"` | ||
| 11 | + Value map[string]string `pg:"value"` | ||
| 12 | + CreatedAt time.Time `pg:"createdAt"` | ||
| 13 | } | 13 | } |
| 1 | package repository | 1 | package repository |
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +type LogSmsRepository struct { | ||
| 10 | + transactionContext *pgTransaction.TransactionContext | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +func NewLogSmsRepository(transactionContext *pgTransaction.TransactionContext) *LogSmsRepository { | ||
| 14 | + return &LogSmsRepository{transactionContext: transactionContext} | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +var _ domain.LogSmsRepository = (*LogSmsRepository)(nil) | ||
| 18 | + | ||
| 19 | +func (repo *LogSmsRepository) Insert(param *domain.LogSms) error { | ||
| 20 | + m := models.LogSms{ | ||
| 21 | + Id: param.Id, | ||
| 22 | + Phone: param.Phone, | ||
| 23 | + TemplateId: param.TemplateId, | ||
| 24 | + Template: param.Template, | ||
| 25 | + Value: param.Value, | ||
| 26 | + CreatedAt: param.CreatedAt, | ||
| 27 | + } | ||
| 28 | + tx := repo.transactionContext.PgTx | ||
| 29 | + _, err := tx.Model(&m).Insert() | ||
| 30 | + if err != nil { | ||
| 31 | + return err | ||
| 32 | + } | ||
| 33 | + return nil | ||
| 34 | +} |
| @@ -67,11 +67,14 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e | @@ -67,11 +67,14 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e | ||
| 67 | } | 67 | } |
| 68 | db := repo.transactionContext.PgTx | 68 | db := repo.transactionContext.PgTx |
| 69 | if m.Id == 0 { | 69 | if m.Id == 0 { |
| 70 | + m.CreatedAt = time.Now() | ||
| 71 | + m.UpdatedAt = time.Now() | ||
| 70 | _, err := db.Model(&m).Insert() | 72 | _, err := db.Model(&m).Insert() |
| 71 | if err != nil { | 73 | if err != nil { |
| 72 | return err | 74 | return err |
| 73 | } | 75 | } |
| 74 | } else { | 76 | } else { |
| 77 | + m.UpdatedAt = time.Now() | ||
| 75 | _, err := db.Model(&m).Update() | 78 | _, err := db.Model(&m).Update() |
| 76 | if err != nil { | 79 | if err != nil { |
| 77 | return err | 80 | return err |
| @@ -51,11 +51,14 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati | @@ -51,11 +51,14 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati | ||
| 51 | } | 51 | } |
| 52 | db := repo.transactionContext.PgTx | 52 | db := repo.transactionContext.PgTx |
| 53 | if m.Id == 0 { | 53 | if m.Id == 0 { |
| 54 | + m.CreatedAt = time.Now() | ||
| 55 | + m.UpdatedAt = time.Now() | ||
| 54 | _, err := db.Model(&m).Insert() | 56 | _, err := db.Model(&m).Insert() |
| 55 | if err != nil { | 57 | if err != nil { |
| 56 | return err | 58 | return err |
| 57 | } | 59 | } |
| 58 | } else { | 60 | } else { |
| 61 | + m.UpdatedAt = time.Now() | ||
| 59 | _, err := db.Model(&m).Update() | 62 | _, err := db.Model(&m).Update() |
| 60 | if err != nil { | 63 | if err != nil { |
| 61 | return err | 64 | return err |
-
请 注册 或 登录 后发表评论