mysql

package
v0.0.0-...-a14fa2b Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ScheduleSQLString = []string{
		`CREATE TABLE IF NOT EXISTS %s (
			scheduleId  BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
			adminId     BIGINT UNSIGNED NOT NULL,
			date        VARCHAR(512),
			time 		VARCHAR(512),
			note        VARCHAR(512),
			PRIMARY KEY (scheduleId),
			KEY (adminId)
		)ENGINE=InnoDB AUTO_INCREMENT=1000000 DEFAULT CHARSET=utf8mb4`,
		`INSERT INTO %s (adminId,date,time,note) VALUES (?,?,?,?)`,
		`SELECT * FROM %s WHERE adminId = ? LOCK IN SHARE MODE`,
		`SELECT * FROM %s WHERE scheduleId = ? LIMIT 1 LOCK IN SHARE MODE`,
		`DELETE FROM %s WHERE scheduleId = ? LIMIT 1`,
	}
)

Functions

func CreateTable

func CreateTable(db *sql.DB, tableName string) error

CreateTable -

func DeleteByID

func DeleteByID(db *sql.DB, tableName string, scheduleID uint64) error

DeleteByID delete by id

func InsertSchedule

func InsertSchedule(db *sql.DB, tableName string, adminId uint64, date string, time string, note string) (int, error)

InsertSchedule return id

Types

type Schedule

type Schedule struct {
	ScheduleID uint64
	AdminID    uint64
	Date       string
	Time       string
	Note       string
}

Schedule -

func InfoByID

func InfoByID(db *sql.DB, tableName string, scheduleID uint64) (*Schedule, error)

InfoByID query by id

func ListValidScheduleByAdminID

func ListValidScheduleByAdminID(db *sql.DB, tableName string, adminId uint64) ([]*Schedule, error)

ListValidScheduleByAdminID return schedule list

Jump to

Keyboard shortcuts

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