user.go 653 B

12345678910111213141516171819202122232425
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/log"
  5. )
  6. // AddUser add user by user object
  7. func (d *Dao) AddUser(user *model.User) error {
  8. return d.DB.Create(user).Error
  9. }
  10. // QueryUserByUserName query user info by userName
  11. func (d *Dao) QueryUserByUserName(userName string) (rows *model.User, err error) {
  12. rows = &model.User{}
  13. if err = d.DB.Where("name = ?", userName).First(rows).Error; err != nil {
  14. log.Error("d.db.Where error(%v)", err)
  15. }
  16. return
  17. }
  18. // UpdateUser update user info
  19. func (d *Dao) UpdateUser(user *model.User) error {
  20. return d.DB.Model(&model.User{}).Update(user).Where("ID=?", user.ID).Error
  21. }