forked from krasnopv/das
-
Notifications
You must be signed in to change notification settings - Fork 0
/
city.go
61 lines (53 loc) · 1.82 KB
/
city.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
61
package reference
import (
"github.com/ProximaB/das/businesslogic"
"github.com/ProximaB/das/config/database"
"github.com/ProximaB/das/controller/reference"
"github.com/ProximaB/das/controller/util"
"net/http"
)
const apiReferenceCityEndpoint = "/api/v1.0/reference/city"
var cityServer = reference.CityServer{
ICityRepository: database.CityRepository,
}
var createCityController = util.DasController{
Name: "CreateCityController",
Description: "Create a city in DAS",
Method: http.MethodPost,
Endpoint: apiReferenceCityEndpoint,
Handler: cityServer.CreateCityHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
var searchCityController = util.DasController{
Name: "SearchCityController",
Description: "Search cities in DAS",
Method: http.MethodGet,
Endpoint: apiReferenceCityEndpoint,
Handler: cityServer.SearchCityHandler,
AllowedRoles: []int{businesslogic.AccountTypeNoAuth},
}
var deleteCityController = util.DasController{
Name: "DeleteCityController",
Description: "Delete a city in DAS",
Method: http.MethodDelete,
Endpoint: apiReferenceCityEndpoint,
Handler: cityServer.DeleteCityHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
var updateCityController = util.DasController{
Name: "UpdateCityController",
Description: "Update a city in DAS",
Method: http.MethodPut,
Endpoint: apiReferenceCityEndpoint,
Handler: cityServer.UpdateCityHandler,
AllowedRoles: []int{businesslogic.AccountTypeAdministrator},
}
// CityControllerGroup is a collection of handler functions for managing cities in DAS
var CityControllerGroup = util.DasControllerGroup{
Controllers: []util.DasController{
createCityController,
deleteCityController,
updateCityController,
searchCityController,
},
}