package repository

import "database/sql"

type UserRole struct {
	RoleID   int
	RoleCode string
	IsSystem bool
}

// repository/user_roles.go
// repository/user_roles.go
func GetUserRolesByUserID(db *sql.DB, userID int64) ([]int, error) {
	rows, err := db.Query(`
		SELECT role_id
		FROM dfrole_usr
		WHERE mk_dfusr_id = $1
	`, userID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()

	var roles []int
	for rows.Next() {
		var rid int
		if err := rows.Scan(&rid); err == nil {
			roles = append(roles, rid)
		}
	}
	return roles, nil
}
