log_opt_service.go
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package log_opt
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/log_opt/command"
)
type LogOptService struct {
}
func NewLogOptService() *LogOptService {
newRoleService := &LogOptService{}
return newRoleService
}
func (rs *LogOptService) List(in *command.QueryLogCommand) (interface{}, error) {
transactionContext, err := factory.ValidateStartTransaction(in)
if err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
ssMap := tool_funs.SimpleStructToMap(in)
ssMap["companyId"] = in.CompanyId
ssMap["optTargetId"] = in.TaskId
logRepository := factory.CreateLogOptRepository(map[string]interface{}{"transactionContext": transactionContext})
total, logList, err := logRepository.Find(ssMap)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return tool_funs.SimpleWrapGridMap(total, logList), nil
}