| 123456789101112131415161718192021222324252627 |
- // Package factories 存放 topic 工厂方法
- package factories
- import (
- "github.com/bxcodec/faker/v4"
- "github.com/runningwater/gohub/app/models/topic"
- )
- func MakeTopics(times int) []topic.Topic {
- var objs []topic.Topic
- // 设置唯一值, 如 Topic 模型中的某个字段需要唯一
- faker.SetGenerateUniqueValues(true)
- for range times {
- model := topic.Topic{
- Title: faker.Sentence(),
- Body: faker.Paragraph(),
- UserID: "1",
- CategoryID: "3",
- }
- objs = append(objs, model)
- }
- return objs
- }
|