user.go 557 B

1234567891011121314151617181920212223
  1. package service
  2. import (
  3. "github.com/RaymondCode/simple-demo/dao"
  4. "github.com/RaymondCode/simple-demo/entities"
  5. "github.com/RaymondCode/simple-demo/util"
  6. "github.com/RaymondCode/simple-demo/util/snowflake"
  7. )
  8. func AddNewUser(userid, password string) error {
  9. md5ps := util.GetMd5Val(password)
  10. user := entities.User{
  11. Id: snowflake.MakeInt64SnowFlakeId(),
  12. UserId: userid,
  13. Password: md5ps,
  14. Name: userid,
  15. FollowCount: 0,
  16. FollowerCount: 0,
  17. IsFollow: false,
  18. }
  19. err := dao.AddNewUser(user)
  20. return err
  21. }