Skip to content

GostBop/agenda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agenda

1.简介

Agenda 是一个简单的 CLI 会议管理系统

1.1 测试

由于 cmd 不便于编写 test 文件,故使用指定测试集,手动测试命令,目前并未出现 Bug,如遇 Bug,可以写 issue,我们会及时处理!

1.2 安装

  1. 确保你已经安装 Golang 编程环境,如未安装,可参考 服务计算 | Golang 入门与配置
  2. 使用 go get github.com/7cthunder/agenda 下载项目
  3. 使用 go install github.com/7cthunder/agenda 进行编译安装

1.3 使用

参考 cmd-design.md 手册,也可以使用 help 命令来提示输入信息。

2.接口实现

entity负责创建实体与操作实体,cmd负责程序的逻辑

2.1 entity

2.1.1 User

NewUser创建一个User实体并返回它的指针

NewUser func(name, password, email, phone string) *User

xxx.Getxxx()xxx.Setxxx(xxx)用来获取或设置User实体的属性

// Getxxx
GetName func() string
GetPassword func() string
GetEmail func() string
GetPhone func() string
// Setxxx
SetName func(newName string)
SetPassword func(newPassword string)
SetEmail func(newEmail string)
SetPhone func(newPhone string)

2.1.2 Date

NewDate创建一个Date实体并返回它的指针

NewDate func(year, month, day, hour, minute int) *Date

xxx.Getxxx()xxx.Setxxx(xxx)方法用来获取或设置Date实体的属性

// Getxxx
GetYear func() int
GetMonth func() int
GetDay func() int
GetHour func() int
GetMinute func() int
// Setxxx
SetYear func(newYear int) 
SetMonth func(newMonth int)
SetDay func(newDay int) 
SetHour func(newHour int) 
SetMinute func(newMinute int) 

xxx.IsValid()判断日期是否合法

IsValid func() bool

StringToDate()DateToString()函数用来执行stringDate类型相互转化

//StringToDate convert a date string to a Date type
StringToDate func(dateString string) Date
// DateToString convert a Date struct to a string with format YYYY-MM-DD/HH:mm
DateToString func(date Date) string

因为没有操作符重载,所以设计xxx.IsEqual(xxx), xxx.IsGreater(xxx), xxx.IsLess(xxx), xxx.IsGreaterThanEqual(xxx)xxx.IsLessThanEqual(xxx)方法来判断日期的前后关系

IsEqual func(date Date) bool
IsGreater func(date Date) bool
IsLess func(date Date) bool
IsGreaterThanEqual func(date Date) bool
IsLessThanEqual func(date Date) bool

2.1.3 Meeting

NewMeeting创建一个Meeting实体并返回它的指针

NewMeeting func(sponsor string, title string, startTime Date, endTime Date, participators []string) *Meeting

xxx.Getxxx()xxx.Setxxx(xxx)方法用来获取或设置Meeting实体的属性

// Getxxx
GetSponsor func() string
GetTitle func() string
GetStartTime func() Date
GetEndTime func() Date
GetParticipators func() []string
// Setxxx
SetSponsor func(sponsor string)
SetTitle func(title string)
SetStartTime func(startTime Date)
SetEndTime func(endTime Date)
SetParticipators func(participators []string)

xxx.AddParticipator(xxx)meeting实体添加指定参与者xxx

AddParticipator func(participator string)

xxx.RemoveParticipator(xxx)meeting实体删除指定参与者xxx

RemoveParticipator func(participator string)

xxx.IsParticipator(xxx)判断xxx是否在meeting实体中

IsParticipator func(username string) bool

2.1.4 Storage

注意:Storage的方法如果调用成功会自动写入curUser.txt, Meeting.jsonUser.json

GetStorage()函数获取一个单例storage实体读写curUser.txt, Meeting.jsonUser.json

GetStorage func() *Storage

xxx.CreateUser(xxx)方法用来创建新用户

CreateUser func(newUser User)

xxx.QueryUser(uFilter)方法通过传入一个过滤器uFilter查询用户

// uFilter
type uFilter func(*User) bool
// QueryUser *
QueryUser func(filter uFilter) []User

xxx.UpdateUser(uFilter, uSwitcher)方法通过传入一个过滤器uFilter筛选用户并对它们使用uSwitcher进行更新

type uFilter func(*User) bool
type uSwitcher func(*User)
// UpdateUser *
UpdateUser func(filter uFilter, switcher uSwitcher) int

xxx.DeleteUser(uFilter)方法通过传入一个过滤器uFilter筛选用户并删除

// uFilter
type uFilter func(*User) bool
// DeleteUser *
DeleteUser func(filter uFilter) int

xxx.CreateMeeting(xxx)方法用来创建新会议并写入Meeting.json

CreateMeeting func(newMeeting Meeting)

xxx.QueryMeeting(mFilter)方法通过传入一个过滤器mFilter查询会议

// mFilter
type mFilter func(*Meeting) bool
// QueryMeeting *
QueryMeeting func(filter mFilter) []Meeting

xxx.UpdateMeeting(mFilter, mSwitcher)方法通过传入一个过滤器mFilter筛选会议并对它们使用mSwitcher进行更新

type mFilter func(*Meeting) bool
type mSwitcher func(*Meeting)
// UpdateMeeting *
UpdateMeeting func(filter mFilter, switcher mSwitcher) int

xxx.DeleteMeeting(mFilter)方法通过传入一个过滤器mFilter筛选会议并删除

// mFilter
type mFilter func(*Meeting) bool
// DeleteUser *
DeleteMeeting func(filter mFilter) int

xxx.GetCurUser()获取现在登录的用户

SetCurUser func(u User)

xxx.SetCurUser(xxx)设置当前登录用户

SetCurUser func(u User)

2.1.5 Logger

NewLogger根据传入的前缀来创建新的logger,其可同时写入log.txt和显示在屏幕上

// NewLogger create a logger which write info on screen and in ./data/log.txt with specific prefix
NewLogger func(prefix string) *log.Logger

About

大三的服务计算团队项目

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%