1234567891011121314151617181920212223242526272829303132333435363738 |
- package service
- import (
- "crypto/sha1"
- "fmt"
- "io"
- "iot_manager_service/app/system/dao"
- )
- // 用户管理服务
- var UserService = new(userService)
- type userService struct{}
- func (s *userService) GetUserByPasskey(passKey string) (*dao.User, error) {
- user := &dao.User{}
- err := user.GetUser()
- if err != nil {
- return nil, err
- }
- return user, nil
- }
- func (s *userService) GetOne(tenantId, account, password string) (dao.User, error) {
- t := sha1.New()
- _, _ = io.WriteString(t, password)
- password = fmt.Sprintf("%x", t.Sum(nil))
- user := dao.User{
- TenantId: tenantId,
- Account: account,
- Password: password,
- }
- err := user.GetUser()
- if err != nil {
- return dao.User{}, err
- }
- return user, nil
- }
|