dsg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 23 Imported by: 1

README

数据库

  1. 数据库:COLLATE=utf8mb4_0900_ai_ci
  2. 建表:ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
  3. 项目启动时,会检测当前数据库无user表情况下,创建user表,并在models文件夹生成表对应结构体文件model.go
  4. 生成model.go使用models下cmd/gen.go,可根据genModel.go进行配置

功能

1. gRPC

  • 通过id查询用户
  • 通过id列表查询用户
  • 通过Token查询用户id和openID
  • 通过手机号查询用户id
  • 发送短信
  • 校验验证码
  • 登录(手机号未注册则自动注册
    • 参数:手机号,验证码,设备信息,登录方式(电脑web和app、公众号和小程序),其中token时效暂定web为2小时,其他为90天
  • 刷新token
  • 微信
    • 登录
      • 参数:系统标识编码、code、appID
      • 返回值:token,可以根据token获取用户id和openID,如果userID=0,说明该用户未绑定手机号
    • 绑定手机号
      • 小程序直接绑定,给公众号需要验证码校验

缓存

  • 默认缓存(非Redis
    • 系统版本
    • RSA秘钥

gRPC

go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

Documentation

Overview

Package dsg @Author: asus @Description: $ @File: New @Data: 2022/2/2118:09

Index

Constants

View Source
const (
	CodeSuccess = 0
)

Variables

View Source
var DB *gorm.DB
View Source
var ErrLevel = map[ErrorLevel]string{
	LogLevelInfo:  "info",
	LogLevelError: "error",
}

Functions

func Listening added in v1.0.0

func Listening(app *iris.Application)

Listening 开始监听端口

func Load added in v1.0.0

func Load(app *iris.Application, configPath string)

func LoadMysql added in v1.0.0

func LoadMysql()

func LoadRedisDefault added in v1.0.0

func LoadRedisDefault()

func LogError added in v1.0.0

func LogError(msg string, data interface{})

func LogInfo added in v1.0.0

func LogInfo(msg string, data interface{})

func MySqlDefault added in v1.0.0

func MySqlDefault() *gorm.DB

func RedisInit added in v1.0.0

func RedisInit(conf env.Redis) *redis.Client

Types

type Api added in v1.0.0

type Api struct {
	Method     string
	Name       string
	Login      bool
	AuthKey    string
	Controller func(base *Base) ApiInterface
}

type ApiInterface added in v1.0.0

type ApiInterface interface {
	Handler() int
}

type Base added in v1.0.0

type Base struct {
	Method string `json:"-"`
	Path   string `json:"-"`

	Time      time.Time `json:"-"`
	TimeStamp int64     `json:"-"`

	// 参数签名
	RandomStr string `valid:"length(32|32)"`
	SignAt    int64  `valid:"timestamp"`
	Sign      string `valid:"-"`
	// contains filtered or unexported fields
}

func NewBase added in v1.0.0

func NewBase(ctx iris.Context) *Base

func (*Base) CancelMustJsonParam added in v1.0.0

func (p *Base) CancelMustJsonParam()

func (*Base) CryptReceive added in v1.0.0

func (p *Base) CryptReceive() []byte

CryptReceive 加密:后端--->前端

func (*Base) CryptSend added in v1.0.0

func (p *Base) CryptSend(data []byte)

CryptSend 加密:后端--->前端

func (*Base) Ctx added in v1.0.0

func (p *Base) Ctx() iris.Context

func (*Base) DB added in v1.0.0

func (p *Base) DB() *gorm.DB

DB 默认

func (*Base) Init added in v1.0.0

func (p *Base) Init(data interface{})

func (*Base) InitAndBackParam added in v1.0.0

func (p *Base) InitAndBackParam(data interface{}) (param map[string]interface{})

InitAndBackParam Init返回前端传回的参数

func (*Base) Key added in v1.0.0

func (p *Base) Key() (rsa []byte)

Key 从header中获取前端公钥

func (*Base) MyId added in v1.0.0

func (p *Base) MyId() uint32

func (*Base) MyIdToString added in v1.0.0

func (p *Base) MyIdToString() string

func (*Base) Page added in v1.0.0

func (p *Base) Page() int64

func (*Base) PageSize added in v1.0.0

func (p *Base) PageSize() int64

func (*Base) Redis added in v1.0.0

func (p *Base) Redis() *RedisDsg

func (*Base) ReplaceParamColumn added in v1.0.0

func (p *Base) ReplaceParamColumn(data, old interface{}, requestParam map[string]interface{}) map[string]interface{}

func (*Base) SetMyId added in v1.0.0

func (p *Base) SetMyId(id uint32)

func (*Base) Skip added in v1.0.0

func (p *Base) Skip() int64

func (*Base) Success added in v1.0.0

func (p *Base) Success()

func (*Base) SuccessWithData added in v1.0.0

func (p *Base) SuccessWithData(data interface{})

func (*Base) SuccessWithList added in v1.0.0

func (p *Base) SuccessWithList(list interface{}, total interface{})

func (*Base) Token added in v1.0.0

func (p *Base) Token() (token string)

func (*Base) ValidateParam added in v1.0.0

func (p *Base) ValidateParam(data interface{})

ValidateParam 参数校验

type ErrorLevel added in v1.0.0

type ErrorLevel int
const (
	LogLevelInfo ErrorLevel = 1 + iota
	LogLevelError
)

type RedisDsg added in v1.0.0

type RedisDsg struct {
	Conn *redis.Client
}

func RedisDefault added in v1.0.0

func RedisDefault() *RedisDsg

func (*RedisDsg) ErrRedisDel added in v1.0.0

func (p *RedisDsg) ErrRedisDel(key string) bool

func (*RedisDsg) ErrRedisExists added in v1.0.0

func (p *RedisDsg) ErrRedisExists(key string) (bool, bool)

func (*RedisDsg) ErrRedisExpire added in v1.0.0

func (p *RedisDsg) ErrRedisExpire(key string, lifetime int) bool

func (*RedisDsg) ErrRedisGet added in v1.0.0

func (p *RedisDsg) ErrRedisGet(key string) (string, bool)

func (*RedisDsg) ErrRedisHDel added in v1.0.0

func (p *RedisDsg) ErrRedisHDel(key, field string) bool

func (*RedisDsg) ErrRedisHExists added in v1.0.0

func (p *RedisDsg) ErrRedisHExists(key, field string) (bool, bool)

func (*RedisDsg) ErrRedisHGet added in v1.0.0

func (p *RedisDsg) ErrRedisHGet(key, field string) (string, bool)

func (*RedisDsg) ErrRedisHScan added in v1.0.0

func (p *RedisDsg) ErrRedisHScan(key string, cursor uint64, match string, count int64) ([]string, uint64, bool)

func (*RedisDsg) ErrRedisHSet added in v1.0.0

func (p *RedisDsg) ErrRedisHSet(key, field, value string) bool

func (*RedisDsg) ErrRedisIncr added in v1.0.0

func (p *RedisDsg) ErrRedisIncr(key string) (int64, bool)

func (*RedisDsg) ErrRedisLRange added in v1.0.0

func (p *RedisDsg) ErrRedisLRange(key string, start, end int64) ([]string, bool)

func (*RedisDsg) ErrRedisPop added in v1.0.0

func (p *RedisDsg) ErrRedisPop(key string) (string, bool)

func (*RedisDsg) ErrRedisPush added in v1.0.0

func (p *RedisDsg) ErrRedisPush(key, value string) bool

func (*RedisDsg) ErrRedisSMembers added in v1.0.0

func (p *RedisDsg) ErrRedisSMembers(key string) ([]string, bool)

func (*RedisDsg) ErrRedisSadd added in v1.0.0

func (p *RedisDsg) ErrRedisSadd(key string, members ...interface{}) (int64, bool)

func (*RedisDsg) ErrRedisScan added in v1.0.0

func (p *RedisDsg) ErrRedisScan(cursor uint64, match string, count int64) ([]string, uint64, bool)

func (*RedisDsg) ErrRedisSet added in v1.0.0

func (p *RedisDsg) ErrRedisSet(key, value string, sec int) bool

func (*RedisDsg) ErrRedisZADD added in v1.0.0

func (p *RedisDsg) ErrRedisZADD(key string, members ...*redis.Z) (int64, bool)

set 类型 ***************************** 有序合集 set *****************************

func (*RedisDsg) ErrRedisZIncrBy added in v1.0.0

func (p *RedisDsg) ErrRedisZIncrBy(key string, increment float64, member string) (float64, bool)

func (*RedisDsg) ErrRedisZRange added in v1.0.0

func (p *RedisDsg) ErrRedisZRange(key string, start, stop int64) ([]string, bool)

***************************** ZRange *****************************

func (*RedisDsg) ErrRedisZRevRange added in v1.0.0

func (p *RedisDsg) ErrRedisZRevRange(key string, start, stop int64) ([]string, bool)

***************************** ZRevRange *****************************

func (*RedisDsg) ErrRedisZRevRangeWithScores added in v1.0.0

func (p *RedisDsg) ErrRedisZRevRangeWithScores(key string, start, stop int64) ([]redis.Z, bool)

***************************** ZRevRangeWithScores *****************************

func (*RedisDsg) RedisDel added in v1.0.0

func (p *RedisDsg) RedisDel(key string)

func (*RedisDsg) RedisExists added in v1.0.0

func (p *RedisDsg) RedisExists(key string) bool

func (*RedisDsg) RedisExpire added in v1.0.0

func (p *RedisDsg) RedisExpire(key string, lifetime int)

func (*RedisDsg) RedisGet added in v1.0.0

func (p *RedisDsg) RedisGet(key string) string

func (*RedisDsg) RedisHDel added in v1.0.0

func (p *RedisDsg) RedisHDel(key, field string)

func (*RedisDsg) RedisHExists added in v1.0.0

func (p *RedisDsg) RedisHExists(key, field string) bool

func (*RedisDsg) RedisHGet added in v1.0.0

func (p *RedisDsg) RedisHGet(key, field string) string

func (*RedisDsg) RedisHScan added in v1.0.0

func (p *RedisDsg) RedisHScan(key string, cursor uint64, match string, count int64) ([]string, uint64)

func (*RedisDsg) RedisHSet added in v1.0.0

func (p *RedisDsg) RedisHSet(key, field, value string)

func (*RedisDsg) RedisIncr added in v1.0.0

func (p *RedisDsg) RedisIncr(key string) int64

func (*RedisDsg) RedisLRange added in v1.0.0

func (p *RedisDsg) RedisLRange(key string, start, end int64) []string

func (*RedisDsg) RedisPop added in v1.0.0

func (p *RedisDsg) RedisPop(key string) string

func (*RedisDsg) RedisPush added in v1.0.0

func (p *RedisDsg) RedisPush(key, value string)

func (*RedisDsg) RedisSMembers added in v1.0.0

func (p *RedisDsg) RedisSMembers(key string) []string

func (*RedisDsg) RedisSadd added in v1.0.0

func (p *RedisDsg) RedisSadd(key string, members ...interface{}) int64

func (*RedisDsg) RedisScan added in v1.0.0

func (p *RedisDsg) RedisScan(cursor uint64, match string, count int64) ([]string, uint64)

func (*RedisDsg) RedisSet added in v1.0.0

func (p *RedisDsg) RedisSet(key, value string, sec int)

func (*RedisDsg) RedisZADD added in v1.0.0

func (p *RedisDsg) RedisZADD(key string, members ...*redis.Z) int64

func (*RedisDsg) RedisZIncrBy added in v1.0.0

func (p *RedisDsg) RedisZIncrBy(key string, increment float64, member string) float64

func (*RedisDsg) RedisZRange added in v1.0.0

func (p *RedisDsg) RedisZRange(key string, start, stop int64) []string

func (*RedisDsg) RedisZRevRange added in v1.0.0

func (p *RedisDsg) RedisZRevRange(key string, start, stop int64) []string

func (*RedisDsg) RedisZRevRangeWithScores added in v1.0.0

func (p *RedisDsg) RedisZRevRangeWithScores(key string, start, stop int64) []redis.Z

type ResJson added in v1.0.0

type ResJson struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type ResSign added in v1.0.0

type ResSign struct {
	RandomStr string
	SignAt    int64
	Sign      string
}

type Service added in v0.8.0

type Service struct {
	App *iris.Application
}

func New

func New(paths ...string) *Service

func (*Service) Start added in v0.8.0

func (app *Service) Start()

Start 启动监听

type UpBase added in v1.0.0

type UpBase struct {
	Base
	// contains filtered or unexported fields
}

Directories

Path Synopsis
render
Package render @Author: asus @Description: $ @File: category_render @Data: 2022/2/2816:48
Package render @Author: asus @Description: $ @File: category_render @Data: 2022/2/2816:48
cond
Package cond @Author: asus @Description: $ @File: cond @Data: 2022/4/129:54
Package cond @Author: asus @Description: $ @File: cond @Data: 2022/4/129:54
service
aesService/ecb_aes
Package ecb_aes @Author: asus @Description: $ @File: aes_decrypt @Data: 2022/8/1917:12
Package ecb_aes @Author: asus @Description: $ @File: aes_decrypt @Data: 2022/8/1917:12
fileService
Package fileService @Author: asus @Description: $ @File: router.go @Data: 2022/4/1116:51
Package fileService @Author: asus @Description: $ @File: router.go @Data: 2022/4/1116:51
grpcService/userCard
Package userCard @Author: asus @Description: $ @File: userCard @Data: 2022/4/116:46
Package userCard @Author: asus @Description: $ @File: userCard @Data: 2022/4/116:46
grpcService/userHistory
Package userHistory @Author: asus @Description: $ @File: userHistory @Data: 2022/4/116:53
Package userHistory @Author: asus @Description: $ @File: userHistory @Data: 2022/4/116:53
validatorService
Package frame @Author: asus @Description: $ @File: registerValidation @Data: 2021/12/311:16
Package frame @Author: asus @Description: $ @File: registerValidation @Data: 2021/12/311:16
Package service @Author: asus @Description: $ @File: random @Data: 2021/12/2318:44
Package service @Author: asus @Description: $ @File: random @Data: 2021/12/2318:44
guzzle
Package guzzle @Author: asus @Description: $ @File: client @Data: 2022/1/2016:41
Package guzzle @Author: asus @Description: $ @File: client @Data: 2022/1/2016:41

Jump to

Keyboard shortcuts

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