user-favorite-menus_controller.go
2.0 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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/service"
)
type UserFavoriteMenusController struct {
beego.BaseController
}
func (controller *UserFavoriteMenusController) UpdateFavoriteMenus() {
userService := service.NewUserService(nil)
updateFavoriteMenusCommand := &command.UpdateFavoriteMenusCommand{}
controller.Unmarshal(updateFavoriteMenusCommand)
userId, _ := controller.GetInt64(":userId")
updateFavoriteMenusCommand.UserId = userId
data, err := userService.UpdateFavoriteMenus(updateFavoriteMenusCommand)
controller.Response(data, err)
}
func (controller *UserFavoriteMenusController) GetFavoriteMenus() {
userService := service.NewUserService(nil)
getFavoriteMenusQuery := &query.GetFavoriteMenusQuery{}
userId, _ := controller.GetInt64(":userId")
getFavoriteMenusQuery.UserId = userId
data, err := userService.GetFavoriteMenus(getFavoriteMenusQuery)
controller.Response(data, err)
}
func (controller *UserFavoriteMenusController) DeleteFavoriteMenus() {
userService := service.NewUserService(nil)
deleteFavoriteMenusCommand := &command.DeleteFavoriteMenusCommand{}
controller.Unmarshal(deleteFavoriteMenusCommand)
userId, _ := controller.GetInt64(":userId")
deleteFavoriteMenusCommand.UserId = userId
code, _ := controller.GetInt(":code")
deleteFavoriteMenusCommand.Code = code
data, err := userService.DeleteFavoriteMenus(deleteFavoriteMenusCommand)
controller.Response(data, err)
}
func (controller *UserFavoriteMenusController) UpdateFavorite() {
userService := service.NewUserService(nil)
updateFavoriteMenusCommand := &command.UpdateFavoriteCommand{}
controller.Unmarshal(updateFavoriteMenusCommand)
data, err := userService.UpdateFavorite(updateFavoriteMenusCommand)
controller.Response(data, err)
}