package topical import ( "gofiber.study.skcks.cn/global" "gofiber.study.skcks.cn/model/generic/models" "strconv" ) type Service struct { } var Services *Service func InitService() { Services = &Service{} } type CreateTopicalDTO struct { Title string Content string } func (s *Service) CreateTopical(dto CreateTopicalDTO, userId string) error { id, _ := global.SonyFlake.NextID() _, err := global.DataSources.Insert(&models.Topical{ Id: strconv.FormatUint(id, 10), Active: true, Content: dto.Content, ModifyTimes: 0, Title: dto.Title, UserId: userId, }) if err != nil { return err } return nil }