正在显示
12 个修改的文件
包含
197 行增加
和
1 行删除
| @@ -12,6 +12,8 @@ type UserBaseDto struct { | @@ -12,6 +12,8 @@ type UserBaseDto struct { | ||
| 12 | UserType int `json:"userType"` | 12 | UserType int `json:"userType"` |
| 13 | // 用户信息 | 13 | // 用户信息 |
| 14 | UserInfo *domain.UserInfo `json:"userInfo,omitempty"` | 14 | UserInfo *domain.UserInfo `json:"userInfo,omitempty"` |
| 15 | + // 收藏 | ||
| 16 | + Favorite *domain.Favorite `json:"favorite"` | ||
| 15 | // 手机号码 | 17 | // 手机号码 |
| 16 | //Account string `json:"phone,omitempty"` | 18 | //Account string `json:"phone,omitempty"` |
| 17 | // 密码 | 19 | // 密码 |
| @@ -31,6 +33,7 @@ type UserBaseDto struct { | @@ -31,6 +33,7 @@ type UserBaseDto struct { | ||
| 31 | func (u *UserBaseDto) LoadDto(ub *domain.UserBase) { | 33 | func (u *UserBaseDto) LoadDto(ub *domain.UserBase) { |
| 32 | u.UserBaseId = ub.UserBaseId | 34 | u.UserBaseId = ub.UserBaseId |
| 33 | u.UserInfo = ub.UserInfo | 35 | u.UserInfo = ub.UserInfo |
| 36 | + u.Favorite = ub.Favorite | ||
| 34 | u.UserType = domain.UserTypeVisitor | 37 | u.UserType = domain.UserTypeVisitor |
| 35 | u.Im = ub.Im | 38 | u.Im = ub.Im |
| 36 | } | 39 | } |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
| 6 | + "reflect" | ||
| 7 | + "strings" | ||
| 8 | + | ||
| 9 | + "github.com/beego/beego/v2/core/validation" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type UpdateFavoriteCommand struct { | ||
| 13 | + OperateInfo *domain.OperateInfo `json:"-"` | ||
| 14 | + | ||
| 15 | + UserBaseId int64 `json:"userBaseId" valid:"Required"` | ||
| 16 | + // 菜单编码列表 | ||
| 17 | + Item string `json:"item" valid:"Required"` | ||
| 18 | + // 项唯一标识 | ||
| 19 | + ItemId int64 `cname:"项唯一标识" json:"itemId" valid:"Required"` | ||
| 20 | + // 用户Id 用户唯一标识 | ||
| 21 | + Action int64 `cname:"操作类型 1:关注 2:取消关注 " json:"action" valid:"Required"` | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (UpdateFavoriteCommand *UpdateFavoriteCommand) Valid(validation *validation.Validation) { | ||
| 25 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (UpdateFavoriteCommand *UpdateFavoriteCommand) ValidateCommand() error { | ||
| 29 | + valid := validation.Validation{} | ||
| 30 | + b, err := valid.Valid(UpdateFavoriteCommand) | ||
| 31 | + if err != nil { | ||
| 32 | + return err | ||
| 33 | + } | ||
| 34 | + if !b { | ||
| 35 | + elem := reflect.TypeOf(UpdateFavoriteCommand).Elem() | ||
| 36 | + for _, validErr := range valid.Errors { | ||
| 37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
| 38 | + if isExist { | ||
| 39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
| 40 | + } else { | ||
| 41 | + return fmt.Errorf(validErr.Message) | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + return nil | ||
| 46 | +} |
| @@ -20,6 +20,8 @@ type UserDto struct { | @@ -20,6 +20,8 @@ type UserDto struct { | ||
| 20 | UserRole []*domain.Role `json:"userRole"` | 20 | UserRole []*domain.Role `json:"userRole"` |
| 21 | // 收藏的菜单(工作台)(菜单编码列表) | 21 | // 收藏的菜单(工作台)(菜单编码列表) |
| 22 | FavoriteMenus []string `json:"favoriteMenus"` | 22 | FavoriteMenus []string `json:"favoriteMenus"` |
| 23 | + // 收藏 | ||
| 24 | + Favorite *domain.Favorite `json:"favorite"` | ||
| 23 | // 共创信息 (共创用户有效) | 25 | // 共创信息 (共创用户有效) |
| 24 | CooperationInfo *domain.CooperationInfo `json:"cooperationInfo,omitempty"` | 26 | CooperationInfo *domain.CooperationInfo `json:"cooperationInfo,omitempty"` |
| 25 | // 状态(1:启用 2:禁用 3:注销) | 27 | // 状态(1:启用 2:禁用 3:注销) |
| @@ -58,6 +60,7 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error { | @@ -58,6 +60,7 @@ func (dto *UserDto) LoadDto(user *domain.User, company *domain.Company) error { | ||
| 58 | dto.CooperationInfo = user.CooperationInfo | 60 | dto.CooperationInfo = user.CooperationInfo |
| 59 | dto.EnableStatus = user.EnableStatus | 61 | dto.EnableStatus = user.EnableStatus |
| 60 | dto.UserInfo = user.UserInfo | 62 | dto.UserInfo = user.UserInfo |
| 63 | + dto.Favorite = user.Favorite | ||
| 61 | if company != nil { | 64 | if company != nil { |
| 62 | dto.Company = &Company{ | 65 | dto.Company = &Company{ |
| 63 | CompanyId: company.CompanyId, | 66 | CompanyId: company.CompanyId, |
| @@ -376,6 +376,7 @@ func (userService *UserService) GetUser(getUserQuery *query.GetUserQuery) (inter | @@ -376,6 +376,7 @@ func (userService *UserService) GetUser(getUserQuery *query.GetUserQuery) (inter | ||
| 376 | } | 376 | } |
| 377 | if userBase != nil { | 377 | if userBase != nil { |
| 378 | user.UserInfo = userBase.UserInfo | 378 | user.UserInfo = userBase.UserInfo |
| 379 | + user.Favorite = userBase.Favorite | ||
| 379 | } | 380 | } |
| 380 | // TODO:后期可以移除有冗余roleType | 381 | // TODO:后期可以移除有冗余roleType |
| 381 | for i := range user.UserRole { | 382 | for i := range user.UserRole { |
| @@ -540,6 +541,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -540,6 +541,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
| 540 | user.Organization = org.CloneSample() | 541 | user.Organization = org.CloneSample() |
| 541 | user.Company = company.CloneSample() | 542 | user.Company = company.CloneSample() |
| 542 | user.UserInfo = userBase.UserInfo | 543 | user.UserInfo = userBase.UserInfo |
| 544 | + user.Favorite = userBase.Favorite | ||
| 543 | } | 545 | } |
| 544 | } | 546 | } |
| 545 | if err := userDto.LoadDto(users[i], company); err != nil { | 547 | if err := userDto.LoadDto(users[i], company); err != nil { |
| @@ -812,6 +814,45 @@ func (userService *UserService) UpdateUsersBase(updateUsersBaseCommand *command. | @@ -812,6 +814,45 @@ func (userService *UserService) UpdateUsersBase(updateUsersBaseCommand *command. | ||
| 812 | return struct{}{}, nil | 814 | return struct{}{}, nil |
| 813 | } | 815 | } |
| 814 | 816 | ||
| 817 | +// 更新我喜欢菜单列表 | ||
| 818 | +func (userService *UserService) UpdateFavorite(updateFavoriteCommand *command.UpdateFavoriteCommand) (interface{}, error) { | ||
| 819 | + if err := updateFavoriteCommand.ValidateCommand(); err != nil { | ||
| 820 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
| 821 | + } | ||
| 822 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 823 | + if err != nil { | ||
| 824 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 825 | + } | ||
| 826 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 827 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 828 | + } | ||
| 829 | + defer func() { | ||
| 830 | + transactionContext.RollbackTransaction() | ||
| 831 | + }() | ||
| 832 | + userRepository, user, err := factory.FastPgUserBase(transactionContext, updateFavoriteCommand.UserBaseId) | ||
| 833 | + if err != nil { | ||
| 834 | + return nil, err | ||
| 835 | + } | ||
| 836 | + switch updateFavoriteCommand.Action { | ||
| 837 | + case domain.Follow: | ||
| 838 | + err = user.AddFavorite(updateFavoriteCommand.Item, updateFavoriteCommand.ItemId) | ||
| 839 | + case domain.Unfollow: | ||
| 840 | + err = user.RemoveFavorite(updateFavoriteCommand.Item, updateFavoriteCommand.ItemId) | ||
| 841 | + default: | ||
| 842 | + err = fmt.Errorf("unkown action %v", updateFavoriteCommand.Action) | ||
| 843 | + } | ||
| 844 | + if err != nil { | ||
| 845 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 846 | + } | ||
| 847 | + if _, err = userRepository.Save(user); err != nil { | ||
| 848 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 849 | + } | ||
| 850 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 851 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 852 | + } | ||
| 853 | + return struct{}{}, nil | ||
| 854 | +} | ||
| 855 | + | ||
| 815 | func NewUserService(options map[string]interface{}) *UserService { | 856 | func NewUserService(options map[string]interface{}) *UserService { |
| 816 | newUserService := &UserService{} | 857 | newUserService := &UserService{} |
| 817 | return newUserService | 858 | return newUserService |
| @@ -4,7 +4,7 @@ import "os" | @@ -4,7 +4,7 @@ import "os" | ||
| 4 | 4 | ||
| 5 | var ( | 5 | var ( |
| 6 | // kafka 地址 | 6 | // kafka 地址 |
| 7 | - KAFKA_HOST = "106.75.231.90:9092" //"192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092" | 7 | + KAFKA_HOST = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092" //"106.75.231.90:9092" |
| 8 | // kafka topic log stash | 8 | // kafka topic log stash |
| 9 | TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage" | 9 | TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage" |
| 10 | // kafka topic up_block_chain | 10 | // kafka topic up_block_chain |
| @@ -66,6 +66,8 @@ type User struct { | @@ -66,6 +66,8 @@ type User struct { | ||
| 66 | Organization *Org `json:"org,omitempty"` | 66 | Organization *Org `json:"org,omitempty"` |
| 67 | // 部门 | 67 | // 部门 |
| 68 | Department *Department `json:"department,omitempty"` | 68 | Department *Department `json:"department,omitempty"` |
| 69 | + // 收藏 | ||
| 70 | + Favorite *Favorite `json:"favorite"` | ||
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | type UserRepository interface { | 73 | type UserRepository interface { |
| @@ -7,6 +7,17 @@ import ( | @@ -7,6 +7,17 @@ import ( | ||
| 7 | "time" | 7 | "time" |
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | +const ( | ||
| 11 | + FavoriteOrg = "org" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +const ( | ||
| 15 | + // 关注 | ||
| 16 | + Follow = 1 | ||
| 17 | + // 取消关注 | ||
| 18 | + Unfollow = 2 | ||
| 19 | +) | ||
| 20 | + | ||
| 10 | // 用户基础 | 21 | // 用户基础 |
| 11 | type UserBase struct { | 22 | type UserBase struct { |
| 12 | // 用户基础数据id | 23 | // 用户基础数据id |
| @@ -23,12 +34,18 @@ type UserBase struct { | @@ -23,12 +34,18 @@ type UserBase struct { | ||
| 23 | RelatedUsers []int64 `json:"relatedUsers,omitempty"` | 34 | RelatedUsers []int64 `json:"relatedUsers,omitempty"` |
| 24 | // 账号状态 1:正常 2.禁用 3:注销 | 35 | // 账号状态 1:正常 2.禁用 3:注销 |
| 25 | Status int `json:"status,omitempty"` | 36 | Status int `json:"status,omitempty"` |
| 37 | + // 关注的对象 | ||
| 38 | + Favorite *Favorite `json:"favorite,omitempty"` | ||
| 26 | // 创建时间 | 39 | // 创建时间 |
| 27 | CreatedAt time.Time `json:"createdAt,omitempty"` | 40 | CreatedAt time.Time `json:"createdAt,omitempty"` |
| 28 | // 更新时间 | 41 | // 更新时间 |
| 29 | UpdatedAt time.Time `json:"updatedAt,omitempty"` | 42 | UpdatedAt time.Time `json:"updatedAt,omitempty"` |
| 30 | } | 43 | } |
| 31 | 44 | ||
| 45 | +type Favorite struct { | ||
| 46 | + OrgItems []int64 `json:"orgItems"` | ||
| 47 | +} | ||
| 48 | + | ||
| 32 | type UserBaseRepository interface { | 49 | type UserBaseRepository interface { |
| 33 | Save(userBase *UserBase) (*UserBase, error) | 50 | Save(userBase *UserBase) (*UserBase, error) |
| 34 | Remove(userBase *UserBase) (*UserBase, error) | 51 | Remove(userBase *UserBase) (*UserBase, error) |
| @@ -178,6 +195,73 @@ func (userBase *UserBase) UpdateUserInfo(userInfo *UserInfo) error { | @@ -178,6 +195,73 @@ func (userBase *UserBase) UpdateUserInfo(userInfo *UserInfo) error { | ||
| 178 | return nil | 195 | return nil |
| 179 | } | 196 | } |
| 180 | 197 | ||
| 198 | +func (userBase *UserBase) AddFavorite(favoriteItem string, code int64) error { | ||
| 199 | + if userBase.Favorite == nil { | ||
| 200 | + userBase.Favorite = NewFavorite() | ||
| 201 | + } | ||
| 202 | + var err error | ||
| 203 | + switch favoriteItem { | ||
| 204 | + case FavoriteOrg: | ||
| 205 | + userBase.Favorite.OrgItems, err = userBase.addFavorite(userBase.Favorite.OrgItems, code) | ||
| 206 | + default: | ||
| 207 | + return fmt.Errorf("unkown type " + favoriteItem) | ||
| 208 | + } | ||
| 209 | + return err | ||
| 210 | +} | ||
| 211 | + | ||
| 212 | +func (userBase *UserBase) RemoveFavorite(favoriteItem string, code int64) error { | ||
| 213 | + if userBase.Favorite == nil { | ||
| 214 | + userBase.Favorite = NewFavorite() | ||
| 215 | + return nil | ||
| 216 | + } | ||
| 217 | + var err error | ||
| 218 | + switch favoriteItem { | ||
| 219 | + case FavoriteOrg: | ||
| 220 | + userBase.Favorite.OrgItems, err = userBase.removeFavorite(userBase.Favorite.OrgItems, code) | ||
| 221 | + default: | ||
| 222 | + return fmt.Errorf("unkown type " + favoriteItem) | ||
| 223 | + } | ||
| 224 | + return err | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +func NewFavorite() *Favorite { | ||
| 228 | + return &Favorite{ | ||
| 229 | + OrgItems: make([]int64, 0), | ||
| 230 | + } | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +// addFavorite 收藏 | ||
| 234 | +// | ||
| 235 | +// codes 菜单列表 | ||
| 236 | +func (userBase *UserBase) addFavorite(items []int64, code int64) ([]int64, error) { | ||
| 237 | + var existed = false | ||
| 238 | + for j := 0; j < len(items); j++ { | ||
| 239 | + if items[j] == code { | ||
| 240 | + existed = true | ||
| 241 | + } | ||
| 242 | + } | ||
| 243 | + if !existed { | ||
| 244 | + items = append(items, code) | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + return items, nil | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | +// removeFavorite 收藏移除 | ||
| 251 | +// | ||
| 252 | +// codes 菜单列表 | ||
| 253 | +func (userBase *UserBase) removeFavorite(items []int64, code int64) ([]int64, error) { | ||
| 254 | + var newItems = make([]int64, 0) | ||
| 255 | + | ||
| 256 | + for i := 0; i < len(items); i++ { | ||
| 257 | + if items[i] == code { | ||
| 258 | + continue | ||
| 259 | + } | ||
| 260 | + newItems = append(newItems, items[i]) | ||
| 261 | + } | ||
| 262 | + return newItems, nil | ||
| 263 | +} | ||
| 264 | + | ||
| 181 | /***** 2.缓存模块 *****/ | 265 | /***** 2.缓存模块 *****/ |
| 182 | 266 | ||
| 183 | func (m *UserBase) CacheKeyFunc() string { | 267 | func (m *UserBase) CacheKeyFunc() string { |
| @@ -21,6 +21,8 @@ type UserBase struct { | @@ -21,6 +21,8 @@ type UserBase struct { | ||
| 21 | RelatedUser []int64 `pg:",array" comment:"关联的用户 (冗余)"` | 21 | RelatedUser []int64 `pg:",array" comment:"关联的用户 (冗余)"` |
| 22 | // 账号状态 1:正常 2.禁用 3:注销 | 22 | // 账号状态 1:正常 2.禁用 3:注销 |
| 23 | Status int `comment:"账号状态 1:正常 2.禁用 3:注销"` | 23 | Status int `comment:"账号状态 1:正常 2.禁用 3:注销"` |
| 24 | + // 关注的数据 | ||
| 25 | + Favorite *domain.Favorite `comment:"关注的数据"` | ||
| 24 | // 创建时间 | 26 | // 创建时间 |
| 25 | CreatedAt time.Time `comment:"创建时间"` | 27 | CreatedAt time.Time `comment:"创建时间"` |
| 26 | // 更新时间 | 28 | // 更新时间 |
| @@ -14,6 +14,7 @@ func TransformToUserBaseDomainModelFromPgModels(userBaseModel *models.UserBase) | @@ -14,6 +14,7 @@ func TransformToUserBaseDomainModelFromPgModels(userBaseModel *models.UserBase) | ||
| 14 | Im: userBaseModel.Im, | 14 | Im: userBaseModel.Im, |
| 15 | RelatedUsers: userBaseModel.RelatedUser, | 15 | RelatedUsers: userBaseModel.RelatedUser, |
| 16 | Status: userBaseModel.Status, | 16 | Status: userBaseModel.Status, |
| 17 | + Favorite: userBaseModel.Favorite, | ||
| 17 | CreatedAt: userBaseModel.CreatedAt, | 18 | CreatedAt: userBaseModel.CreatedAt, |
| 18 | UpdatedAt: userBaseModel.UpdatedAt, | 19 | UpdatedAt: userBaseModel.UpdatedAt, |
| 19 | }, nil | 20 | }, nil |
| @@ -37,6 +37,7 @@ var ( | @@ -37,6 +37,7 @@ var ( | ||
| 37 | "im", | 37 | "im", |
| 38 | "related_user", | 38 | "related_user", |
| 39 | "status", | 39 | "status", |
| 40 | + "favorite", | ||
| 40 | "created_at", | 41 | "created_at", |
| 41 | "updated_at", | 42 | "updated_at", |
| 42 | } | 43 | } |
| @@ -66,6 +67,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | @@ -66,6 +67,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | ||
| 66 | &userBase.Im, | 67 | &userBase.Im, |
| 67 | pg.Array(&userBase.RelatedUsers), | 68 | pg.Array(&userBase.RelatedUsers), |
| 68 | &userBase.Status, | 69 | &userBase.Status, |
| 70 | + &userBase.Favorite, | ||
| 69 | &userBase.CreatedAt, | 71 | &userBase.CreatedAt, |
| 70 | &userBase.UpdatedAt, | 72 | &userBase.UpdatedAt, |
| 71 | ), | 73 | ), |
| @@ -77,6 +79,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | @@ -77,6 +79,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | ||
| 77 | userBase.Im, | 79 | userBase.Im, |
| 78 | pg.Array(userBase.RelatedUsers), | 80 | pg.Array(userBase.RelatedUsers), |
| 79 | userBase.Status, | 81 | userBase.Status, |
| 82 | + userBase.Favorite, | ||
| 80 | userBase.CreatedAt, | 83 | userBase.CreatedAt, |
| 81 | userBase.UpdatedAt, | 84 | userBase.UpdatedAt, |
| 82 | ); err != nil { | 85 | ); err != nil { |
| @@ -93,6 +96,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | @@ -93,6 +96,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | ||
| 93 | &userBase.Im, | 96 | &userBase.Im, |
| 94 | pg.Array(&userBase.RelatedUsers), | 97 | pg.Array(&userBase.RelatedUsers), |
| 95 | &userBase.Status, | 98 | &userBase.Status, |
| 99 | + &userBase.Favorite, | ||
| 96 | &userBase.CreatedAt, | 100 | &userBase.CreatedAt, |
| 97 | &userBase.UpdatedAt, | 101 | &userBase.UpdatedAt, |
| 98 | ), | 102 | ), |
| @@ -103,6 +107,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | @@ -103,6 +107,7 @@ func (repository *UserBaseRepository) Save(userBase *domain.UserBase) (*domain.U | ||
| 103 | userBase.Im, | 107 | userBase.Im, |
| 104 | pg.Array(userBase.RelatedUsers), | 108 | pg.Array(userBase.RelatedUsers), |
| 105 | userBase.Status, | 109 | userBase.Status, |
| 110 | + userBase.Favorite, | ||
| 106 | userBase.CreatedAt, | 111 | userBase.CreatedAt, |
| 107 | userBase.UpdatedAt, | 112 | userBase.UpdatedAt, |
| 108 | userBase.Identify(), | 113 | userBase.Identify(), |
| @@ -41,3 +41,11 @@ func (controller *UserFavoriteMenusController) DeleteFavoriteMenus() { | @@ -41,3 +41,11 @@ func (controller *UserFavoriteMenusController) DeleteFavoriteMenus() { | ||
| 41 | data, err := userService.DeleteFavoriteMenus(deleteFavoriteMenusCommand) | 41 | data, err := userService.DeleteFavoriteMenus(deleteFavoriteMenusCommand) |
| 42 | controller.Response(data, err) | 42 | controller.Response(data, err) |
| 43 | } | 43 | } |
| 44 | + | ||
| 45 | +func (controller *UserFavoriteMenusController) UpdateFavorite() { | ||
| 46 | + userService := service.NewUserService(nil) | ||
| 47 | + updateFavoriteMenusCommand := &command.UpdateFavoriteCommand{} | ||
| 48 | + controller.Unmarshal(updateFavoriteMenusCommand) | ||
| 49 | + data, err := userService.UpdateFavorite(updateFavoriteMenusCommand) | ||
| 50 | + controller.Response(data, err) | ||
| 51 | +} |
| @@ -9,4 +9,5 @@ func init() { | @@ -9,4 +9,5 @@ func init() { | ||
| 9 | web.Router("/user/:userId/favorite-menus", &controllers.UserFavoriteMenusController{}, "Put:UpdateFavoriteMenus") | 9 | web.Router("/user/:userId/favorite-menus", &controllers.UserFavoriteMenusController{}, "Put:UpdateFavoriteMenus") |
| 10 | web.Router("/user/:userId/favorite-menus", &controllers.UserFavoriteMenusController{}, "Get:GetFavoriteMenus") | 10 | web.Router("/user/:userId/favorite-menus", &controllers.UserFavoriteMenusController{}, "Get:GetFavoriteMenus") |
| 11 | web.Router("/user/:userId/favorite-menus/:code", &controllers.UserFavoriteMenusController{}, "Delete:DeleteFavoriteMenus") | 11 | web.Router("/user/:userId/favorite-menus/:code", &controllers.UserFavoriteMenusController{}, "Delete:DeleteFavoriteMenus") |
| 12 | + web.Router("/user-base/favorite", &controllers.UserFavoriteMenusController{}, "Post:UpdateFavorite") | ||
| 12 | } | 13 | } |
-
请 注册 或 登录 后发表评论