func (this *ContentPuzzleActivityComponentPuzzleDbModel) GetByComponentIdForTrans(sess *xorm.Session, componentId int) []ContentPuzzleActivityComponentPuzzle {
	result := []ContentPuzzleActivityComponentPuzzle{}
	err := sess.Sql("select * from t_content_puzzle_activity_component_puzzle where contentPuzzleActivityComponentId = ? for update", componentId).Find(&result)
	if err != nil {
		panic(err)
	}
	return result
}
示例#2
0
文件: feed.go 项目: kissthink/qreader
// Get feed list with amount, unread and starred number.
func GetFeedListWithAmount(session *xorm.Session) (feedlist []*FeedWithAmount, err error) {

	sql := `select Feed.*,t1.Amount,t2.Unread,t3.Starred from Feed left join
            (select Fid,count(*) as Amount from Item group by Fid) as t1 on Feed.Id = t1.Fid left join
            (select Fid,count(*) as Unread from Item where Read=0 group by Fid) as t2 on t1.Fid=t2.Fid left join
            (select Fid,count(*) as Starred from Item where Starred=1 group by Fid) as t3 on t1.Fid=t3.Fid`

	if session == nil {
		err = global.Orm.Sql(sql).Find(&feedlist)
	} else {
		err = session.Sql(sql).Find(&feedlist)
	}

	return
}
示例#3
0
func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *xorm.Session) error {
	var sql bytes.Buffer
	params := make([]interface{}, 0)

	sql.WriteString(`SELECT
										alert_notification.id,
										alert_notification.org_id,
										alert_notification.name,
										alert_notification.type,
										alert_notification.created,
										alert_notification.updated,
										alert_notification.settings,
										alert_notification.is_default
										FROM alert_notification
	  							`)

	sql.WriteString(` WHERE alert_notification.org_id = ?`)
	params = append(params, query.OrgId)

	if query.Name != "" || query.Id != 0 {
		if query.Name != "" {
			sql.WriteString(` AND alert_notification.name = ?`)
			params = append(params, query.Name)
		}

		if query.Id != 0 {
			sql.WriteString(` AND alert_notification.id = ?`)
			params = append(params, query.Id)
		}
	}

	results := make([]*m.AlertNotification, 0)
	if err := sess.Sql(sql.String(), params...).Find(&results); err != nil {
		return err
	}

	if len(results) == 0 {
		query.Result = nil
	} else {
		query.Result = results[0]
	}

	return nil
}
示例#4
0
文件: feed.go 项目: kissthink/qreader
func getTagAndFeedIds(session *xorm.Session) (result []*TagAndFeedId, err error) {
	err = session.Sql("select Feed.Id as FeedId,Tag.Name as Tag from Feed left join Tag on Feed.Id=Tag.Fid").Find(&result)
	return
}