Documentation ¶
Index ¶
- func GetPeriodScore(period string) int
- func ParseCategory(category string) (string, string)
- func ParseClassValue(classValue string) (string, string, string)
- func Valid8DigitTelephoneNum(phoneNum string) bool
- func ValidMobilePhoneNum(phoneNum string) bool
- func ValidPhoneNum(phoneNum string) bool
- type DB
- func (db *DB) ClassHandler(class *ming800.Class) error
- func (db *DB) Clear() error
- func (db *DB) GetAllClasses() ([]string, error)
- func (db *DB) GetAllPeriods() ([]string, error)
- func (db *DB) GetAllPeriodsOfCategory(category string) (map[string][]string, error)
- func (db *DB) GetAllStudents() ([]string, error)
- func (db *DB) GetClassPeriod(campus, category, class string) (string, error)
- func (db *DB) GetClassesByNameAndPhoneNum(name, phoneNum string) ([]string, error)
- func (db *DB) GetClassesPeriods() (map[string]string, error)
- func (db *DB) GetNamesByPhoneNum(phoneNum string) ([]string, error)
- func (db *DB) GetStudentsOfTeacher(teacher string) ([]string, error)
- func (db *DB) GetTeachers() ([]string, error)
- func (db *DB) GetTeachersOfClass(campus, category, class string) ([]string, error)
- func (db *DB) StudentHandler(class *ming800.Class, student *ming800.Student) error
- func (db *DB) SyncFromMing(serverURL, company, user, password string) error
- func (db *DB) ValidClass(campus, category, class string) (bool, error)
- func (db *DB) ValidPeriod(campus, category, period string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPeriodScore ¶
GetPeriodScore gets the score for the period string.
Params:
period: period string. e.g. "星期一09:00-11:30".
Return:
computed score.
func ParseCategory ¶
ParseCategory gets campus and real category from category string.
Param: category: raw category string like this: 初一(中山) Return: campus, category. e.g. campus: 中山,category: 初一
func ParseClassValue ¶
ParseClassValue parses the value of class.
Params:
classValue: class string contains campus, category and real class. format: $CAMPUS:$CATEGORY:$CLASS e.g. "新校区:一年级:一年级2班"
Returns:
campus, category, real class.
func Valid8DigitTelephoneNum ¶
Valid8DigitTelephoneNum checks if phone number matches the format: 1. Starts with 8 digital number. 2. Can have one or more '.' as sufix.
func ValidMobilePhoneNum ¶
ValidMobilePhoneNum checks if phone number matches the format: 1. Starts with 11 digital number. 2. Can have one or more '.' as sufix.
func ValidPhoneNum ¶
ValidPhoneNum checks if phone number is 11-digit mobile phone number or 8-digit telephone number.
Types ¶
type DB ¶
DB sync data from ming system.
func (*DB) ClassHandler ¶
ClassHandler implements ming800.WalkDB interface. It'll be called when a class is found.
func (*DB) GetAllClasses ¶
GetAllClasses gets the names of all classes. Return: a slice contains the names of all classes. Class name format: $campus:$category:$class.
func (*DB) GetAllPeriods ¶
GetAllPeriods gets the names of all classes. Return: a slice contains the all periods. Period name format: $campus:$category:$period.
func (*DB) GetAllPeriodsOfCategory ¶
GetAllPeriodsOfCategory gets all category's periods for all campuses.
Params:
category: category which you want to get all periods.
Returns:
a map contains all periods. key: campus, value: periods.
func (*DB) GetAllStudents ¶
GetAllStudents gets all students. Return: Slice contains student in the format: $name:$phone_num.
func (*DB) GetClassPeriod ¶
GetClassPeriod gets the period of the combination of campus, category, class.
func (*DB) GetClassesByNameAndPhoneNum ¶
GetClassesByNameAndPhoneNum searches classes by student name and phone number.
func (*DB) GetClassesPeriods ¶
GetClassesPeriods gets the period of each class. Return: a map. Key: class name($campus:$category:$class), value: period.
func (*DB) GetNamesByPhoneNum ¶
GetNamesByPhoneNum searches student names by phone number.
func (*DB) GetStudentsOfTeacher ¶
GetStudentsOfTeacher gets all students of given teacher.
Params:
teacher: name of teacher.
Return:
students in the format: $STUDENT_NAME:$CONTACT_PHONE_NUM. e.g. 小明:13800138000
func (*DB) GetTeachers ¶
GetTeachers lists all teacher names.
func (*DB) GetTeachersOfClass ¶
GetTeachersOfClass gets teachers of the class.
func (*DB) StudentHandler ¶
StudentHandler implements ming800.WalkDB interface. It'll be called when a student is found.
func (*DB) SyncFromMing ¶
SyncFromMing sync data included all current campuses, categories, students from ming800 to redis.
Params:
serverURL: server URL of ming800. e.g. "http://192.168.1.87:8080". company: company or orgnization name of ming800. user: user account of ming800. password: user password of ming800.
func (*DB) ValidClass ¶
ValidClass validates if the campus, category, class info match.