forked from krasnopv/das
/
country.go
60 lines (53 loc) · 1.95 KB
/
country.go
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
package reference
import (
"github.com/DancesportSoftware/das/businesslogic"
"github.com/DancesportSoftware/das/config/database"
"github.com/DancesportSoftware/das/controller/reference"
"github.com/DancesportSoftware/das/controller/util"
"net/http"
)
const apiReferenceCountryEndpoint = "/api/v1.0/reference/country"
var countryServer = reference.CountryServer{
database.CountryRepository,
}
var searchCountryController = util.DasController{
Name: "SearchCountryController",
Description: "Search countries in DAS",
Method: http.MethodGet,
Endpoint: apiReferenceCountryEndpoint,
Handler: countryServer.SearchCountryHandler,
AllowedRoles: []int{businesslogic.AccountTypeNoAuth},
}
var createCountryController = util.DasController{
Name: "CreateCountryController",
Description: "Create a country in DAS",
Method: http.MethodPost,
Endpoint: apiReferenceCountryEndpoint,
Handler: countryServer.CreateCountryHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
var deleteCountryController = util.DasController{
Name: "DeleteCountryController",
Description: "Delete a country from DAS",
Method: http.MethodDelete,
Endpoint: apiReferenceCountryEndpoint,
Handler: countryServer.DeleteCountryHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
var updateCountryController = util.DasController{
Name: "UpdateCountryController",
Description: "Update a country in DAS",
Method: http.MethodPut,
Endpoint: apiReferenceCountryEndpoint,
Handler: countryServer.UpdateCountryHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
// CountryControllerGroup is a collection of handler functions for managing countries in DAS
var CountryControllerGroup = util.DasControllerGroup{
Controllers: []util.DasController{
searchCountryController,
createCountryController,
deleteCountryController,
updateCountryController,
},
}