service.go 652 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "context"
  4. "crypto/aes"
  5. "crypto/cipher"
  6. "go-common/app/admin/main/passport/conf"
  7. "go-common/app/admin/main/passport/dao"
  8. )
  9. // Service struct
  10. type Service struct {
  11. c *conf.Config
  12. dao *dao.Dao
  13. AESBlock cipher.Block
  14. hashSalt []byte
  15. }
  16. // New init
  17. func New(c *conf.Config) (s *Service) {
  18. s = &Service{
  19. c: c,
  20. dao: dao.New(c),
  21. hashSalt: []byte(c.Encode.Salt),
  22. }
  23. s.AESBlock, _ = aes.NewCipher([]byte(c.Encode.AesKey))
  24. return s
  25. }
  26. // Ping Service
  27. func (s *Service) Ping(c context.Context) (err error) {
  28. return s.dao.Ping(c)
  29. }
  30. // Close Service
  31. func (s *Service) Close() {
  32. s.dao.Close()
  33. }