go-common/app/admin/ep/melloi/service/user.go

32 lines
876 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package service
import (
"go-common/app/admin/ep/melloi/model"
"go-common/library/log"
)
// QueryUser query user info
func (s *Service) QueryUser(userName string) (user *model.User, err error) {
return s.CreateUser(userName)
}
// CreateUser create user
func (s *Service) CreateUser(userName string) (userData *model.User, err error) {
//此处因为业务因素出现错误需要继续执行不能retrun !!!
if userData, err = s.dao.QueryUserByUserName(userName); err != nil {
log.Error("s.dao.QueryUserByUserName err :(%v)", err)
}
if userData.ID == 0 {
user := model.User{Name: userName, Email: userName + "@bilibili.com", Active: "1", Accept: -1}
s.dao.AddUser(&user)
userData, err = s.dao.QueryUserByUserName(userName)
}
return
}
// UpdateUser update user
func (s *Service) UpdateUser(user *model.User) error {
return s.dao.UpdateUser(user)
}