credit_account_controller.go
3.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package controllers
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/service"
)
type CreditAccountController struct {
BaseController
}
func (controller *CreditAccountController) CreateCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
createCreditAccountCommand := &command.CreateCreditAccountCommand{}
controller.Unmarshal(createCreditAccountCommand)
data, err := creditAccountService.CreateCreditAccount(createCreditAccountCommand)
controller.Response(data, err)
}
func (controller *CreditAccountController) UpdateCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
updateCreditAccountCommand := &command.UpdateCreditAccountCommand{}
controller.Unmarshal(updateCreditAccountCommand)
creditAccountId, _ := controller.GetInt64(":creditAccountId")
updateCreditAccountCommand.CreditAccountId = creditAccountId
data, err := creditAccountService.UpdateCreditAccount(updateCreditAccountCommand)
controller.Response(data, err)
}
func (controller *CreditAccountController) GetCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
getCreditAccountQuery := &query.GetCreditAccountQuery{}
creditAccountId, _ := controller.GetInt64(":creditAccountId")
getCreditAccountQuery.CreditAccountId = creditAccountId
data, err := creditAccountService.GetCreditAccount(getCreditAccountQuery)
controller.Response(data, err)
}
func (controller *CreditAccountController) RemoveCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
removeCreditAccountCommand := &command.RemoveCreditAccountCommand{}
controller.Unmarshal(removeCreditAccountCommand)
creditAccountId, _ := controller.GetInt64(":creditAccountId")
removeCreditAccountCommand.CreditAccountId = creditAccountId
data, err := creditAccountService.RemoveCreditAccount(removeCreditAccountCommand)
controller.Response(data, err)
}
func (controller *CreditAccountController) SearchCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
searchCreditAccountQuery := &query.SearchCreditAccountQuery{}
data, err := creditAccountService.SearchCreditAccount(searchCreditAccountQuery)
controller.Response(data, err)
}
func (controller *CreditAccountController) PayCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
payCreditAccountCommand := &command.PayCreditAccountCommand{}
controller.Unmarshal(payCreditAccountCommand)
data, err := creditAccountService.PayCreditAccount(payCreditAccountCommand)
controller.Response(data, err)
}
func (controller *CreditAccountController) ListCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
listCreditAccountQuery := &query.ListCreditAccountQuery{}
offset, _ := controller.GetInt("offset")
listCreditAccountQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listCreditAccountQuery.Limit = limit
data, err := creditAccountService.ListCreditAccount(listCreditAccountQuery)
controller.Response(data, err)
}