user.go 876 B

12345678910111213141516171819202122232425262728293031
  1. package service
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/log"
  5. )
  6. // QueryUser query user info
  7. func (s *Service) QueryUser(userName string) (user *model.User, err error) {
  8. return s.CreateUser(userName)
  9. }
  10. // CreateUser create user
  11. func (s *Service) CreateUser(userName string) (userData *model.User, err error) {
  12. //此处因为业务因素,出现错误需要继续执行,不能retrun !!!
  13. if userData, err = s.dao.QueryUserByUserName(userName); err != nil {
  14. log.Error("s.dao.QueryUserByUserName err :(%v)", err)
  15. }
  16. if userData.ID == 0 {
  17. user := model.User{Name: userName, Email: userName + "@bilibili.com", Active: "1", Accept: -1}
  18. s.dao.AddUser(&user)
  19. userData, err = s.dao.QueryUserByUserName(userName)
  20. }
  21. return
  22. }
  23. // UpdateUser update user
  24. func (s *Service) UpdateUser(user *model.User) error {
  25. return s.dao.UpdateUser(user)
  26. }