gofiber-study/services/topical/topical.go
Shikong 7392e4c26a login sha1 加密
主题创建测试
2022-11-13 19:34:48 +08:00

36 lines
642 B
Go

package topical
import (
"gofiber.study.skcks.cn/global"
"gofiber.study.skcks.cn/model/generic/models"
"gofiber.study.skcks.cn/model/topical"
"strconv"
)
type Service struct {
}
var Services *Service
func InitService() {
Services = &Service{}
}
func (s *Service) CreateTopical(dto topical.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
}