コード例 #1
0
// getTopics return all topics.
func (ts *TopicService) getTopics() *utils.ResultTransformer {

	topics := []TopicModel{}

	err := ts.db.Select(&topics, "select * from topics order by id asc limit 500")
	if err != nil {
		panic(err)
	}

	header := models.Header{Status: "ok", Count: len(topics), Data: topics}
	result := utils.NewResultTransformer(header)

	return result
}
コード例 #2
0
// getLogs return all logs.
func (ls *LogService) getLogs() *utils.ResultTransformer {

	logs := []LogModel{}

	err := ls.db.Select(&logs, "select * from logs order by id asc limit 500")
	if err != nil {
		panic(err)
	}

	header := models.Header{Status: "ok", Count: len(logs), Data: logs}
	result := utils.NewResultTransformer(header)

	return result
}
コード例 #3
0
// getSubscribers return all subscribers.
// note: get topic as name instead of id
func (ss *SubscriberService) getSubscribers() *utils.ResultTransformer {

	subscribers := []SubscriberModel{}

	err := ss.db.Select(&subscribers,
		"select id, datetime, uid, (select name from topics where id = subscribers.topic_id) as topic from subscribers")
	if err != nil {
		panic(err)
	}

	header := models.Header{Status: "ok", Count: len(subscribers), Data: subscribers}
	result := utils.NewResultTransformer(header)

	return result
}