| | |
| | | } |
| | | |
| | | func (userService *UserService) ChangePassword(u *model.User, newPassword string) (userInter *model.User, errCode int) { |
| | | user, err := model.NewUserSearch(nil).SetId(u.ID).First() |
| | | user, err := model.NewUserSearch(nil).SetId(u.UUID).First() |
| | | if err != nil { |
| | | return nil, ecode.UserNotExist |
| | | } |
| | |
| | | } |
| | | |
| | | user.Password = encrypt.BcryptHash(newPassword) |
| | | err = model.NewUserSearch(nil).SetId(u.ID).UpdateByMap(map[string]interface{}{ |
| | | err = model.NewUserSearch(nil).SetId(u.UUID).UpdateByMap(map[string]interface{}{ |
| | | "password": user.Password}) |
| | | |
| | | return user, ecode.OK |
| | |
| | | } |
| | | |
| | | func (userService *UserService) SetUserInfo(req model.User) error { |
| | | return model.NewUserSearch(nil).SetId(req.ID).UpdateByMap(map[string]interface{}{ |
| | | return model.NewUserSearch(nil).SetId(req.UUID).UpdateByMap(map[string]interface{}{ |
| | | "nick_name": req.NickName, |
| | | "header_img": req.HeaderImg, |
| | | "phone": req.Phone, |
| | |
| | | "password": encrypt.BcryptHash("123456"), |
| | | }) |
| | | } |
| | | |
| | | func (userService *UserService) GetUserList(userIds []int) (userList []*model.User, err error) { |
| | | return model.NewUserSearch(nil).SetUserIds(userIds).FindAll() |
| | | } |
| | | |
| | | func (userService *UserService) UUID2CrmUserId(uuids []string) (crmUserIds []int, m map[string]int, err error) { |
| | | idPairs, err := model.NewUserSearch(nil).UUID2CrmUserId(uuids) |
| | | if err != nil { |
| | | return |
| | | } |
| | | crmUserIds = make([]int, 0, len(idPairs)) |
| | | m = make(map[string]int, len(idPairs)) |
| | | for _, idPair := range idPairs { |
| | | crmUserIds = append(crmUserIds, idPair.ID) |
| | | m[idPair.UUID] = idPair.ID |
| | | } |
| | | return |
| | | } |