github.com/Ptt-official-app/go-bbs@v0.12.0/pttbbs/pttbbs_write_board_connector.go (about) 1 package pttbbs 2 3 import ( 4 "github.com/Ptt-official-app/go-bbs" 5 6 "fmt" 7 ) 8 9 func (c *Connector) NewBoardRecord(args map[string]interface{}) (bbs.BoardRecord, error) { 10 // return fmt.Errorf("not implement") 11 record := NewBoardHeader() 12 13 boardID, ok := args["board_id"].(string) 14 if !ok { 15 return nil, fmt.Errorf("NewBoardRecord: board_id must not be empty") 16 } 17 record.SetBoardID(boardID) 18 19 title, ok := args["title"].(string) 20 if !ok { 21 return nil, fmt.Errorf("NewBoardRecord: title must not be empty") 22 } 23 record.SetTitle(title) 24 25 return record, nil 26 } 27 28 // AddBoardRecordFileRecord given record file name and new record, should append 29 // file record in that file. 30 func (c *Connector) AddBoardRecordFileRecord(name string, brd bbs.BoardRecord) error { 31 b, ok := brd.(*BoardHeader) 32 if !ok { 33 return fmt.Errorf("brd should be create with NewBoardRecord") 34 35 } 36 return AppendBoardHeaderFileRecord(name, b) 37 } 38 39 // UpdateBoardRecordFileRecord update boardRecord brd on index in record file, 40 // index is start with 0 41 func (c *Connector) UpdateBoardRecordFileRecord(name string, index uint, brd bbs.BoardRecord) error { 42 return fmt.Errorf("not implement") 43 } 44 45 // ReadBoardRecordFileRecord return boardRecord brd on index in record file. 46 func (c *Connector) ReadBoardRecordFileRecord(name string, index uint) (bbs.BoardRecord, error) { 47 return nil, fmt.Errorf("not implement") 48 } 49 50 // RemoveBoardRecordFileRecord remove boardRecord brd on index in record file. 51 func (c *Connector) RemoveBoardRecordFileRecord(name string, index uint) error { 52 return fmt.Errorf("not implement") 53 } 54 55 var _ bbs.WriteBoardConnector = &Connector{}