signServer

package module
v0.0.0-...-f6f6927 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagTodayTotal = "sign:today" // 今日签到
	TagUser       = "sign:user"  // 签到人
)
View Source
const (
	Sign3Day = 7   // 7     => 0000 0111
	Sign7Day = 127 // 127   => 01111 1111
)

Variables

View Source
var CurrentKey string

Functions

func GetTodayTotalNum

func GetTodayTotalNum() int64

GetTodayTotalNum 获取今日签到人数

func GetYesterdayNum

func GetYesterdayNum() int64

GetYesterdayNum 获取昨日签到人数

func Init

func Init(db *gorm.DB, rdb *redis.Client, config *Config)

func SignGetTodayNum

func SignGetTodayNum() int64

SignGetTodayNum 统计今日签到人数

func SignToday

func SignToday() int64

SignToday 统计今日签到人数 返回当前第几个签到

func SignUser

func SignUser(userID uint32) (int64, error)

SignUser 人员打卡, 返回今日第几个签到

func SignUserCheckToday

func SignUserCheckToday(userID uint32) bool

SignUserCheckToday 今日是否已经打卡

func SignUserCount

func SignUserCount(userID uint32, start, end int64) int64

SignUserCount 已打卡次数

start:0  end:-1 统计所有
统计近7天->  start:getTodayNum() - 6
0000 0000
        ^
7654 3210  计数从下标开始

func SignUserGetUint16

func SignUserGetUint16(userID uint32) []int64

SignUserGetUint16 获取近16日打卡数据

func TotalToday

func TotalToday() int64

TotalToday 签到总人次, 返回今日第几个签到

Types

type Config

type Config struct {
	NumDaysAgo int64 `json:"num_days_ago"` // 距今多少天, 为第一天(至少为当前天数 - 20天, 防止偏移超出范围)
}

type SignData

type SignData struct {
	Consecutive3   bool       // 连续三天
	Consecutive7   bool       // 连续七天
	ConsecutiveNum int        // 连续签到几天
	List           []SignInfo // 打卡情况
}

func SignUserGetInfo

func SignUserGetInfo(userID uint32) (*SignData, error)

SignUserGetInfo 获取近8日打卡情况

近3/7天打卡情况, 通过&来计算
0111 1100 1001 0000
                  &
0000 0000 0111 1111
                  =
0000 0000 0001 0000     只有打卡数据末尾都是1的情况才能拿到数据

type SignDay

type SignDay struct {
	TimeAt  int64  `json:"time_at"`
	TimeStr string `json:"time_str"`
	IsSign  bool   `json:"is_sign"`
}

type SignInfo

type SignInfo struct {
	TimeAt  int64  `json:"time_at"`  // 时间戳
	TimeStr string `json:"time_str"` // 打卡时间
	IsSign  bool   `json:"is_sign"`  //是否打卡
}

Jump to

Keyboard shortcuts

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