| | |
| | | return FileService{} |
| | | } |
| | | |
| | | func (FileService) GetFile(id uint) (*model.File, int) { |
| | | file, err := model.NewFileSearch().SetId(id).First() |
| | | if err != nil { |
| | | return nil, ecode.DBErr |
| | | } |
| | | |
| | | return file, ecode.OK |
| | | } |
| | | |
| | | func (FileService) AddFile(fileRecord *model.File) int { |
| | | |
| | | err := model.NewFileSearch().Create(fileRecord) |
| | |
| | | } |
| | | |
| | | func (FileService) UpdateFile(file *model.File) int { |
| | | err := model.NewFileSearch().SetId(file.ID).Save(file) |
| | | err := model.NewFileSearch().SetId(file.ID).Update(file) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |