func ArticleLikeLogs(userId int64, articleIds interface{}) []int64 {
	var signs []int64
	articleIdStr := utils.SliceToString(articleIds, ",")
	sql := "select article_id from article_like where user_id = ? and valid=1 and article_id in (" + articleIdStr + ") "
	db := db.NewDB()
	db.Raw(sql, userId).QueryRows(&signs)
	return signs
}
Пример #2
0
func TestExtractFieldValues(t *testing.T) {

	var users []entities.User

	users = append(users, entities.User{Id: 1, Name: "第1个"})
	users = append(users, entities.User{Id: 2, Name: "第2个"})
	users = append(users, entities.User{Id: 3, Name: "第3个"})
	users = append(users, entities.User{Id: 4, Name: "第4个"})
	users = append(users, entities.User{Id: 5, Name: "第5个"})
	users = append(users, entities.User{Id: 6, Name: "第6个"})

	ids, err := utils.ExtractFieldValues(users, "Id")
	if nil != err {
		fmt.Println("err:", err)
	}
	for _, id := range ids {
		fmt.Println("id:", id)
	}

	str := utils.SliceToString(ids, ",")

	fmt.Println("str:", str)

}