sdk

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

README

WeJH-SDK

提供一些封装好的工具

  • 邮件功能
  • fetch
  • 加密
  • redis初始化
  • gin-session初始化
  • wechat初始化

使用go get github.com/zjutjh/WeJH-SDK导入到项目mod

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cryted string, key string) string

func AesEncrypt

func AesEncrypt(orig string, key string) string

func AesSHA256

func AesSHA256(password string) string

func GetRedisClient

func GetRedisClient(info RedisInfoConfig) *Redis.Client

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blocksize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func SessionInit

func SessionInit(r *gin.Engine, config SessionInfoConfig)

func WeChatInitInMemory

func WeChatInitInMemory(config WechatConfig) *miniprogram.MiniProgram

func WeChatInitInRedis

func WeChatInitInRedis(config WechatConfig, redisConfig RedisInfoConfig) *miniprogram.MiniProgram

Types

type Fetch

type Fetch struct {
	Cookie []*http.Cookie
	// contains filtered or unexported fields
}

func (*Fetch) Get

func (f *Fetch) Get(url string) ([]byte, error)

func (*Fetch) GetRaw

func (f *Fetch) GetRaw(url string) (*http.Response, error)

func (*Fetch) Init

func (f *Fetch) Init()

func (*Fetch) InitUnSafe

func (f *Fetch) InitUnSafe()

func (*Fetch) PostForm

func (f *Fetch) PostForm(url string, requestData url.Values) ([]byte, error)

func (*Fetch) PostFormRaw

func (f *Fetch) PostFormRaw(url string, requestData url.Values) (*http.Response, error)

func (*Fetch) PostJsonForm

func (f *Fetch) PostJsonForm(url string, requestData map[string]string) ([]byte, error)

func (*Fetch) PostJsonFormRaw

func (f *Fetch) PostJsonFormRaw(url string, requestData map[string]string) (*http.Response, error)

func (*Fetch) SkipTlsCheck

func (f *Fetch) SkipTlsCheck()

type MailInfoConfig

type MailInfoConfig struct {
	// 发件人账号
	Sender string
	// 发件人密码,QQ邮箱这里配置授权码
	SPassword string
	// SMTP 服务器地址, QQ邮箱是smtp.qq.com
	SMTPAddr string
	// SMTP端口 QQ邮箱是25
	SMTPPort int
}

MailInfoConfig 发件人配置

func (MailInfoConfig) SendEmail

func (config MailInfoConfig) SendEmail(message string, mailbox MailboxConf) error

SendEmail 一个message可以是这样的: message := fmt.Sprintf(`<div>

    <div>
        hello
    </div>
</div>`)

type MailboxConf

type MailboxConf struct {
	// 邮件标题
	Title string
	// 邮件内容
	Body string
	// 收件人列表
	RecipientList []string
}

MailboxConf 发送邮件内容配置

type RedisInfoConfig

type RedisInfoConfig struct {
	Host     string
	Port     string
	DB       int
	Password string
}

func DefaultRedisConfig

func DefaultRedisConfig() RedisInfoConfig

type SessionInfoConfig

type SessionInfoConfig struct {
	Driver      string
	Name        string
	SecretKey   string
	RedisConfig RedisInfoConfig
}

func DefaultSessionConfig

func DefaultSessionConfig() SessionInfoConfig

type WechatConfig

type WechatConfig struct {
	AppId     string
	AppSecret string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL